tgsi/scan: get information about shader buffer usage
authorMarek Olšák <marek.olsak@amd.com>
Sun, 9 Oct 2016 17:26:43 +0000 (19:26 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 24 Oct 2016 19:41:35 +0000 (21:41 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h

index c27f0c6b89acba70c9da39a763a52e9410cd1cac..517b98387a1f0501ad37851b664baffaa621b54c 100644 (file)
@@ -339,6 +339,18 @@ scan_instruction(struct tgsi_shader_info *info,
                   info->images_writemask = info->images_declared;
                else
                   info->images_writemask |= 1 << src->Register.Index;
+            } else if (src->Register.File == TGSI_FILE_BUFFER) {
+               if (src->Register.Indirect)
+                  info->shader_buffers_atomic = info->shader_buffers_declared;
+               else
+                  info->shader_buffers_atomic |= 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
+                  info->shader_buffers_load |= 1 << src->Register.Index;
             }
          }
       }
@@ -366,6 +378,11 @@ scan_instruction(struct tgsi_shader_info *info,
                info->images_writemask = info->images_declared;
             else
                info->images_writemask |= 1 << dst->Register.Index;
+         } else if (dst->Register.File == TGSI_FILE_BUFFER) {
+            if (dst->Register.Indirect)
+               info->shader_buffers_store = info->shader_buffers_declared;
+            else
+               info->shader_buffers_store |= 1 << dst->Register.Index;
          }
       }
    }
@@ -427,6 +444,8 @@ scan_declaration(struct tgsi_shader_info *info,
          info->const_buffers_declared |= 1u << buffer;
       } else if (file == TGSI_FILE_IMAGE) {
          info->images_declared |= 1u << reg;
+      } else if (file == TGSI_FILE_BUFFER) {
+         info->shader_buffers_declared |= 1u << reg;
       } else if (file == TGSI_FILE_INPUT) {
          info->input_semantic_name[reg] = (ubyte) semName;
          info->input_semantic_index[reg] = (ubyte) semIndex;
index 16f00348ac225204a07e53c90840133f730388bc..602a8703d502a30bde7298c624ec59cbd1e09cd6 100644 (file)
@@ -133,6 +133,10 @@ struct tgsi_shader_info
     * Bitmask indicating which declared image is a buffer.
     */
    unsigned images_buffers;
+   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 */
+   unsigned shader_buffers_atomic; /**< bitmask of shader buffers using atomics */
    /**
     * Bitmask indicating which register files are accessed with
     * indirect addressing.  The bits are (1 << TGSI_FILE_x), etc.