glsl: fix indirect addressing of gl_TextureMatrix[] arrays

The code to emit an array of OpenGL state vars lacked the code
to handle the gl_TextureMatrix[] array.

Fixes fd.o bug 28967

NOTE: this is a candidate for the 7.8 branch.
This commit is contained in:
Brian Paul 2010-07-08 18:35:08 -06:00
parent 2168b87b51
commit 41f66915ab

View file

@ -399,7 +399,7 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
}
if (isMatrix) {
/* load all four columns of matrix */
/* load all four rows (or columns) of matrix */
GLint pos[4];
GLuint j;
for (j = 0; j < 4; j++) {
@ -489,9 +489,26 @@ emit_statevars(const char *name, int array_len,
tokens[0] = STATE_TEXGEN;
tokens[2] = STATE_TEXGEN_OBJECT_Q;
}
else if (strcmp(name, "gl_TextureMatrix") == 0) {
tokens[0] = STATE_TEXTURE_MATRIX;
tokens[4] = STATE_MATRIX_TRANSPOSE;
}
else if (strcmp(name, "gl_TextureMatrixInverse") == 0) {
tokens[0] = STATE_TEXTURE_MATRIX;
tokens[4] = STATE_MATRIX_INVTRANS;
}
else if (strcmp(name, "gl_TextureMatrixTranspose") == 0) {
tokens[0] = STATE_TEXTURE_MATRIX;
tokens[4] = 0;
}
else if (strcmp(name, "gl_TextureMatrixInverseTranspose") == 0) {
tokens[0] = STATE_TEXTURE_MATRIX;
tokens[4] = STATE_MATRIX_INVERSE;
}
else {
return -1; /* invalid array name */
}
/* emit state vars for each array element */
for (i = 0; i < array_len; i++) {
GLint p;
tokens[1] = i;
@ -513,6 +530,19 @@ emit_statevars(const char *name, int array_len,
}
return pos;
}
else if (type->type == SLANG_SPEC_MAT4) {
/* unroll/emit 4 array rows (or columns) */
slang_type_specifier vec4;
GLint i, p, pos = -1;
vec4.type = SLANG_SPEC_VEC4;
for (i = 0; i < 4; i++) {
tokens[2] = tokens[3] = i; /* row[i] (or column[i]) of matrix */
p = emit_statevars(NULL, 0, &vec4, tokens, paramList);
if (pos == -1)
pos = p;
}
return pos;
}
else {
GLint pos;
assert(type->type == SLANG_SPEC_VEC4 ||