[Mesa-dev] [PATCH v2 120/133] i965/fs_nir: Add support for indirect texture

Jason Ekstrand jason at jlekstrand.net
Wed Jan 7 18:03:12 PST 2015


Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>

v2 Jason Ekstrand <jason.ekstrand at intel.com>:
 - Use the nir_tex_src_sampler_offset source type instead of the
   sampler_indirect thing that I cooked up before.
---
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index c7610d1..0eea0fe 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -1574,6 +1574,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
 {
    brw_wm_prog_key *key = (brw_wm_prog_key*) this->key;
    unsigned sampler = instr->sampler_index;
+   fs_reg sampler_reg(sampler);
 
    /* FINISHME: We're failing to recompile our programs when the sampler is
     * updated.  This only matters for the texture rectangle scale parameters
@@ -1644,8 +1645,24 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
          break;
       case nir_tex_src_projector:
          unreachable("should be lowered");
-      case nir_tex_src_sampler_index:
-         unreachable("not yet supported");
+
+      case nir_tex_src_sampler_offset: {
+         /* Figure out the highest possible sampler index and mark it as used */
+         uint32_t max_used = sampler + instr->sampler_array_size - 1;
+         if (instr->op == nir_texop_tg4 && brw->gen < 8) {
+            max_used += stage_prog_data->binding_table.gather_texture_start;
+         } else {
+            max_used += stage_prog_data->binding_table.texture_start;
+         }
+         brw_mark_surface_used(prog_data, max_used);
+
+         /* Emit code to evaluate the actual indexing expression */
+         sampler_reg = fs_reg(this, glsl_type::uint_type);
+         emit(ADD(sampler_reg, src, fs_reg(sampler)))
+             ->force_writemask_all = true;
+         break;
+      }
+
       default:
          unreachable("unknown texture source");
       }
@@ -1653,7 +1670,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
 
    if (instr->op == nir_texop_txf_ms) {
       if (brw->gen >= 7 && key->tex.compressed_multisample_layout_mask & (1<<sampler))
-         mcs = emit_mcs_fetch(coordinate, instr->coord_components, fs_reg(sampler));
+         mcs = emit_mcs_fetch(coordinate, instr->coord_components, sampler_reg);
       else
          mcs = fs_reg(0u);
    }
@@ -1704,7 +1721,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
    emit_texture(op, dest_type, coordinate, instr->coord_components,
                 shadow_comparitor, lod, lod2, lod_components, sample_index,
                 offset, offset_components, mcs, gather_component,
-                is_cube_array, is_rect, sampler, fs_reg(sampler), texunit);
+                is_cube_array, is_rect, sampler, sampler_reg, texunit);
 
    fs_reg dest = get_nir_dest(instr->dest);
    dest.type = this->result.type;
-- 
2.2.0



More information about the mesa-dev mailing list