summaryrefslogtreecommitdiff
path: root/src/mesa/shader/arbprogparse.c
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 /src/mesa/shader/arbprogparse.c
parent866a2c3ccb6b62966ce1da796498a62e276570d1 (diff)
mesa: Fix arb parse constants
Diffstat (limited to 'src/mesa/shader/arbprogparse.c')
-rw-r--r--src/mesa/shader/arbprogparse.c37
1 files changed, 36 insertions, 1 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)