summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-11-17 17:01:58 -0800
committerEric Anholt <[email protected]>2011-11-29 16:44:51 -0800
commitd2235b0f4681f75d562131d655a6d7b7033d2d8b (patch)
tree6fba9ad009aaffb6c131d7ef2a238bc417b12067
parentf98bfb5d68423a4e57f78091c70288c0b558b8bd (diff)
i965: Always handle GL_DEPTH_TEXTURE_MODE through the shader.
We were already doing it through the shader (layered underneath GL_EXT_texture_swizzle) in the shadow compare case. This avoids having per-format logic for switching out the surface format dependent on the depth mode. v2: Also do the swizzling for DEPTH_STENCIL. oops. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c39
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c23
2 files changed, 30 insertions, 32 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 377b8ba2231..207ffd6c639 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -420,25 +420,40 @@ static void brw_wm_populate_key( struct brw_context *brw,
SWIZZLE_NIL
};
- /* 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 (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
- key->compare_funcs[i] = sampler->CompareFunc;
-
- if (sampler->DepthMode == GL_ALPHA) {
+ if (img->_BaseFormat == GL_DEPTH_COMPONENT ||
+ img->_BaseFormat == GL_DEPTH_STENCIL) {
+ if (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB)
+ key->compare_funcs[i] = sampler->CompareFunc;
+
+ /* We handle GL_DEPTH_TEXTURE_MODE here instead of as surface format
+ * overrides because shadow comparison always returns the result of
+ * the comparison in all channels anyway.
+ */
+ switch (sampler->DepthMode) {
+ case GL_ALPHA:
swizzles[0] = SWIZZLE_ZERO;
swizzles[1] = SWIZZLE_ZERO;
swizzles[2] = SWIZZLE_ZERO;
- } else if (sampler->DepthMode == GL_LUMINANCE) {
+ swizzles[3] = SWIZZLE_X;
+ break;
+ case GL_LUMINANCE:
+ swizzles[0] = SWIZZLE_X;
+ swizzles[1] = SWIZZLE_X;
+ swizzles[2] = SWIZZLE_X;
swizzles[3] = SWIZZLE_ONE;
- } else if (sampler->DepthMode == GL_RED) {
- /* See table 3.23 of the GL 3.0 spec. */
+ break;
+ case GL_INTENSITY:
+ swizzles[0] = SWIZZLE_X;
+ swizzles[1] = SWIZZLE_X;
+ swizzles[2] = SWIZZLE_X;
+ swizzles[3] = SWIZZLE_X;
+ break;
+ case GL_RED:
+ swizzles[0] = SWIZZLE_X;
swizzles[1] = SWIZZLE_ZERO;
swizzles[2] = SWIZZLE_ZERO;
swizzles[3] = SWIZZLE_ONE;
+ break;
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 5a6896e63b4..0f6abe2e54e 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -568,29 +568,12 @@ translate_tex_format(gl_format mesa_format,
switch( mesa_format ) {
case MESA_FORMAT_Z16:
- if (depth_mode == GL_INTENSITY)
- return BRW_SURFACEFORMAT_I16_UNORM;
- else if (depth_mode == GL_ALPHA)
- return BRW_SURFACEFORMAT_A16_UNORM;
- else if (depth_mode == GL_RED)
- return BRW_SURFACEFORMAT_R16_UNORM;
- else
- return BRW_SURFACEFORMAT_L16_UNORM;
+ return BRW_SURFACEFORMAT_I16_UNORM;
case MESA_FORMAT_S8_Z24:
case MESA_FORMAT_X8_Z24:
- /* XXX: these different surface formats don't seem to
- * make any difference for shadow sampler/compares.
- */
- if (depth_mode == GL_INTENSITY)
- return BRW_SURFACEFORMAT_I24X8_UNORM;
- else if (depth_mode == GL_ALPHA)
- return BRW_SURFACEFORMAT_A24X8_UNORM;
- else if (depth_mode == GL_RED)
- return BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS;
- else
- return BRW_SURFACEFORMAT_L24X8_UNORM;
-
+ return BRW_SURFACEFORMAT_I24X8_UNORM;
+
case MESA_FORMAT_SARGB8:
case MESA_FORMAT_SLA8:
case MESA_FORMAT_SL8: