summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-09-19 13:04:52 +0200
committerJakob Bornecrantz <jakob@tungstengraphics.com>2008-09-19 13:04:52 +0200
commit0576e837f18ad9925d732f883f4922c907d7bafb (patch)
treeec242db18a1aba5833cb7fd531a83c26aecc28eb
parent866a2c3ccb6b62966ce1da796498a62e276570d1 (diff)
mesa: Fix arb parse constants
-rw-r--r--src/mesa/shader/arbprogparse.c37
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c10
2 files changed, 38 insertions, 9 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 26ccdc7395..5e81477592 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -30,6 +30,27 @@
* \author Karl Rasche
*/
+/**
+Notes on program parameters, etc.
+
+The instructions we emit will use six kinds of source registers:
+
+ PROGRAM_INPUT - input registers
+ PROGRAM_TEMPORARY - temp registers
+ PROGRAM_ADDRESS - address/indirect register
+ PROGRAM_SAMPLER - texture sampler
+ PROGRAM_CONSTANT - indexes into program->Parameters, a known constant/literal
+ PROGRAM_STATE_VAR - indexes into program->Parameters, and may actually be:
+ + a state variable, like "state.fog.color", or
+ + a pointer to a "program.local[k]" parameter, or
+ + a pointer to a "program.env[k]" parameter
+
+Basically, all the program.local[] and program.env[] values will get mapped
+into the unified gl_program->Parameters array. This solves the problem of
+having three separate program parameter arrays.
+*/
+
+
#include "main/glheader.h"
#include "main/imports.h"
#include "shader/grammar/grammar_mesa.h"
@@ -1871,7 +1892,11 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst,
const_values, 4);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
- param_var->param_binding_type = PROGRAM_CONSTANT;
+ param_var->param_binding_type = PROGRAM_STATE_VAR;
+ /* Note: when we reference this parameter in an instruction later,
+ * we'll check if it's really a constant/immediate and set the
+ * instruction register type appropriately.
+ */
param_var->param_binding_length++;
Program->Base.NumParameters++;
break;
@@ -2578,6 +2603,16 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
return 1;
}
+ if (*File == PROGRAM_STATE_VAR) {
+ /* If we're referencing the Program->Parameters[] array, check if the
+ * parameter is really a constant/literal. If so, set File to CONSTANT.
+ */
+ assert(*Index < Program->Base.Parameters->NumParameters);
+ enum register_file file = Program->Base.Parameters->Parameters[*Index].Type;
+ if (file == PROGRAM_CONSTANT)
+ *File = PROGRAM_CONSTANT;
+ }
+
/* Add attributes to InputsRead only if they are used the program.
* This avoids the handling of unused ATTRIB declarations in the drivers. */
if (*File == PROGRAM_INPUT)
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index b9807bb807..524d8890b5 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -77,6 +77,7 @@ map_register_file(
case PROGRAM_CONSTANT:
if (indirectAccess)
return TGSI_FILE_CONSTANT;
+ assert(immediateMapping[index] != ~0);
return TGSI_FILE_IMMEDIATE;
case PROGRAM_INPUT:
return TGSI_FILE_INPUT;
@@ -118,6 +119,7 @@ map_register_file_index(
case TGSI_FILE_IMMEDIATE:
if (indirectAccess)
return index;
+ assert(immediateMapping[index] != ~0);
return immediateMapping[index];
default:
@@ -242,14 +244,6 @@ compile_instruction(
immediateMapping,
indirectAccess );
- /**
- * This not at all the correct solution.
- * FIXME: Roll this up in the above map functions
- */
- if (fullsrc->SrcRegister.File == TGSI_FILE_IMMEDIATE && fullsrc->SrcRegister.Index == ~0) {
- fullsrc->SrcRegister.File = TGSI_FILE_CONSTANT;
- fullsrc->SrcRegister.Index = inst->SrcReg[i].Index;
- }
/* swizzle (ext swizzle also depends on negation) */
{