Module: Mesa
Branch: master
Commit: 8059c2ea9011110df3632e28a4311de9373b9b4e
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8059c2ea9011110df3632e28a4311de9373b9b4e

Author: Carl Worth <[email protected]>
Date:   Tue Jan 22 13:29:01 2013 -0800

i965: Use swizzles to force R, G, and B to 0.0 for ALPHA textures.

Similar to the previous commit, we may be using a texture with actual RGBA
storage for the GL_ALPHA format, so force the color values to 0.0.

This commit fixes the following piglit (sub) tests:

        EXT_texture_snorm/fbo-blending-formats
                GL_ALPHA16_SNORM
                GL_ALPHA8_SNORM
                GL_ALPHA_SNORM

Note: Haswell bypasses this swizzle code, so may require an independent fix
for this bug.

Reviewed-by: Eric Anholt <[email protected]>

---

 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

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 b1f1df1..b772ef6 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -729,11 +729,18 @@ brw_get_texture_swizzle(const struct gl_texture_object *t)
       }
    }
 
-   /* For a format with no alpha channel, force the alpha result to
-    * 1.0. (This allows for an RGBA texture to be used for an RGB
-    * format, for example).
+   /* If the texture's format is alpha-only, force R, G, and B to
+    * 0.0. Similarly, if the texture's format has no alpha channel,
+    * force the alpha value read to 1.0. This allows for the
+    * implementation to use an RGBA texture for any of these formats
+    * without leaking any unexpected values.
     */
    switch (img->_BaseFormat) {
+   case GL_ALPHA:
+      swizzles[0] = SWIZZLE_ZERO;
+      swizzles[1] = SWIZZLE_ZERO;
+      swizzles[2] = SWIZZLE_ZERO;
+      break;
    case GL_RED:
    case GL_RG:
    case GL_RGB:

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to