diff options
-rw-r--r-- | src/mesa/pipe/tgsi/exec/tgsi_dump.c | 6 | ||||
-rw-r--r-- | src/mesa/pipe/tgsi/exec/tgsi_exec.c | 11 | ||||
-rw-r--r-- | src/mesa/pipe/tgsi/exec/tgsi_exec.h | 4 | ||||
-rw-r--r-- | src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c | 60 |
4 files changed, 74 insertions, 7 deletions
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; diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index 8975b4fd57..4fac61777c 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -1,9 +1,12 @@ #include "tgsi_platform.h"
#include "tgsi_mesa.h"
#include "pipe/tgsi/mesa/mesa_to_tgsi.h"
+#include "shader/prog_parameter.h"
#define TGSI_DEBUG 0
+#define EMIT_IMMEDIATES 0
+
/*
* Map mesa register file to TGSI register file.
@@ -21,9 +24,14 @@ map_register_file( //case PROGRAM_ENV_PARAM:
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
- case PROGRAM_CONSTANT:
case PROGRAM_UNIFORM:
return TGSI_FILE_CONSTANT;
+ case PROGRAM_CONSTANT:
+#if EMIT_IMMEDIATES
+ return TGSI_FILE_IMMEDIATE;
+#else
+ return TGSI_FILE_CONSTANT;
+#endif
case PROGRAM_INPUT:
return TGSI_FILE_INPUT;
case PROGRAM_OUTPUT:
@@ -49,7 +57,8 @@ map_register_file_index( GLuint file,
GLuint index,
const GLuint inputMapping[],
- const GLuint outputMapping[])
+ const GLuint outputMapping[],
+ const GLuint immediateMapping[])
{
switch( file ) {
case TGSI_FILE_INPUT:
@@ -59,6 +68,11 @@ map_register_file_index( case TGSI_FILE_OUTPUT:
return outputMapping[index];
+#if EMIT_IMMEDIATES
+ case TGSI_FILE_IMMEDIATE:
+ return immediateMapping[index];
+#endif
+
default:
return index;
}
@@ -119,12 +133,26 @@ convert_writemask( return writemask;
}
+#if EMIT_IMMEDIATES
+static struct tgsi_full_immediate
+make_immediate(const float *value, uint size)
+{
+ struct tgsi_full_immediate imm;
+ imm.Immediate.Type = TGSI_TOKEN_TYPE_IMMEDIATE;
+ imm.Immediate.Size = size;
+ imm.Immediate.DataType = TGSI_IMM_FLOAT32;
+ imm.u.ImmediateFloat32 = (struct tgsi_immediate_float32 *) value;
+ return imm;
+}
+#endif
+
static void
compile_instruction(
const struct prog_instruction *inst,
struct tgsi_full_instruction *fullinst,
const GLuint inputMapping[],
const GLuint outputMapping[],
+ const GLuint immediateMapping[],
GLuint preamble_size,
GLuint processor )
{
@@ -144,7 +172,8 @@ compile_instruction( fulldst->DstRegister.File,
inst->DstReg.Index,
inputMapping,
- outputMapping
+ outputMapping,
+ NULL
);
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );
@@ -157,7 +186,8 @@ compile_instruction( fullsrc->SrcRegister.File,
inst->SrcReg[i].Index,
inputMapping,
- outputMapping );
+ outputMapping,
+ immediateMapping);
for( j = 0; j < 4; j++ ) {
GLuint swz;
@@ -595,6 +625,10 @@ tgsi_translate_mesa_program( struct tgsi_processor *processor;
struct tgsi_full_instruction fullinst;
GLuint preamble_size = 0;
+ GLuint immediates[1000];
+#if EMIT_IMMEDIATES
+ GLuint numImmediates = 0;
+#endif
assert(procType == TGSI_PROCESSOR_FRAGMENT ||
procType == TGSI_PROCESSOR_VERTEX);
@@ -723,12 +757,30 @@ tgsi_translate_mesa_program( }
}
+ /* immediates/literals */
+#if EMIT_IMMEDIATES
+ for (i = 0; i < program->Parameters->NumParameters; i++) {
+ if (program->Parameters->Parameters[i].Type == PROGRAM_CONSTANT) {
+ struct tgsi_full_immediate fullimm
+ = make_immediate(program->Parameters->ParameterValues[i],
+ program->Parameters->Parameters[i].Size);
+ ti += tgsi_build_full_immediate(&fullimm,
+ &tokens[ti],
+ header,
+ maxTokens - ti);
+ immediates[i] = numImmediates;
+ numImmediates++;
+ }
+ }
+#endif
+
for( i = 0; i < program->NumInstructions; i++ ) {
compile_instruction(
&program->Instructions[i],
&fullinst,
inputMapping,
outputMapping,
+ immediates,
preamble_size,
procType );
|