[Mesa-dev] [PATCH v2 10/13] i965/fs: make swizzle_result() more generic

Connor Abbott cwabbott0 at gmail.com
Mon Aug 4 15:20:47 PDT 2014


v2: fix build failure
Signed-off-by: Connor Abbott <connor.abbott at intel.com>
---
 src/mesa/drivers/dri/i965/brw_fs.h           |  3 ++-
 src/mesa/drivers/dri/i965/brw_fs_fp.cpp      |  2 +-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 12 ++++++------
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index b86e65e..d3c2e5f 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -242,7 +242,8 @@ public:
    void visit(ir_end_primitive *);
 
    uint32_t gather_channel(ir_texture *ir, int sampler);
-   void swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler);
+   void swizzle_result(ir_texture_opcode op, int dest_components,
+                       fs_reg orig_val, int sampler);
 
    fs_inst *emit(fs_inst *inst);
    void emit(exec_list list);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
index 7048ed4..fb46a27 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
@@ -500,7 +500,7 @@ fs_visitor::emit_fragment_program_code()
          inst->shadow_compare = fpi->TexShadow;
 
          /* Reuse the GLSL swizzle_result() handler. */
-         swizzle_result(ir, dst, fpi->TexSrcUnit);
+         swizzle_result(ir->op, 4, dst, fpi->TexSrcUnit);
          dst = this->result;
 
          break;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 3ac19c1..3521064 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1920,7 +1920,7 @@ fs_visitor::visit(ir_texture *ir)
       emit_gen6_gather_wa(key->tex.gen6_gather_wa[sampler], dst);
    }
 
-   swizzle_result(ir, dst, sampler);
+   swizzle_result(ir->op, ir->type->vector_elements, dst, sampler);
 }
 
 /**
@@ -1982,9 +1982,10 @@ fs_visitor::gather_channel(ir_texture *ir, int sampler)
  * EXT_texture_swizzle as well as DEPTH_TEXTURE_MODE for shadow comparisons.
  */
 void
-fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler)
+fs_visitor::swizzle_result(ir_texture_opcode op, int dest_components,
+                           fs_reg orig_val, int sampler)
 {
-   if (ir->op == ir_query_levels) {
+   if (op == ir_query_levels) {
       /* # levels is in .w */
       orig_val.reg_offset += 3;
       this->result = orig_val;
@@ -1996,12 +1997,11 @@ fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler)
    /* txs,lod don't actually sample the texture, so swizzling the result
     * makes no sense.
     */
-   if (ir->op == ir_txs || ir->op == ir_lod || ir->op == ir_tg4)
+   if (op == ir_txs || op == ir_lod || op == ir_tg4)
       return;
 
-   if (ir->type == glsl_type::float_type) {
+   if (dest_components == 1) {
       /* Ignore DEPTH_TEXTURE_MODE swizzling. */
-      assert(ir->sampler->type->sampler_shadow);
    } else if (key->tex.swizzles[sampler] != SWIZZLE_NOOP) {
       fs_reg swizzled_result = fs_reg(this, glsl_type::vec4_type);
 
-- 
1.9.3



More information about the mesa-dev mailing list