Mesa (master): i965/hsw: Apply gather4 RG32F w/ a using SCS instead of shader.

Chris Forbes chrisf at kemper.freedesktop.org
Wed Oct 2 18:58:07 UTC 2013


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

Author: Chris Forbes <chrisf at ijw.co.nz>
Date:   Mon Sep 30 22:53:14 2013 +1300

i965/hsw: Apply gather4 RG32F w/a using SCS instead of shader.

The new surface channel select bits allow us to avoid having to
recompile the shader for this workaround.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-and-tested-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_wm.c                |    5 +++--
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |   14 ++++++++------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 3d1ed44..6ce58dd 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -346,8 +346,9 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
 	       key->gl_clamp_mask[2] |= 1 << s;
 	 }
 
-         /* gather4's channel select for green from RG32F is broken */
-         if (brw->gen >= 7 && prog->UsesGather) {
+         /* gather4's channel select for green from RG32F is broken;
+          * requires a shader w/a on IVB; fixable with just SCS on HSW. */
+         if (brw->gen >= 7 && !brw->is_haswell && prog->UsesGather) {
             if (img->InternalFormat == GL_RG32F && GET_SWZ(t->_Swizzle, 0) == 1)
                key->gather_channel_quirk_mask |= 1 << s;
          }
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 7f934f8..564ac76 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -42,13 +42,13 @@
  * "Shader Channel Select" enumerations (i.e. HSW_SCS_RED)
  */
 static unsigned
-swizzle_to_scs(GLenum swizzle)
+swizzle_to_scs(GLenum swizzle, bool need_green_to_blue)
 {
    switch (swizzle) {
    case SWIZZLE_X:
       return HSW_SCS_RED;
    case SWIZZLE_Y:
-      return HSW_SCS_GREEN;
+      return need_green_to_blue ? HSW_SCS_BLUE : HSW_SCS_GREEN;
    case SWIZZLE_Z:
       return HSW_SCS_BLUE;
    case SWIZZLE_W:
@@ -369,11 +369,13 @@ gen7_update_texture_surface(struct gl_context *ctx,
       const int swizzle = unlikely(alpha_depth)
          ? SWIZZLE_XYZW : brw_get_texture_swizzle(ctx, tObj);
 
+      const bool need_scs_green_to_blue = for_gather && tex_format == BRW_SURFACEFORMAT_R32G32_FLOAT_LD;
+
       surf[7] =
-         SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 0)), GEN7_SURFACE_SCS_R) |
-         SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 1)), GEN7_SURFACE_SCS_G) |
-         SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 2)), GEN7_SURFACE_SCS_B) |
-         SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 3)), GEN7_SURFACE_SCS_A);
+         SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 0), need_scs_green_to_blue), GEN7_SURFACE_SCS_R) |
+         SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 1), need_scs_green_to_blue), GEN7_SURFACE_SCS_G) |
+         SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 2), need_scs_green_to_blue), GEN7_SURFACE_SCS_B) |
+         SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 3), need_scs_green_to_blue), GEN7_SURFACE_SCS_A);
    }
 
    /* Emit relocation to surface contents */




More information about the mesa-commit mailing list