tgsi/scan: record load/store/atomic image usage
authorMarek Olšák <marek.olsak@amd.com>
Tue, 15 Nov 2016 23:47:35 +0000 (00:47 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 3 Mar 2017 14:29:30 +0000 (15:29 +0100)
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h
src/gallium/drivers/radeonsi/si_shader.c

index 7d5496c9603cb13fd51f5c02911280b2621a4647..99799fa16e2ace9e6161a4c22c53bb1f64eb33c2 100644 (file)
@@ -283,9 +283,9 @@ scan_src_operand(struct tgsi_shader_info *info,
 
          if (src->Register.File == TGSI_FILE_IMAGE) {
             if (src->Register.Indirect)
-               info->images_writemask = info->images_declared;
+               info->images_atomic = info->images_declared;
             else
-               info->images_writemask |= 1 << src->Register.Index;
+               info->images_atomic |= 1 << src->Register.Index;
          } else if (src->Register.File == TGSI_FILE_BUFFER) {
             if (src->Register.Indirect)
                info->shader_buffers_atomic = info->shader_buffers_declared;
@@ -293,7 +293,12 @@ scan_src_operand(struct tgsi_shader_info *info,
                info->shader_buffers_atomic |= 1 << src->Register.Index;
          }
       } else {
-         if (src->Register.File == TGSI_FILE_BUFFER) {
+         if (src->Register.File == TGSI_FILE_IMAGE) {
+            if (src->Register.Indirect)
+               info->images_load = info->images_declared;
+            else
+               info->images_load |= 1 << src->Register.Index;
+         } else if (src->Register.File == TGSI_FILE_BUFFER) {
             if (src->Register.Indirect)
                info->shader_buffers_load = info->shader_buffers_declared;
             else
@@ -425,9 +430,9 @@ scan_instruction(struct tgsi_shader_info *info,
 
          if (dst->Register.File == TGSI_FILE_IMAGE) {
             if (dst->Register.Indirect)
-               info->images_writemask = info->images_declared;
+               info->images_store = info->images_declared;
             else
-               info->images_writemask |= 1 << dst->Register.Index;
+               info->images_store |= 1 << dst->Register.Index;
          } else if (dst->Register.File == TGSI_FILE_BUFFER) {
             if (dst->Register.Indirect)
                info->shader_buffers_store = info->shader_buffers_declared;
index e3c24e950ed031ff5c6f9052d030d48c576b38d9..3854827e5cb044dae8fa1b692674800a077a0f0f 100644 (file)
@@ -137,15 +137,13 @@ struct tgsi_shader_info
    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;
+   unsigned images_load; /**< bitmask of images using loads */
+   unsigned images_store; /**< bitmask of images using stores */
+   unsigned images_atomic; /**< bitmask of images using atomics */
    unsigned shader_buffers_declared; /**< bitmask of declared shader buffers */
    unsigned shader_buffers_load; /**< bitmask of shader buffers using loads */
    unsigned shader_buffers_store; /**< bitmask of shader buffers using stores */
index 212a9bee80019b3742c43e1519f89116180cb84d..f84eefc3ddc4329f30764a9f0d19b7fe81a3f0de 100644 (file)
@@ -3328,10 +3328,12 @@ image_fetch_rsrc(
 
        if (!image->Register.Indirect) {
                const struct tgsi_shader_info *info = bld_base->info;
+               unsigned images_writemask = info->images_store |
+                                           info->images_atomic;
 
                index = LLVMConstInt(ctx->i32, image->Register.Index, 0);
 
-               if (info->images_writemask & (1 << image->Register.Index) &&
+               if (images_writemask & (1 << image->Register.Index) &&
                    target != TGSI_TEXTURE_BUFFER)
                        dcc_off = true;
        } else {