[Mesa-dev] [PATCH 07/17] i965: Add support for texture swizzling of integer L/A/I/LA formats.

Eric Anholt eric at anholt.net
Fri Jan 20 15:39:19 PST 2012


Right now we claim to not support these MESA_FORMATs, so the texture
gets promoted to RGBA integer.  This almost works, except that there's
nothing in Mesa to make sure that the channels get replaced with
appropriate values when read by ReadPixels or texturing.  So, the
driver really needs to provide support for these formats, even if we
have to do so using R/RG formats and swizzling.

This is the first step, getting texturing to work so that if the
formats are added to the table,
EXT_texture_integer/texture_integer_glsl130 keeps working.

NOTE: This is a candidate for the 8.0 branch.
---
 src/mesa/drivers/dri/i965/brw_wm.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 7dee20b..f7e590d 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -376,6 +376,38 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
 	    swizzles[3] = SWIZZLE_ONE;
 	    break;
 	 }
+      } else {
+	 /* Do remapping for integer MESA_FORMATs which get loaded using a
+	  * mismatched BRW_SURFACEFORMAT.
+	  */
+	 if (_mesa_is_format_integer_color(img->TexFormat)) {
+	    switch (_mesa_get_format_base_format(img->TexFormat)) {
+	    case GL_ALPHA:
+	       swizzles[0] = SWIZZLE_ZERO;
+	       swizzles[1] = SWIZZLE_ZERO;
+	       swizzles[2] = SWIZZLE_ZERO;
+	       swizzles[3] = SWIZZLE_X;
+	       break;
+	    case GL_LUMINANCE:
+	       swizzles[0] = SWIZZLE_X;
+	       swizzles[1] = SWIZZLE_X;
+	       swizzles[2] = SWIZZLE_X;
+	       swizzles[3] = SWIZZLE_ONE;
+	       break;
+	    case GL_INTENSITY:
+	       swizzles[0] = SWIZZLE_X;
+	       swizzles[1] = SWIZZLE_X;
+	       swizzles[2] = SWIZZLE_X;
+	       swizzles[3] = SWIZZLE_X;
+	       break;
+	    case GL_LUMINANCE_ALPHA:
+	       swizzles[0] = SWIZZLE_X;
+	       swizzles[1] = SWIZZLE_X;
+	       swizzles[2] = SWIZZLE_X;
+	       swizzles[3] = SWIZZLE_Y;
+	       break;
+	    }
+	 }
       }
 
       if (img->InternalFormat == GL_YCBCR_MESA) {
-- 
1.7.7.3



More information about the mesa-dev mailing list