[Mesa-dev] [PATCH 4/7] tgsi/scan: handle indirect image indexing correctly

Marek Olšák maraeo at gmail.com
Thu Oct 20 18:08:51 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 23 +++++++++++++++--------
 src/gallium/auxiliary/tgsi/tgsi_scan.h |  2 ++
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 66f1fdf..c27f0c6 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -327,23 +327,26 @@ scan_instruction(struct tgsi_shader_info *info,
          }
       }
 
       if (is_memory_file(src->Register.File) &&
           !is_mem_query_inst(fullinst->Instruction.Opcode)) {
          is_mem_inst = true;
 
          if (tgsi_get_opcode_info(fullinst->Instruction.Opcode)->is_store) {
             info->writes_memory = TRUE;
 
-            if (src->Register.File == TGSI_FILE_IMAGE &&
-                !src->Register.Indirect)
-               info->images_writemask |= 1 << src->Register.Index;
+            if (src->Register.File == TGSI_FILE_IMAGE) {
+               if (src->Register.Indirect)
+                  info->images_writemask = info->images_declared;
+               else
+                  info->images_writemask |= 1 << src->Register.Index;
+            }
          }
       }
    }
 
    /* check for indirect register writes */
    for (i = 0; i < fullinst->Instruction.NumDstRegs; i++) {
       const struct tgsi_full_dst_register *dst = &fullinst->Dst[i];
       if (dst->Register.Indirect) {
          info->indirect_files |= (1 << dst->Register.File);
          info->indirect_files_written |= (1 << dst->Register.File);
@@ -351,23 +354,26 @@ scan_instruction(struct tgsi_shader_info *info,
 
       if (dst->Register.Dimension && dst->Dimension.Indirect)
          info->dim_indirect_files |= 1u << dst->Register.File;
 
       if (is_memory_file(dst->Register.File)) {
          assert(fullinst->Instruction.Opcode == TGSI_OPCODE_STORE);
 
          is_mem_inst = true;
          info->writes_memory = TRUE;
 
-         if (dst->Register.File == TGSI_FILE_IMAGE &&
-             !dst->Register.Indirect)
-            info->images_writemask |= 1 << dst->Register.Index;
+         if (dst->Register.File == TGSI_FILE_IMAGE) {
+            if (dst->Register.Indirect)
+               info->images_writemask = info->images_declared;
+            else
+               info->images_writemask |= 1 << dst->Register.Index;
+         }
       }
    }
 
    if (is_mem_inst)
       info->num_memory_instructions++;
 
    if (computes_derivative(fullinst->Instruction.Opcode))
       info->uses_derivatives = true;
 
    info->num_instructions++;
@@ -412,22 +418,23 @@ scan_declaration(struct tgsi_shader_info *info,
 
       if (file == TGSI_FILE_CONSTANT) {
          int buffer = 0;
 
          if (fulldecl->Declaration.Dimension)
             buffer = fulldecl->Dim.Index2D;
 
          info->const_file_max[buffer] =
             MAX2(info->const_file_max[buffer], (int)reg);
          info->const_buffers_declared |= 1u << buffer;
-      }
-      else if (file == TGSI_FILE_INPUT) {
+      } else if (file == TGSI_FILE_IMAGE) {
+         info->images_declared |= 1u << reg;
+      } else if (file == TGSI_FILE_INPUT) {
          info->input_semantic_name[reg] = (ubyte) semName;
          info->input_semantic_index[reg] = (ubyte) semIndex;
          info->input_interpolate[reg] = (ubyte)fulldecl->Interp.Interpolate;
          info->input_interpolate_loc[reg] = (ubyte)fulldecl->Interp.Location;
          info->input_cylindrical_wrap[reg] = (ubyte)fulldecl->Interp.CylindricalWrap;
 
          /* Vertex shaders can have inputs with holes between them. */
          info->num_inputs = MAX2(info->num_inputs, reg + 1);
 
          if (semName == TGSI_SEMANTIC_PRIMID)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 47528d5..16f0034 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -115,20 +115,22 @@ struct tgsi_shader_info
    boolean writes_viewport_index;
    boolean writes_layer;
    boolean writes_memory; /**< contains stores or atomics to buffers or images */
    boolean is_msaa_sampler[PIPE_MAX_SAMPLERS];
    boolean uses_doubles; /**< uses any of the double instructions */
    boolean uses_derivatives;
    unsigned clipdist_writemask;
    unsigned culldist_writemask;
    unsigned num_written_culldistance;
    unsigned num_written_clipdistance;
+
+   unsigned images_declared; /**< bitmask of declared images */
    /**
     * Bitmask indicating which images are written to (STORE / ATOM*).
     * Indirect image accesses are not reflected in this mask.
     */
    unsigned images_writemask;
    /**
     * Bitmask indicating which declared image is a buffer.
     */
    unsigned images_buffers;
    /**
-- 
2.7.4



More information about the mesa-dev mailing list