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 );
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:
#include "tgsi_platform.h"\r
#include "tgsi_mesa.h"\r
#include "pipe/tgsi/mesa/mesa_to_tgsi.h"\r
+#include "shader/prog_parameter.h"\r
\r
#define TGSI_DEBUG 0\r
\r
+#define EMIT_IMMEDIATES 0\r
+\r
\r
/*\r
* Map mesa register file to TGSI register file.\r
//case PROGRAM_ENV_PARAM:\r
case PROGRAM_STATE_VAR:\r
case PROGRAM_NAMED_PARAM:\r
- case PROGRAM_CONSTANT:\r
case PROGRAM_UNIFORM:\r
return TGSI_FILE_CONSTANT;\r
+ case PROGRAM_CONSTANT:\r
+#if EMIT_IMMEDIATES\r
+ return TGSI_FILE_IMMEDIATE;\r
+#else\r
+ return TGSI_FILE_CONSTANT;\r
+#endif\r
case PROGRAM_INPUT:\r
return TGSI_FILE_INPUT;\r
case PROGRAM_OUTPUT:\r
GLuint file,\r
GLuint index,\r
const GLuint inputMapping[],\r
- const GLuint outputMapping[])\r
+ const GLuint outputMapping[],\r
+ const GLuint immediateMapping[])\r
{\r
switch( file ) {\r
case TGSI_FILE_INPUT:\r
case TGSI_FILE_OUTPUT:\r
return outputMapping[index];\r
\r
+#if EMIT_IMMEDIATES\r
+ case TGSI_FILE_IMMEDIATE:\r
+ return immediateMapping[index];\r
+#endif\r
+\r
default:\r
return index;\r
}\r
return writemask;\r
}\r
\r
+#if EMIT_IMMEDIATES\r
+static struct tgsi_full_immediate\r
+make_immediate(const float *value, uint size)\r
+{\r
+ struct tgsi_full_immediate imm;\r
+ imm.Immediate.Type = TGSI_TOKEN_TYPE_IMMEDIATE;\r
+ imm.Immediate.Size = size;\r
+ imm.Immediate.DataType = TGSI_IMM_FLOAT32;\r
+ imm.u.ImmediateFloat32 = (struct tgsi_immediate_float32 *) value;\r
+ return imm;\r
+}\r
+#endif\r
+\r
static void\r
compile_instruction(\r
const struct prog_instruction *inst,\r
struct tgsi_full_instruction *fullinst,\r
const GLuint inputMapping[],\r
const GLuint outputMapping[],\r
+ const GLuint immediateMapping[],\r
GLuint preamble_size,\r
GLuint processor )\r
{\r
fulldst->DstRegister.File,\r
inst->DstReg.Index,\r
inputMapping,\r
- outputMapping\r
+ outputMapping,\r
+ NULL\r
);\r
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );\r
\r
fullsrc->SrcRegister.File,\r
inst->SrcReg[i].Index,\r
inputMapping,\r
- outputMapping );\r
+ outputMapping,\r
+ immediateMapping);\r
\r
for( j = 0; j < 4; j++ ) {\r
GLuint swz;\r
struct tgsi_processor *processor;\r
struct tgsi_full_instruction fullinst;\r
GLuint preamble_size = 0;\r
+ GLuint immediates[1000];\r
+#if EMIT_IMMEDIATES\r
+ GLuint numImmediates = 0;\r
+#endif\r
\r
assert(procType == TGSI_PROCESSOR_FRAGMENT ||\r
procType == TGSI_PROCESSOR_VERTEX);\r
}\r
}\r
\r
+ /* immediates/literals */\r
+#if EMIT_IMMEDIATES\r
+ for (i = 0; i < program->Parameters->NumParameters; i++) {\r
+ if (program->Parameters->Parameters[i].Type == PROGRAM_CONSTANT) {\r
+ struct tgsi_full_immediate fullimm\r
+ = make_immediate(program->Parameters->ParameterValues[i],\r
+ program->Parameters->Parameters[i].Size);\r
+ ti += tgsi_build_full_immediate(&fullimm,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti);\r
+ immediates[i] = numImmediates;\r
+ numImmediates++;\r
+ }\r
+ }\r
+#endif\r
+\r
for( i = 0; i < program->NumInstructions; i++ ) {\r
compile_instruction(\r
&program->Instructions[i],\r
&fullinst,\r
inputMapping,\r
outputMapping,\r
+ immediates,\r
preamble_size,\r
procType );\r
\r