Mesa (master): tgsi/scan: handle indirect image indexing correctly

Marek Olšák mareko at kemper.freedesktop.org
Mon Oct 24 19:42:03 UTC 2016


Module: Mesa
Branch: master
Commit: d89890d000da36c51484ee170b2d9727d2766a93
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d89890d000da36c51484ee170b2d9727d2766a93

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun Oct  9 19:21:33 2016 +0200

tgsi/scan: handle indirect image indexing correctly

Reviewed-by: Nicolai Hähnle <nicolai.haehnle 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
@@ -334,9 +334,12 @@ scan_instruction(struct tgsi_shader_info *info,
          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;
+            }
          }
       }
    }
@@ -358,9 +361,12 @@ scan_instruction(struct tgsi_shader_info *info,
          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;
+         }
       }
    }
 
@@ -419,8 +425,9 @@ scan_declaration(struct tgsi_shader_info *info,
          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;
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
@@ -122,6 +122,8 @@ struct tgsi_shader_info
    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.




More information about the mesa-commit mailing list