[Mesa-dev] [PATCH 08/11] intel/fs: Mark texture surfaces used in brw_fs_nir

Jason Ekstrand jason at jlekstrand.net
Sat Nov 3 00:06:40 UTC 2018


Previously, we were marking constant surface used in the generator and
non-constant ones in brw_fs_nir.  We should pick one and go with it.
---
 src/intel/compiler/brw_fs_generator.cpp |  2 --
 src/intel/compiler/brw_fs_nir.cpp       | 16 ++++++++--------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/intel/compiler/brw_fs_generator.cpp b/src/intel/compiler/brw_fs_generator.cpp
index 3182f6014bc..36f8ec3fd16 100644
--- a/src/intel/compiler/brw_fs_generator.cpp
+++ b/src/intel/compiler/brw_fs_generator.cpp
@@ -1185,8 +1185,6 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src
                  inst->header_size != 0,
                  simd_mode,
                  return_format);
-
-      brw_mark_surface_used(prog_data, surface + base_binding_table_index);
    } else {
       /* Non-const sampler index */
 
diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp
index c845d87d59b..8835334e273 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -5003,6 +5003,7 @@ void
 fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
 {
    unsigned texture = instr->texture_index;
+   unsigned max_texture = texture;
    unsigned sampler = instr->sampler_index;
 
    fs_reg srcs[TEX_LOGICAL_NUM_SRCS];
@@ -5088,14 +5089,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
 
       case nir_tex_src_texture_offset: {
          /* Figure out the highest possible texture index and mark it as used */
-         uint32_t max_used = texture + instr->texture_array_size - 1;
-         if (instr->op == nir_texop_tg4 && devinfo->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);
-
+         max_texture = texture + instr->texture_array_size - 1;
          /* Emit code to evaluate the actual indexing expression */
          fs_reg tmp = vgrf(glsl_type::uint_type);
          bld.ADD(tmp, src, brw_imm_ud(texture));
@@ -5126,6 +5120,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
             stage_prog_data->binding_table.texture_start;
 
          srcs[TEX_LOGICAL_SRC_SURFACE] = brw_imm_ud(texture_index);
+         max_texture = texture_index;
          break;
       }
 
@@ -5134,6 +5129,11 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
       }
    }
 
+   unsigned bt_start = instr->op == nir_texop_tg4 && devinfo->gen < 8 ?
+                       stage_prog_data->binding_table.gather_texture_start :
+                       stage_prog_data->binding_table.texture_start;
+   brw_mark_surface_used(prog_data, bt_start + max_texture);
+
    if (srcs[TEX_LOGICAL_SRC_MCS].file == BAD_FILE &&
        (instr->op == nir_texop_txf_ms ||
         instr->op == nir_texop_samples_identical)) {
-- 
2.19.1



More information about the mesa-dev mailing list