Mesa (master): i965: w/a for gather4 green RG32F

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


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

Author: Chris Forbes <chrisf at ijw.co.nz>
Date:   Sun Aug 11 09:55:30 2013 +1200

i965: w/a for gather4 green RG32F

V4: Only flag quirks if there are any uses of gather in the shader,
    to avoid spurious recompiles just because someone happened to use
    RG32F.

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

---

 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   |    4 ++++
 src/mesa/drivers/dri/i965/brw_program.h        |    5 +++++
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |    4 ++++
 src/mesa/drivers/dri/i965/brw_wm.c             |    9 +++++++++
 4 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 262cead..a8ad659 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1584,6 +1584,10 @@ uint32_t
 fs_visitor::gather_channel(ir_texture *ir, int sampler)
 {
    int swiz = GET_SWZ(c->key.tex.swizzles[sampler], 0 /* red */);
+   if (c->key.tex.gather_channel_quirk_mask & (1<<sampler))
+      return 2;   /* gather4 sampler is broken for green channel on RG32F --
+                   * we must ask for blue instead.
+                   */
    switch (swiz) {
       case SWIZZLE_X: return 0;
       case SWIZZLE_Y: return 1;
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index e2ddaa8..07be4a0 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -40,6 +40,11 @@ struct brw_sampler_prog_key_data {
     */
    uint16_t yuvtex_mask;
    uint16_t yuvtex_swap_mask; /**< UV swaped */
+
+   /**
+    * For RG32F, gather4's channel select is broken.
+    */
+   uint16_t gather_channel_quirk_mask;
 };
 
 #ifdef __cplusplus
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index f6ea28a..9e6cc78 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2392,6 +2392,10 @@ uint32_t
 vec4_visitor::gather_channel(ir_texture *ir, int sampler)
 {
    int swiz = GET_SWZ(key->tex.swizzles[sampler], 0 /* red */);
+   if (key->tex.gather_channel_quirk_mask & (1<<sampler))
+      return 2;   /* gather4 sampler is broken for green channel on RG32F --
+                   * we must ask for blue instead.
+                   */
    switch (swiz) {
       case SWIZZLE_X: return 0;
       case SWIZZLE_Y: return 1;
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 9745eda..3d1ed44 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -32,6 +32,7 @@
 #include "brw_context.h"
 #include "brw_wm.h"
 #include "brw_state.h"
+#include "main/enums.h"
 #include "main/formats.h"
 #include "main/fbobject.h"
 #include "main/samplerobj.h"
@@ -233,6 +234,8 @@ brw_debug_recompile_sampler_key(struct brw_context *brw,
                       old_key->yuvtex_mask, key->yuvtex_mask);
    found |= key_debug(brw, "GL_MESA_ycbcr UV swapping\n",
                       old_key->yuvtex_swap_mask, key->yuvtex_swap_mask);
+   found |= key_debug(brw, "gather channel quirk on any texture unit",
+                      old_key->gather_channel_quirk_mask, key->gather_channel_quirk_mask);
 
    return found;
 }
@@ -342,6 +345,12 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
 	    if (sampler->WrapR == GL_CLAMP)
 	       key->gl_clamp_mask[2] |= 1 << s;
 	 }
+
+         /* gather4's channel select for green from RG32F is broken */
+         if (brw->gen >= 7 && prog->UsesGather) {
+            if (img->InternalFormat == GL_RG32F && GET_SWZ(t->_Swizzle, 0) == 1)
+               key->gather_channel_quirk_mask |= 1 << s;
+         }
       }
    }
 }




More information about the mesa-commit mailing list