Mesa (7.11): glsl: Fix gl_NormalMatrix swizzle setup to match i965' s invariants.

Ian Romanick idr at kemper.freedesktop.org
Thu Nov 10 19:45:42 UTC 2011


Module: Mesa
Branch: 7.11
Commit: 172de77b123ccb73716d279ecd529bbd35151b2c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=172de77b123ccb73716d279ecd529bbd35151b2c

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Oct 18 17:17:28 2011 -0700

glsl: Fix gl_NormalMatrix swizzle setup to match i965's invariants.

A driver trying to set up builtin uniforms is faced with a problem:
How do I walk the ir_variable structure (representing an array of
structs, or array of matrices, or struct, or whatever), and set up
driver structures so that dereference of that uniform gets the
corresponding ParameterValues[] entry.  The rule in general is that
each corresponding vector-sized field of an array of structs is one
builtin uniform state slot.  i965 relied on another invariant: each
state slot has a number of unique channel swizzles corresponding to
the number of elements in the field's vector, to avoid needing to walk
the glsl_type in parallel to get at vector_elements.

All of the builtin uniforms followed this behavior, except for
gl_NormalMatrix.  That's a mat3 (so 3 vec3s), but it was swizzled as 3
vec4s.

Fixes piglit glsl-fs-normalmatrix.
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
(cherry picked from commit cc4ddc3a1e4bbe5fccd03b39b3590368be8c172f)

---

 src/glsl/ir_variable.cpp |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index b848769..6a8ea59 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -224,11 +224,11 @@ MATRIX(gl_TextureMatrixInverseTranspose,
 
 static struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = {
    { NULL, { STATE_MODELVIEW_MATRIX, 0, 0, 0, STATE_MATRIX_INVERSE},
-     SWIZZLE_XYZW },
+     MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) },
    { NULL, { STATE_MODELVIEW_MATRIX, 0, 1, 1, STATE_MATRIX_INVERSE},
-     SWIZZLE_XYZW },
+     MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) },
    { NULL, { STATE_MODELVIEW_MATRIX, 0, 2, 2, STATE_MATRIX_INVERSE},
-     SWIZZLE_XYZW },
+     MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) },
 };
 
 #undef MATRIX




More information about the mesa-commit mailing list