tgsi/scan: add images_writemask
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sun, 13 Mar 2016 20:00:40 +0000 (15:00 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 21 Mar 2016 20:34:22 +0000 (15:34 -0500)
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h

index 8e24cc626bda77f8ae1ea56cf4132116ae930cdd..dee6884d14d2ceba1ced25b365f09a481ad0c158 100644 (file)
@@ -38,6 +38,7 @@
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_prim.h"
+#include "tgsi/tgsi_info.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_util.h"
 #include "tgsi/tgsi_scan.h"
@@ -192,8 +193,14 @@ scan_instruction(struct tgsi_shader_info *info,
          }
       }
 
-      if (is_memory_file(src->Register.File))
+      if (is_memory_file(src->Register.File)) {
          is_mem_inst = true;
+
+         if (src->Register.File == TGSI_FILE_IMAGE &&
+             !src->Register.Indirect &&
+             tgsi_get_opcode_info(fullinst->Instruction.Opcode)->is_store)
+            info->images_writemask |= 1 << src->Register.Index;
+      }
    }
 
    /* check for indirect register writes */
@@ -204,8 +211,15 @@ scan_instruction(struct tgsi_shader_info *info,
          info->indirect_files_written |= (1 << dst->Register.File);
       }
 
-      if (is_memory_file(dst->Register.File))
+      if (is_memory_file(dst->Register.File)) {
+         assert(fullinst->Instruction.Opcode == TGSI_OPCODE_STORE);
+
          is_mem_inst = true;
+
+         if (dst->Register.File == TGSI_FILE_IMAGE &&
+             !dst->Register.Indirect)
+            info->images_writemask |= 1 << dst->Register.Index;
+      }
    }
 
    if (is_mem_inst)
index d65dec71888ade525eda3e76ec91df8d939cbb11..f52729ae2d27c348131d022835377212301d691b 100644 (file)
@@ -117,6 +117,11 @@ struct tgsi_shader_info
    unsigned culldist_writemask;
    unsigned num_written_culldistance;
    unsigned num_written_clipdistance;
+   /**
+    * Bitmask indicating which images are written to (STORE / ATOM*).
+    * Indirect image accesses are not reflected in this mask.
+    */
+   unsigned images_writemask;
    /**
     * Bitmask indicating which register files are accessed with
     * indirect addressing.  The bits are (1 << TGSI_FILE_x), etc.