[Mesa-dev] [PATCH 2/2] st/mesa: add texture gather support.

Dave Airlie airlied at gmail.com
Thu Feb 6 17:52:41 PST 2014


From: Dave Airlie <airlied at redhat.com>

This respects the CAP and adds glsl->tgsi support for the TG4 opcode.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/mesa/state_tracker/st_extensions.c     |  4 ++++
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 11 ++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 9829eb5..8509304 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -266,6 +266,7 @@ void st_init_limits(struct st_context *st)
    c->MinProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MIN_TEXEL_OFFSET);
    c->MaxProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET);
 
+   c->MaxProgramTextureGatherComponents = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS);
    c->UniformBooleanTrue = ~0;
 
    c->MaxTransformFeedbackBuffers =
@@ -777,4 +778,7 @@ void st_init_extensions(struct st_context *st)
       if (!ctx->Extensions.EXT_transform_feedback)
          ctx->Const.DisableVaryingPacking = GL_TRUE;
    }
+
+   if (ctx->Const.MaxProgramTextureGatherComponents > 0)
+      ctx->Extensions.ARB_texture_gather = GL_TRUE;
 }
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 610fc68..f75e77e 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2779,12 +2779,16 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
       ir->lod_info.sample_index->accept(this);
       sample_index = this->result;
       break;
+   case ir_tg4:
+      opcode = TGSI_OPCODE_TG4;
+      if (ir->offset) {
+         ir->offset->accept(this);
+         offset = this->result;
+      }
+      break;
    case ir_lod:
       assert(!"Unexpected ir_lod opcode");
       break;
-   case ir_tg4:
-      assert(!"Unexpected ir_tg4 opcode");
-      break;
    case ir_query_levels:
       assert(!"Unexpected ir_query_levels opcode");
       break;
@@ -4450,6 +4454,7 @@ compile_tgsi_instruction(struct st_translate *t,
    case TGSI_OPCODE_TEX2:
    case TGSI_OPCODE_TXB2:
    case TGSI_OPCODE_TXL2:
+   case TGSI_OPCODE_TG4:
       src[num_src++] = t->samplers[inst->sampler];
       for (i = 0; i < inst->tex_offset_num_offset; i++) {
          texoffsets[i] = translate_tex_offset(t, &inst->tex_offsets[i]);
-- 
1.8.3.1



More information about the mesa-dev mailing list