[Mesa-dev] [PATCH 5/7] tgsi/scan: get information about shader buffer usage

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


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

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

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index c27f0c6..517b983 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -332,20 +332,32 @@ scan_instruction(struct tgsi_shader_info *info,
          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) {
                if (src->Register.Indirect)
                   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;
             }
          }
       }
    }
 
    /* 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);
@@ -359,20 +371,25 @@ scan_instruction(struct tgsi_shader_info *info,
          assert(fullinst->Instruction.Opcode == TGSI_OPCODE_STORE);
 
          is_mem_inst = true;
          info->writes_memory = TRUE;
 
          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;
+         } 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;
          }
       }
    }
 
    if (is_mem_inst)
       info->num_memory_instructions++;
 
    if (computes_derivative(fullinst->Instruction.Opcode))
       info->uses_derivatives = true;
 
@@ -420,20 +437,22 @@ scan_declaration(struct tgsi_shader_info *info,
          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_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;
          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);
 
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 16f0034..602a870 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -126,20 +126,24 @@ struct tgsi_shader_info
    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 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.
     */
    unsigned indirect_files;
    /**
     * Bitmask indicating which register files are read / written with
     * indirect addressing.  The bits are (1 << TGSI_FILE_x).
     */
    unsigned indirect_files_read;
-- 
2.7.4



More information about the mesa-dev mailing list