Mesa (master): i965: Set swizzle fields in the VS precompile program key.

Kenneth Graunke kwg at kemper.freedesktop.org
Mon Aug 27 21:24:59 UTC 2012


Module: Mesa
Branch: master
Commit: 88b3850c272636e0385f2111b4bc56724febb45b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=88b3850c272636e0385f2111b4bc56724febb45b

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sun Aug 26 11:45:49 2012 -0700

i965: Set swizzle fields in the VS precompile program key.

This fixes a regression since 76d1301e8e8e50dc962601a9977bc52148798349:
I began setting SWIZZLE_XYZW for unused sampler units in the actual
program keys, since this matched the FS precompile behavior.  However,
the VS precompile was expecting zero, so that commit made essentially
every vertex shader (even those not using texturing) mismatch and need
to be recompiled.

Setting them in the VS precompile key solves the issue.  It also is an
improvement over our old behavior: previously we guessed that vertex
shaders didn't use any textures at all.  Now we actually look to see if
the VS had any sampler uniforms and guess based on that.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/drivers/dri/i965/brw_vs.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 2120437..710ffe8 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -475,6 +475,17 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
    key.program_string_id = bvp->id;
    key.clamp_vertex_color = true;
 
+   for (int i = 0; i < MAX_SAMPLERS; i++) {
+      if (vp->Base.ShadowSamplers & (1 << i)) {
+         /* Assume DEPTH_TEXTURE_MODE is the default: X, X, X, 1 */
+         key.tex.swizzles[i] =
+            MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_ONE);
+      } else {
+         /* Color sampler: assume no swizzling. */
+         key.tex.swizzles[i] = SWIZZLE_XYZW;
+      }
+   }
+
    success = do_vs_prog(brw, prog, bvp, &key);
 
    brw->vs.prog_offset = old_prog_offset;




More information about the mesa-commit mailing list