[Mesa-dev] [PATCH 1/7] tgsi/scan: get information about indirect CONST access

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


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

---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 13 +++++++++++++
 src/gallium/auxiliary/tgsi/tgsi_scan.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index b862078..0c81005 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -264,20 +264,32 @@ scan_instruction(struct tgsi_shader_info *info,
                   /* TGSI_INTERPOLATE_CONSTANT doesn't do any interpolation. */
                }
             }
          }
       }
 
       /* check for indirect register reads */
       if (src->Register.Indirect) {
          info->indirect_files |= (1 << src->Register.File);
          info->indirect_files_read |= (1 << src->Register.File);
+
+         /* record indirect constant buffer indexing */
+         if (src->Register.File == TGSI_FILE_CONSTANT) {
+            if (src->Register.Dimension) {
+               if (src->Dimension.Indirect)
+                  info->const_buffers_indirect = info->const_buffers_declared;
+               else
+                  info->const_buffers_indirect |= 1u << src->Dimension.Index;
+            } else {
+               info->const_buffers_indirect |= 1;
+            }
+         }
       }
 
       /* Texture samplers */
       if (src->Register.File == TGSI_FILE_SAMPLER) {
          const unsigned index = src->Register.Index;
 
          assert(fullinst->Instruction.Texture);
          assert(index < ARRAY_SIZE(info->is_msaa_sampler));
          assert(index < PIPE_MAX_SAMPLERS);
 
@@ -385,20 +397,21 @@ scan_declaration(struct tgsi_shader_info *info,
       info->file_max[file] = MAX2(info->file_max[file], (int)reg);
 
       if (file == TGSI_FILE_CONSTANT) {
          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_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 0c5f2ba..2e61dc7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -57,20 +57,21 @@ struct tgsi_shader_info
 
    ubyte num_system_values;
    ubyte system_value_semantic_name[PIPE_MAX_SHADER_INPUTS];
 
    ubyte processor;
 
    uint file_mask[TGSI_FILE_COUNT];  /**< bitmask of declared registers */
    uint file_count[TGSI_FILE_COUNT];  /**< number of declared registers */
    int file_max[TGSI_FILE_COUNT];  /**< highest index of declared registers */
    int const_file_max[PIPE_MAX_CONSTANT_BUFFERS];
+   unsigned const_buffers_declared; /**< bitmask of declared const buffers */
    unsigned samplers_declared; /**< bitmask of declared samplers */
    ubyte sampler_targets[PIPE_MAX_SHADER_SAMPLER_VIEWS];  /**< TGSI_TEXTURE_x values */
    ubyte sampler_type[PIPE_MAX_SHADER_SAMPLER_VIEWS]; /**< TGSI_RETURN_TYPE_x */
 
    ubyte input_array_first[PIPE_MAX_SHADER_INPUTS];
    ubyte input_array_last[PIPE_MAX_SHADER_INPUTS];
    ubyte output_array_first[PIPE_MAX_SHADER_OUTPUTS];
    ubyte output_array_last[PIPE_MAX_SHADER_OUTPUTS];
    unsigned array_max[TGSI_FILE_COUNT];  /**< highest index array per register file */
 
@@ -134,20 +135,21 @@ struct tgsi_shader_info
     * 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;
    unsigned indirect_files_written;
+   unsigned const_buffers_indirect; /**< const buffers using indirect addressing */
 
    unsigned properties[TGSI_PROPERTY_COUNT]; /* index with TGSI_PROPERTY_ */
 
    /**
     * Max nesting limit of loops/if's
     */
    unsigned max_depth;
 };
 
 struct tgsi_array_info
-- 
2.7.4



More information about the mesa-dev mailing list