[Mesa-dev] [PATCH 05/10] i965/vec4: Do not mark used direct surfaces in the generator for texture opcodes

Iago Toral Quiroga itoral at igalia.com
Fri Oct 30 04:11:57 PDT 2015


Right now the generator marks direct surfaces as used but leaves marking of
indirect surfaces to the caller. Just make the callers handle marking in both
cases for consistency.
---
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp |  6 -----
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp       | 32 ++++++++++++++----------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index ebb353a..297b7c2 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -274,8 +274,6 @@ generate_tex(struct brw_codegen *p,
                  inst->header_size != 0,
                  BRW_SAMPLER_SIMD_MODE_SIMD4X2,
                  return_format);
-
-      brw_mark_surface_used(&prog_data->base, sampler + base_binding_table_index);
    } else {
       /* Non-constant sampler index. */
 
@@ -309,10 +307,6 @@ generate_tex(struct brw_codegen *p,
                               inst->header_size != 0 /* header */,
                               BRW_SAMPLER_SIMD_MODE_SIMD4X2,
                               return_format);
-
-      /* visitor knows more than we do about the surface limit required,
-       * so has already done marking.
-       */
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index efbdaa9..e6d4c0c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -1587,6 +1587,11 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
    src_reg sample_index;
    src_reg mcs;
 
+   unsigned binding_table_texture_start =
+      instr->op == nir_texop_tg4 ?
+         prog_data->base.binding_table.gather_texture_start :
+         prog_data->base.binding_table.texture_start;
+
    const glsl_type *dest_type =
       glsl_type_for_nir_alu_type(instr->dest_type,
                                  nir_tex_instr_dest_size(instr));
@@ -1604,6 +1609,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
    }
 
    /* Load the texture operation sources */
+   bool is_indirect_sampler = false;
    for (unsigned i = 0; i < instr->num_srcs; i++) {
       switch (instr->src[i].src_type) {
       case nir_tex_src_comparitor:
@@ -1672,19 +1678,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
          break;
 
       case nir_tex_src_sampler_offset: {
-         /* The highest sampler which may be used by this operation is
-          * the last element of the array. Mark it here, because the generator
-          * doesn't have enough information to determine the bound.
-          */
-         uint32_t array_size = instr->sampler_array_size;
-         uint32_t max_used = sampler + array_size - 1;
-         if (instr->op == nir_texop_tg4) {
-            max_used += prog_data->base.binding_table.gather_texture_start;
-         } else {
-            max_used += prog_data->base.binding_table.texture_start;
-         }
-
-         brw_mark_surface_used(&prog_data->base, max_used);
+         is_indirect_sampler = true;
 
          /* Emit code to evaluate the actual indexing expression */
          src_reg src = get_nir_src(instr->src[i].src, 1);
@@ -1705,6 +1699,18 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
       }
    }
 
+   if (!is_indirect_sampler) {
+      brw_mark_surface_used(&prog_data->base,
+                            binding_table_texture_start + sampler);
+   } else {
+      /* The highest sampler which may be used by this operation is
+       * the last element of the array.
+       */
+      uint32_t max_used = sampler + instr->sampler_array_size - 1;
+      brw_mark_surface_used(&prog_data->base,
+                            binding_table_texture_start + max_used);
+   }
+
    uint32_t constant_offset = 0;
    for (unsigned i = 0; i < 3; i++) {
       if (instr->const_offset[i] != 0) {
-- 
1.9.1



More information about the mesa-dev mailing list