From a7fa00dfc5ab5782b2e497fbf4ca292dde69cdbd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 2 Oct 2010 23:27:31 -0700 Subject: [PATCH] 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 --- src/mesa/drivers/dri/i965/brw_wm.c | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 9ca8e709f55..66106408c9e 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; -- 2.30.2