From 41f66915ab3d052e0e2ef06000d6534eb7776ec6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 8 Jul 2010 18:35:08 -0600 Subject: 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. --- src/mesa/slang/slang_builtin.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/slang/slang_builtin.c b/src/mesa/slang/slang_builtin.c index bb6fd662cc..e3ac7d38e2 100644 --- a/src/mesa/slang/slang_builtin.c +++ b/src/mesa/slang/slang_builtin.c @@ -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 || -- cgit v1.2.3