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

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

i965: Use swizzles to force alpha to 1.0 for RED, RG, or RGB textures.

We may be using a texture with actual RGBA storage for these formats, so force
the alpha value read to 1.0.

This commit fixes the following piglit (sub) tests:

        ARB_texture_float/fb-blending-formats
                GL_RGB16F_ARB
        EXT_framebuffer_object/fbo-blending-formats
                GL_RGB10
                GL_RGB12
                GL_RGB16
        EXT_texture_snorm/fbo-blending-formats
                GL_RGB16_SNORM
                GL_RGB8_SNORM
                GL_RGB_SNORM

These test improvements depend on the previous commit as well. That commit
smashes alpha to 1.0 for the case of ReadPixels (so fixes "FBO testing" as
reported by this test), while this commit smashes alpha to 1.0 for the case of
texturing (fixed the "window testing" as reported by this test).

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 |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 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 5e99592..b1f1df1 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -729,6 +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).
+    */
+   switch (img->_BaseFormat) {
+   case GL_RED:
+   case GL_RG:
+   case GL_RGB:
+      swizzles[3] = SWIZZLE_ONE;
+      break;
+   }
+
    return MAKE_SWIZZLE4(swizzles[GET_SWZ(t->_Swizzle, 0)],
                         swizzles[GET_SWZ(t->_Swizzle, 1)],
                         swizzles[GET_SWZ(t->_Swizzle, 2)],

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

Reply via email to