summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-02-21 11:08:21 -0700
committerBrian <brian@yutani.localnet.net>2007-02-21 11:08:21 -0700
commit6531952b3c979be0dc95704beb3c3b9dad1dc37b (patch)
tree5cbba2be731d30eac5375513dbe374f51571782d /src
parentc3301d038d404be7c8ecda9d1425617e650e6198 (diff)
adjustments to STATE_ token layout/format so token[1] is always the array index
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/arbprogparse.c47
-rw-r--r--src/mesa/shader/prog_statevars.c129
-rw-r--r--src/mesa/shader/prog_statevars.h15
-rw-r--r--src/mesa/shader/programopt.c14
-rw-r--r--src/mesa/shader/slang/slang_builtin.c54
-rw-r--r--src/mesa/shader/slang/slang_emit.c3
-rw-r--r--src/mesa/tnl/t_vp_build.c30
7 files changed, 166 insertions, 126 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index e240d88aaae..4c200f74cc9 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -1010,7 +1010,7 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra
switch (mat) {
case MATRIX_MODELVIEW:
- *matrix = STATE_MODELVIEW;
+ *matrix = STATE_MODELVIEW_MATRIX;
*matrix_idx = parse_integer (inst, Program);
if (*matrix_idx > 0) {
program_error(ctx, Program->Position,
@@ -1020,15 +1020,15 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra
break;
case MATRIX_PROJECTION:
- *matrix = STATE_PROJECTION;
+ *matrix = STATE_PROJECTION_MATRIX;
break;
case MATRIX_MVP:
- *matrix = STATE_MVP;
+ *matrix = STATE_MVP_MATRIX;
break;
case MATRIX_TEXTURE:
- *matrix = STATE_TEXTURE;
+ *matrix = STATE_TEXTURE_MATRIX;
*matrix_idx = parse_integer (inst, Program);
if (*matrix_idx >= (GLint) ctx->Const.MaxTextureUnits) {
program_error(ctx, Program->Position, "Invalid Texture Unit");
@@ -1046,7 +1046,7 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra
break;
case MATRIX_PROGRAM:
- *matrix = STATE_PROGRAM;
+ *matrix = STATE_PROGRAM_MATRIX;
*matrix_idx = parse_integer (inst, Program);
if (*matrix_idx >= (GLint) ctx->Const.MaxProgramMatrices) {
program_error(ctx, Program->Position, "Invalid Program Matrix");
@@ -1187,10 +1187,12 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
case STATE_FOG:
switch (*(*inst)++) {
case FOG_COLOR:
- state_tokens[0] = STATE_FOG_COLOR;
+ state_tokens[0] = STATE_FOG;
+ state_tokens[1] = STATE_FOG_COLOR;
break;
case FOG_PARAMS:
- state_tokens[0] = STATE_FOG_PARAMS;
+ state_tokens[0] = STATE_FOG;
+ state_tokens[1] = STATE_FOG_PARAMS;
break;
}
break;
@@ -1285,17 +1287,16 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
/* XXX: I think this is the correct format for a matrix row */
case STATE_MATRIX_ROWS:
- state_tokens[0] = STATE_MATRIX;
if (parse_matrix
- (ctx, inst, Program, &state_tokens[1], &state_tokens[2],
- &state_tokens[5]))
+ (ctx, inst, Program, &state_tokens[0], &state_tokens[1],
+ &state_tokens[4]))
return 1;
- state_tokens[3] = parse_integer (inst, Program); /* The first row to grab */
+ state_tokens[2] = parse_integer (inst, Program); /* The first row to grab */
if ((**inst) != 0) { /* Either the last row, 0 */
- state_tokens[4] = parse_integer (inst, Program);
- if (state_tokens[4] < state_tokens[3]) {
+ state_tokens[3] = parse_integer (inst, Program);
+ if (state_tokens[3] < state_tokens[2]) {
program_error(ctx, Program->Position,
"Second matrix index less than the first");
/* state_tokens[4] vs. state_tokens[3] */
@@ -1303,7 +1304,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
}
}
else {
- state_tokens[4] = state_tokens[3];
+ state_tokens[3] = state_tokens[2];
(*inst)++;
}
break;
@@ -1730,14 +1731,18 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst,
/* If we adding STATE_MATRIX that has multiple rows, we need to
* unroll it and call _mesa_add_state_reference() for each row
*/
- if ((state_tokens[0] == STATE_MATRIX)
- && (state_tokens[3] != state_tokens[4])) {
+ if ((state_tokens[0] == STATE_MODELVIEW_MATRIX ||
+ state_tokens[0] == STATE_PROJECTION_MATRIX ||
+ state_tokens[0] == STATE_MVP_MATRIX ||
+ state_tokens[0] == STATE_TEXTURE_MATRIX ||
+ state_tokens[0] == STATE_PROGRAM_MATRIX)
+ && (state_tokens[2] != state_tokens[3])) {
GLint row;
- GLint first_row = state_tokens[3];
- GLint last_row = state_tokens[4];
+ const GLint first_row = state_tokens[2];
+ const GLint last_row = state_tokens[3];
for (row = first_row; row <= last_row; row++) {
- state_tokens[3] = state_tokens[4] = row;
+ state_tokens[2] = state_tokens[3] = row;
idx = _mesa_add_state_reference(Program->Base.Parameters,
state_tokens);
@@ -3357,6 +3362,10 @@ print_state_token (GLint token)
fprintf (stderr, "STATE_TEXGEN ");
break;
+ case STATE_FOG:
+ fprintf (stderr, "STATE_FOG ");
+ break;
+
case STATE_FOG_COLOR:
fprintf (stderr, "STATE_FOG_COLOR ");
break;
diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c
index 3a54ab8c58e..d6c552a71ff 100644
--- a/src/mesa/shader/prog_statevars.c
+++ b/src/mesa/shader/prog_statevars.c
@@ -243,14 +243,17 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
}
return;
- case STATE_FOG_COLOR:
- COPY_4V(value, ctx->Fog.Color);
- return;
- case STATE_FOG_PARAMS:
- value[0] = ctx->Fog.Density;
- value[1] = ctx->Fog.Start;
- value[2] = ctx->Fog.End;
- value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ case STATE_FOG:
+ if (state[1] == STATE_FOG_COLOR) {
+ COPY_4V(value, ctx->Fog.Color);
+ }
+ else {
+ ASSERT(state[1] == STATE_FOG_PARAMS);
+ value[0] = ctx->Fog.Density;
+ value[1] = ctx->Fog.Start;
+ value[2] = ctx->Fog.End;
+ value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ }
return;
case STATE_CLIPPLANE:
{
@@ -270,7 +273,12 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
value[2] = ctx->Point.Params[2];
value[3] = 1.0F;
return;
- case STATE_MATRIX:
+ case STATE_MODELVIEW_MATRIX:
+ case STATE_PROJECTION_MATRIX:
+ case STATE_MVP_MATRIX:
+ case STATE_TEXTURE_MATRIX:
+ case STATE_PROGRAM_MATRIX:
+ /*case STATE_MATRIX:*/
{
/* state[1] = modelview, projection, texture, etc. */
/* state[2] = which texture matrix or program matrix */
@@ -279,26 +287,38 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
/* state[5] = transpose, inverse or invtrans */
const GLmatrix *matrix;
+#if 0
const gl_state_index mat = state[1];
const GLuint index = (GLuint) state[2];
const GLuint firstRow = (GLuint) state[3];
const GLuint lastRow = (GLuint) state[4];
const gl_state_index modifier = state[5];
+#else
+ const gl_state_index mat = state[0];
+ const GLuint index = (GLuint) state[1];
+ const GLuint firstRow = (GLuint) state[2];
+ const GLuint lastRow = (GLuint) state[3];
+ const gl_state_index modifier = state[4];
+#endif
const GLfloat *m;
GLuint row, i;
- if (mat == STATE_MODELVIEW) {
+ ASSERT(firstRow >= 0);
+ ASSERT(firstRow < 4);
+ ASSERT(lastRow >= 0);
+ ASSERT(lastRow < 4);
+ if (mat == STATE_MODELVIEW_MATRIX) {
matrix = ctx->ModelviewMatrixStack.Top;
}
- else if (mat == STATE_PROJECTION) {
+ else if (mat == STATE_PROJECTION_MATRIX) {
matrix = ctx->ProjectionMatrixStack.Top;
}
- else if (mat == STATE_MVP) {
+ else if (mat == STATE_MVP_MATRIX) {
matrix = &ctx->_ModelProjectMatrix;
}
- else if (mat == STATE_TEXTURE) {
+ else if (mat == STATE_TEXTURE_MATRIX) {
matrix = ctx->TextureMatrixStack[index].Top;
}
- else if (mat == STATE_PROGRAM) {
+ else if (mat == STATE_PROGRAM_MATRIX) {
matrix = ctx->ProgramMatrixStack[index].Top;
}
else {
@@ -432,8 +452,11 @@ _mesa_program_state_flags(const GLint state[STATE_LENGTH])
case STATE_TEXENV_COLOR:
return _NEW_TEXTURE;
+ case STATE_FOG:
+#if 0
case STATE_FOG_COLOR:
case STATE_FOG_PARAMS:
+#endif
return _NEW_FOG;
case STATE_CLIPPLANE:
@@ -443,23 +466,16 @@ _mesa_program_state_flags(const GLint state[STATE_LENGTH])
case STATE_POINT_ATTENUATION:
return _NEW_POINT;
- case STATE_MATRIX:
- switch (state[1]) {
- case STATE_MODELVIEW:
- return _NEW_MODELVIEW;
- case STATE_PROJECTION:
- return _NEW_PROJECTION;
- case STATE_MVP:
- return _NEW_MODELVIEW | _NEW_PROJECTION;
- case STATE_TEXTURE:
- return _NEW_TEXTURE_MATRIX;
- case STATE_PROGRAM:
- return _NEW_TRACK_MATRIX;
- default:
- _mesa_problem(NULL,
- "unexpected matrix in _mesa_program_state_flags()");
- return 0;
- }
+ case STATE_MODELVIEW_MATRIX:
+ return _NEW_MODELVIEW;
+ case STATE_PROJECTION_MATRIX:
+ return _NEW_PROJECTION;
+ case STATE_MVP_MATRIX:
+ return _NEW_MODELVIEW | _NEW_PROJECTION;
+ case STATE_TEXTURE_MATRIX:
+ return _NEW_TEXTURE_MATRIX;
+ case STATE_PROGRAM_MATRIX:
+ return _NEW_TRACK_MATRIX;
case STATE_DEPTH_RANGE:
return _NEW_VIEWPORT;
@@ -520,11 +536,14 @@ append_token(char *dst, gl_state_index k)
case STATE_TEXGEN:
append(dst, "texgen");
break;
+ case STATE_FOG:
+ append(dst, "fog");
+ break;
case STATE_FOG_COLOR:
- append(dst, "fog.color");
+ append(dst, ".color");
break;
case STATE_FOG_PARAMS:
- append(dst, "fog.params");
+ append(dst, ".params");
break;
case STATE_CLIPPLANE:
append(dst, "clip");
@@ -535,22 +554,19 @@ append_token(char *dst, gl_state_index k)
case STATE_POINT_ATTENUATION:
append(dst, "point.attenuation");
break;
- case STATE_MATRIX:
- append(dst, "matrix.");
- break;
- case STATE_MODELVIEW:
+ case STATE_MODELVIEW_MATRIX:
append(dst, "modelview");
break;
- case STATE_PROJECTION:
+ case STATE_PROJECTION_MATRIX:
append(dst, "projection");
break;
- case STATE_MVP:
+ case STATE_MVP_MATRIX:
append(dst, "mvp");
break;
- case STATE_TEXTURE:
+ case STATE_TEXTURE_MATRIX:
append(dst, "texture");
break;
- case STATE_PROGRAM:
+ case STATE_PROGRAM_MATRIX:
append(dst, "program");
break;
case STATE_MATRIX_INVERSE:
@@ -703,8 +719,9 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH])
append_index(str, state[1]); /* tex unit [i] */
append(str, "color");
break;
- case STATE_FOG_COLOR:
- case STATE_FOG_PARAMS:
+ case STATE_FOG:
+ append(str, "fog");
+ append_token(str, (gl_state_index) state[1]); /* color or params */
break;
case STATE_CLIPPLANE:
append_index(str, state[1]); /* plane [i] */
@@ -713,18 +730,22 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH])
case STATE_POINT_SIZE:
case STATE_POINT_ATTENUATION:
break;
- case STATE_MATRIX:
+ case STATE_MODELVIEW_MATRIX:
+ case STATE_PROJECTION_MATRIX:
+ case STATE_MVP_MATRIX:
+ case STATE_TEXTURE_MATRIX:
+ case STATE_PROGRAM_MATRIX:
{
- /* state[1] = modelview, projection, texture, etc. */
- /* state[2] = which texture matrix or program matrix */
- /* state[3] = first row to fetch */
- /* state[4] = last row to fetch */
- /* state[5] = transpose, inverse or invtrans */
- const gl_state_index mat = (gl_state_index) state[1];
- const GLuint index = (GLuint) state[2];
- const GLuint firstRow = (GLuint) state[3];
- const GLuint lastRow = (GLuint) state[4];
- const gl_state_index modifier = (gl_state_index) state[5];
+ /* state[0] = modelview, projection, texture, etc. */
+ /* state[1] = which texture matrix or program matrix */
+ /* state[2] = first row to fetch */
+ /* state[3] = last row to fetch */
+ /* state[4] = transpose, inverse or invtrans */
+ const gl_state_index mat = (gl_state_index) state[0];
+ const GLuint index = (GLuint) state[1];
+ const GLuint firstRow = (GLuint) state[2];
+ const GLuint lastRow = (GLuint) state[3];
+ const gl_state_index modifier = (gl_state_index) state[4];
append_token(str, mat);
if (index)
append_index(str, index);
diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h
index 95e38ca7b6f..1b686d8078c 100644
--- a/src/mesa/shader/prog_statevars.h
+++ b/src/mesa/shader/prog_statevars.h
@@ -40,6 +40,9 @@
* fragment programs.
* A string such as "state.light[0].ambient" gets translated into a
* sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
+ *
+ * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should
+ * always be the array index.
*/
typedef enum gl_state_index_ {
STATE_MATERIAL = 100, /* start at 100 so small ints are seen as ints */
@@ -51,6 +54,7 @@ typedef enum gl_state_index_ {
STATE_TEXGEN,
+ STATE_FOG,
STATE_FOG_COLOR,
STATE_FOG_PARAMS,
@@ -59,12 +63,11 @@ typedef enum gl_state_index_ {
STATE_POINT_SIZE,
STATE_POINT_ATTENUATION,
- STATE_MATRIX,
- STATE_MODELVIEW,
- STATE_PROJECTION,
- STATE_MVP,
- STATE_TEXTURE,
- STATE_PROGRAM,
+ STATE_MODELVIEW_MATRIX,
+ STATE_PROJECTION_MATRIX,
+ STATE_MVP_MATRIX,
+ STATE_TEXTURE_MATRIX,
+ STATE_PROGRAM_MATRIX,
STATE_MATRIX_INVERSE,
STATE_MATRIX_TRANSPOSE,
STATE_MATRIX_INVTRANS,
diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c
index a33e6b49ac9..ca11a4e547c 100644
--- a/src/mesa/shader/programopt.c
+++ b/src/mesa/shader/programopt.c
@@ -57,10 +57,10 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog)
* XXX we should check if these state vars are already declared.
*/
static const GLint mvpState[4][5] = {
- { STATE_MATRIX, STATE_MVP, 0, 0, 0 }, /* state.matrix.mvp.row[0] */
- { STATE_MATRIX, STATE_MVP, 0, 1, 1 }, /* state.matrix.mvp.row[1] */
- { STATE_MATRIX, STATE_MVP, 0, 2, 2 }, /* state.matrix.mvp.row[2] */
- { STATE_MATRIX, STATE_MVP, 0, 3, 3 }, /* state.matrix.mvp.row[3] */
+ { STATE_MVP_MATRIX, 0, 0, 0, 0 }, /* state.matrix.mvp.row[0] */
+ { STATE_MVP_MATRIX, 0, 1, 1, 0 }, /* state.matrix.mvp.row[1] */
+ { STATE_MVP_MATRIX, 0, 2, 2, 0 }, /* state.matrix.mvp.row[2] */
+ { STATE_MVP_MATRIX, 0, 3, 3, 0 }, /* state.matrix.mvp.row[3] */
};
GLint mvpRef[4];
@@ -125,8 +125,10 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog)
void
_mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
{
- static const GLint fogParamsState[] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
- static const GLint fogColorState[] = { STATE_FOG_COLOR, 0, 0, 0, 0 };
+ static const GLint fogParamsState[]
+ = { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0 };
+ static const GLint fogColorState[]
+ = { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0 };
struct prog_instruction *newInst, *inst;
const GLuint origLen = fprog->Base.NumInstructions;
const GLuint newLen = origLen + 6;
diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c
index b4aecdb3ad6..71a102e45ce 100644
--- a/src/mesa/shader/slang/slang_builtin.c
+++ b/src/mesa/shader/slang/slang_builtin.c
@@ -70,15 +70,15 @@ _slang_lookup_statevar(const char *name, GLint index,
};
static const struct state_info state[] = {
{ "gl_ModelViewMatrix", 4, SWIZZLE_NOOP,
- { STATE_MATRIX, STATE_MODELVIEW, 0, 0, 0, 0 } },
+ { STATE_MODELVIEW_MATRIX, 0, 0, 0, 0, 0 } },
{ "gl_NormalMatrix", 3, SWIZZLE_NOOP,
- { STATE_MATRIX, STATE_MODELVIEW, 0, 0, 0, 0 } },
+ { STATE_MODELVIEW_MATRIX, 0, 0, 0, 0, 0 } },
{ "gl_ProjectionMatrix", 4, SWIZZLE_NOOP,
- { STATE_MATRIX, STATE_PROJECTION, 0, 0, 0, 0 } },
+ { STATE_PROJECTION_MATRIX, 0, 0, 0, 0, 0 } },
{ "gl_ModelViewProjectionMatrix", 4, SWIZZLE_NOOP,
- { STATE_MATRIX, STATE_MVP, 0, 0, 0, 0 } },
+ { STATE_MVP_MATRIX, 0, 0, 0, 0, 0 } },
{ "gl_TextureMatrix", 4, SWIZZLE_NOOP,
- { STATE_MATRIX, STATE_TEXTURE, 0, 0, 0, 0 } },
+ { STATE_TEXTURE_MATRIX, 0, 0, 0, 0, 0 } },
{ "gl_NormalScale", 1, SWIZZLE_NOOP,
{ STATE_INTERNAL, STATE_NORMAL_SCALE, 0, 0, 0, 0} },
@@ -157,17 +157,17 @@ _slang_lookup_statevar(const char *name, GLint index,
{ "gl_Fog", 1, SWIZZLE_NOOP,
- { STATE_FOG_COLOR, 0, 0, 0, 0, 0 } },
+ { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0, 0 } },
{ "gl_Fog.color", 1, SWIZZLE_NOOP,
- { STATE_FOG_COLOR, 0, 0, 0, 0, 0 } },
+ { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0, 0 } },
{ "gl_Fog.density", 1, SWIZZLE_XXXX,
- { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 } },
+ { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0, 0 } },
{ "gl_Fog.start", 1, SWIZZLE_YYYY,
- { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 } },
+ { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0, 0 } },
{ "gl_Fog.end", 1, SWIZZLE_ZZZZ,
- { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 } },
+ { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0, 0 } },
{ "gl_Fog.scale", 1, SWIZZLE_WWWW,
- { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 } },
+ { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0, 0 } },
{ "gl_ClipPlane", 1, SWIZZLE_NOOP,
{ STATE_CLIPPLANE, 0, 0, 0, 0, 0 } },
@@ -190,7 +190,7 @@ _slang_lookup_statevar(const char *name, GLint index,
indexesCopy[j] = state[i].Indexes[j];
/* load rows */
for (j = 0; j < state[i].NumRows; j++) {
- indexesCopy[3] = indexesCopy[4] = j; /* jth row of matrix */
+ indexesCopy[2] = indexesCopy[3] = j; /* jth row of matrix */
pos[j] = _mesa_add_state_reference(paramList, indexesCopy);
assert(pos[j] >= 0);
}
@@ -256,19 +256,19 @@ struct state_uniform_info {
static const struct state_uniform_info Uniforms[] = {
- { "gl_ModelViewMatrix", { STATE_MATRIX, STATE_MODELVIEW },
+ { "gl_ModelViewMatrix", { STATE_MODELVIEW_MATRIX, INDEX_POS },
{ MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD}
},
- { "gl_ProjectionMatrix", { STATE_MATRIX, STATE_PROJECTION },
+ { "gl_ProjectionMatrix", { STATE_PROJECTION_MATRIX, INDEX_POS },
{ MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD}
},
- { "gl_ModelViewProjectionMatrix", { STATE_MATRIX, STATE_MVP },
+ { "gl_ModelViewProjectionMatrix", { STATE_MVP_MATRIX, INDEX_POS },
{ MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD}
},
- { "gl_NormalMatrix", { STATE_MATRIX, STATE_MODELVIEW },
+ { "gl_NormalMatrix", { STATE_MODELVIEW_MATRIX, INDEX_POS },
{ MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD}
},
- { "gl_TextureMatrix", { STATE_MATRIX, STATE_TEXTURE },
+ { "gl_TextureMatrix", { STATE_TEXTURE_MATRIX, INDEX_POS },
{ MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD}
},
@@ -286,13 +286,13 @@ static const struct state_uniform_info Uniforms[] = {
}
},
- { "gl_Fog", { 0, 0 },
+ { "gl_Fog", { STATE_FOG, 0 },
{
- { "color", STATE_FOG_COLOR, 0, SWIZZLE_NOOP },
- { "density", STATE_FOG_PARAMS, 0, SWIZZLE_XXXX },
- { "start", STATE_FOG_PARAMS, 0, SWIZZLE_YYYY },
- { "end", STATE_FOG_PARAMS, 0, SWIZZLE_ZZZZ },
- { "scale", STATE_FOG_PARAMS, 0, SWIZZLE_WWWW }
+ { "color", STATE_FOG_COLOR, 1, SWIZZLE_NOOP },
+ { "density", STATE_FOG_PARAMS, 1, SWIZZLE_XXXX },
+ { "start", STATE_FOG_PARAMS, 1, SWIZZLE_YYYY },
+ { "end", STATE_FOG_PARAMS, 1, SWIZZLE_ZZZZ },
+ { "scale", STATE_FOG_PARAMS, 1, SWIZZLE_WWWW }
}
},
@@ -349,7 +349,11 @@ lookup_statevar(const char *var, GLint index, const char *field,
}
}
- if (tokens[0] == STATE_MATRIX) {
+ if (tokens[0] == STATE_MODELVIEW_MATRIX ||
+ tokens[0] == STATE_PROJECTION_MATRIX ||
+ tokens[0] == STATE_MVP_MATRIX ||
+ tokens[0] == STATE_TEXTURE_MATRIX ||
+ tokens[0] == STATE_PROGRAM_MATRIX) {
/* a matrix */
GLuint j;
GLint pos[4];
@@ -359,7 +363,7 @@ lookup_statevar(const char *var, GLint index, const char *field,
indexesCopy[j] = tokens[j];
/* load rows */
for (j = 0; j < 4/*state[i].NumRows*/; j++) {
- indexesCopy[3] = indexesCopy[4] = j; /* jth row of matrix */
+ indexesCopy[2] = indexesCopy[3] = j; /* jth row of matrix */
pos[j] = _mesa_add_state_reference(paramList, (GLint*) indexesCopy);
assert(pos[j] >= 0);
}
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 7584857493b..cef6299d62d 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -1354,7 +1354,7 @@ emit_struct_field(slang_var_table *vt, slang_ir_node *n,
n->Store->Index = _slang_alloc_statevar(n, prog->Parameters);
return NULL;
}
-
+#if 0
if (n->Children[0]->Store->File == PROGRAM_STATE_VAR) {
/* state variable sub-field */
GLint pos;
@@ -1371,6 +1371,7 @@ emit_struct_field(slang_var_table *vt, slang_ir_node *n,
n->Store->Index = pos;
n->Store->Swizzle = swizzle;
}
+#endif
else {
_mesa_problem(NULL, "structs/fields not supported yet");
}
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
index 47fed32904d..9065e3421fe 100644
--- a/src/mesa/tnl/t_vp_build.c
+++ b/src/mesa/tnl/t_vp_build.c
@@ -636,14 +636,14 @@ static struct ureg get_eye_position( struct tnl_program *p )
p->eye_position = reserve_temp(p);
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
- STATE_MATRIX, modelview );
+ register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3,
+ 0, 0, modelview );
emit_matrix_transform_vec4(p, p->eye_position, modelview, pos);
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
- STATE_MATRIX_TRANSPOSE, modelview );
+ register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3,
+ STATE_MATRIX_TRANSPOSE, 0, modelview );
emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos);
}
@@ -671,8 +671,8 @@ static struct ureg get_eye_normal( struct tnl_program *p )
struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL );
struct ureg mvinv[3];
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 2,
- STATE_MATRIX_INVTRANS, mvinv );
+ register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 2,
+ STATE_MATRIX_INVTRANS, 0, mvinv );
p->eye_normal = reserve_temp(p);
@@ -706,13 +706,13 @@ static void build_hpos( struct tnl_program *p )
struct ureg mvp[4];
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
- STATE_MATRIX, mvp );
+ register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3,
+ 0, 0, mvp );
emit_matrix_transform_vec4( p, hpos, mvp, pos );
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
- STATE_MATRIX_TRANSPOSE, mvp );
+ register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3,
+ STATE_MATRIX_TRANSPOSE, 0, mvp );
emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos );
}
}
@@ -1109,7 +1109,7 @@ static void build_fog( struct tnl_program *p )
}
if (p->state->tnl_do_vertex_fog) {
- struct ureg params = register_param1(p, STATE_FOG_PARAMS);
+ struct ureg params = register_param2(p, STATE_FOG, STATE_FOG_PARAMS);
struct ureg tmp = get_temp(p);
switch (p->state->fog_mode) {
@@ -1303,13 +1303,13 @@ static void build_texture_transform( struct tnl_program *p )
out_texgen :
register_input(p, VERT_ATTRIB_TEX0+i));
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
- 0, 3, STATE_MATRIX, texmat );
+ register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3,
+ 0, 0, texmat );
emit_matrix_transform_vec4( p, out, texmat, in );
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
- 0, 3, STATE_MATRIX_TRANSPOSE, texmat );
+ register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3,
+ STATE_MATRIX_TRANSPOSE, 0, texmat );
emit_transpose_matrix_transform_vec4( p, out, texmat, in );
}
}