From 6b30f3888e46c3981f1e4fc34c155c7539275420 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 26 Oct 2007 12:20:17 -0600 Subject: Initial support for immediate values in TGSI programs. These can be evaluated at compile time. Code disabled pending clarifications of TGSI immediate data structures. --- src/mesa/pipe/tgsi/exec/tgsi_dump.c | 6 +++++- src/mesa/pipe/tgsi/exec/tgsi_exec.c | 11 +++++++++++ src/mesa/pipe/tgsi/exec/tgsi_exec.h | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/mesa/pipe/tgsi/exec') diff --git a/src/mesa/pipe/tgsi/exec/tgsi_dump.c b/src/mesa/pipe/tgsi/exec/tgsi_dump.c index 9d21da0965..e7eb811d18 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_dump.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_dump.c @@ -89,7 +89,7 @@ text_dump_flt( { char str[48]; - sprintf( str, "%40.6f", f ); + sprintf( str, "%10.4f", f ); text_dump_str( dump, str ); } @@ -780,7 +780,11 @@ dump_immediate_short( ENM( imm->Immediate.DataType, TGSI_IMMS_SHORT ); TXT( " { " ); +#if 0 for( i = 0; i < imm->Immediate.Size - 1; i++ ) { +#else + for( i = 0; i < imm->Immediate.Size; i++ ) { +#endif switch( imm->Immediate.DataType ) { case TGSI_IMM_FLOAT32: FLT( imm->u.ImmediateFloat32[i].Float ); diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c index 3f464372ca..42aed9bd6b 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.c @@ -170,6 +170,7 @@ tgsi_exec_prepare( struct tgsi_exec_machine *mach ) break; case TGSI_TOKEN_TYPE_IMMEDIATE: +#if 0 assert( (parse.FullToken.FullImmediate.Immediate.Size - 1) % 4 == 0 ); assert( mach->ImmLimit + (parse.FullToken.FullImmediate.Immediate.Size - 1) / 4 <= 256 ); @@ -177,6 +178,16 @@ tgsi_exec_prepare( struct tgsi_exec_machine *mach ) mach->Imms[mach->ImmLimit + i / 4][i % 4] = parse.FullToken.FullImmediate.u.ImmediateFloat32[i].Float; } mach->ImmLimit += (parse.FullToken.FullImmediate.Immediate.Size - 1) / 4; +#else + /* Add this immediate value (vector of 1,2,3,4 floats) to immediates array */ + assert( parse.FullToken.FullImmediate.Immediate.Size <= 4 ); + assert( mach->ImmLimit < TGSI_EXEC_NUM_IMMEDIATES ); + + for( i = 0; i < parse.FullToken.FullImmediate.Immediate.Size; i++ ) { + mach->Imms[mach->ImmLimit][i] = parse.FullToken.FullImmediate.u.ImmediateFloat32[i].Float; + } + mach->ImmLimit++; +#endif break; case TGSI_TOKEN_TYPE_INSTRUCTION: diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.h b/src/mesa/pipe/tgsi/exec/tgsi_exec.h index 6c1d368342..1805e72487 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_exec.h +++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.h @@ -93,12 +93,12 @@ struct tgsi_exec_labels #define TGSI_EXEC_NUM_TEMPS (32 + 4) #define TGSI_EXEC_NUM_ADDRS 1 +#define TGSI_EXEC_NUM_IMMEDIATES 256 #define TGSI_EXEC_MAX_COND_NESTING 10 #define TGSI_EXEC_MAX_LOOP_NESTING 10 #define TGSI_EXEC_MAX_CALL_NESTING 10 - /** * Run-time virtual machine state for executing TGSI shader. */ @@ -120,7 +120,7 @@ struct tgsi_exec_machine struct tgsi_sampler *Samplers; - float Imms[256][4]; + float Imms[TGSI_EXEC_NUM_IMMEDIATES][4]; unsigned ImmLimit; float (*Consts)[4]; struct tgsi_exec_vector *Inputs; -- cgit v1.2.3