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;
}
}
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: