Mesa (7.9): i965: Set up swizzling of shadow compare results for GL_DEPTH_TEXTURE_MODE.

Ian Romanick idr at kemper.freedesktop.org
Tue Oct 5 00:49:46 UTC 2010


Module: Mesa
Branch: 7.9
Commit: 9b646b1fd37f534efb72d463a6a6ca0e092bce8a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b646b1fd37f534efb72d463a6a6ca0e092bce8a

Author: Eric Anholt <eric at anholt.net>
Date:   Sat Oct  2 23:27:31 2010 -0700

i965: Set up swizzling of shadow compare results for GL_DEPTH_TEXTURE_MODE.

The brw_wm_surface_state.c handling of GL_DEPTH_TEXTURE_MODE doesn't
apply to shadow compares, which always return an intensity value.  The
texture swizzles can do the job for us.

Fixes:
glsl1-shadow2D(): 1
glsl1-shadow2D(): 3
(cherry picked from commit a7fa00dfc5ab5782b2e497fbf4ca292dde69cdbd)

---

 src/mesa/drivers/dri/i965/brw_wm.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 9ca8e70..6610640 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -342,13 +342,44 @@ static void brw_wm_populate_key( struct brw_context *brw,
       if (unit->_ReallyEnabled) {
          const struct gl_texture_object *t = unit->_Current;
          const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
+
+	 key->tex_swizzles[i] = SWIZZLE_NOOP;
+
+	 /* GL_DEPTH_TEXTURE_MODE is normally handled through
+	  * brw_wm_surface_state, but it applies to shadow compares as
+	  * well and our shadow compares always return the result in
+	  * all 4 channels.
+	  */
+	 if (t->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+	    if (t->DepthMode == GL_ALPHA) {
+	       key->tex_swizzles[i] =
+		  MAKE_SWIZZLE4(SWIZZLE_ZERO,
+				SWIZZLE_ZERO,
+				SWIZZLE_ZERO,
+				SWIZZLE_X);
+	    } else if (t->DepthMode == GL_LUMINANCE) {
+	       key->tex_swizzles[i] =
+		  MAKE_SWIZZLE4(SWIZZLE_X,
+				SWIZZLE_X,
+				SWIZZLE_X,
+				SWIZZLE_ONE);
+	    }
+	 }
+
 	 if (img->InternalFormat == GL_YCBCR_MESA) {
 	    key->yuvtex_mask |= 1 << i;
 	    if (img->TexFormat == MESA_FORMAT_YCBCR)
 		key->yuvtex_swap_mask |= 1 << i;
 	 }
 
-         key->tex_swizzles[i] = t->_Swizzle;
+	 key->tex_swizzles[i] = MAKE_SWIZZLE4(GET_SWZ(key->tex_swizzles[i],
+						      GET_SWZ(t->_Swizzle, 0)),
+					      GET_SWZ(key->tex_swizzles[i],
+						      GET_SWZ(t->_Swizzle, 1)),
+					      GET_SWZ(key->tex_swizzles[i],
+						      GET_SWZ(t->_Swizzle, 2)),
+					      GET_SWZ(key->tex_swizzles[i],
+						      GET_SWZ(t->_Swizzle, 3)));
       }
       else {
          key->tex_swizzles[i] = SWIZZLE_NOOP;




More information about the mesa-commit mailing list