Mesa (master): i965/fs: Add support for textureGather(.., comp)

Chris Forbes chrisf at kemper.freedesktop.org
Sun Oct 6 00:04:33 UTC 2013


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

Author: Chris Forbes <chrisf at ijw.co.nz>
Date:   Sat Oct  5 22:59:17 2013 +1300

i965/fs: Add support for textureGather(.., comp)

- For HSW: Select the channel based on the component selected (swizzle
  is done in HW)
- For IVB: Select the channel based on the swizzle state for the
  component selected. Only apply the RG32F w/a if we actually want
  green -- we're about to flag it regardless of swizzle state.

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 |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 6141009..62d2042 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1475,7 +1475,8 @@ fs_visitor::visit(ir_texture *ir)
       /* When tg4 is used with the degenerate ZERO/ONE swizzles, don't bother
        * emitting anything other than setting up the constant result.
        */
-      int swiz = GET_SWZ(c->key.tex.swizzles[sampler], 0);
+      ir_constant *chan = ir->lod_info.component->as_constant();
+      int swiz = GET_SWZ(c->key.tex.swizzles[sampler], chan->value.i[0]);
       if (swiz == SWIZZLE_ZERO || swiz == SWIZZLE_ONE) {
 
          fs_reg res = fs_reg(this, glsl_type::vec4_type);
@@ -1594,14 +1595,17 @@ fs_visitor::visit(ir_texture *ir)
 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.
-                   */
+   ir_constant *chan = ir->lod_info.component->as_constant();
+   int swiz = GET_SWZ(c->key.tex.swizzles[sampler], chan->value.i[0]);
    switch (swiz) {
       case SWIZZLE_X: return 0;
-      case SWIZZLE_Y: return 1;
+      case SWIZZLE_Y:
+         /* gather4 sampler is broken for green channel on RG32F --
+          * we must ask for blue instead.
+          */
+         if (c->key.tex.gather_channel_quirk_mask & (1<<sampler))
+            return 2;
+         return 1;
       case SWIZZLE_Z: return 2;
       case SWIZZLE_W: return 3;
       default:




More information about the mesa-commit mailing list