[Mesa-dev] [PATCH 02/11] tgsi/scan: get more information about arrays and handle arrays correctly

Marek Olšák maraeo at gmail.com
Sun May 24 04:19:21 PDT 2015


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

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

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index d821072..cd7eb9e 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -167,13 +167,20 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                = &parse.FullToken.FullDeclaration;
             const uint file = fulldecl->Declaration.File;
             uint reg;
-            if (fulldecl->Declaration.Array)
+
+            if (fulldecl->Declaration.Array) {
+               assert(fulldecl->Array.ArrayID < PIPE_MAX_SHADER_ARRAYS);
+               info->array_first[file][fulldecl->Array.ArrayID] = fulldecl->Range.First;
+               info->array_last[file][fulldecl->Array.ArrayID] = fulldecl->Range.Last;
                info->array_max[file] = MAX2(info->array_max[file], fulldecl->Array.ArrayID);
+            }
+
             for (reg = fulldecl->Range.First;
                  reg <= fulldecl->Range.Last;
                  reg++) {
                unsigned semName = fulldecl->Semantic.Name;
-               unsigned semIndex = fulldecl->Semantic.Index;
+               unsigned semIndex =
+                  fulldecl->Semantic.Index + (reg - fulldecl->Range.First);
 
                /* only first 32 regs will appear in this bitfield */
                info->file_mask[file] |= (1 << reg);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 0ea0e88..86a14e9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -65,6 +65,8 @@ struct tgsi_shader_info
    int file_max[TGSI_FILE_COUNT];  /**< highest index of declared registers */
    int const_file_max[PIPE_MAX_CONSTANT_BUFFERS];
 
+   unsigned array_first[TGSI_FILE_COUNT][PIPE_MAX_SHADER_ARRAYS];
+   unsigned array_last[TGSI_FILE_COUNT][PIPE_MAX_SHADER_ARRAYS];
    unsigned array_max[TGSI_FILE_COUNT];  /**< highest index array per register file */
 
    uint immediate_count; /**< number of immediates declared */
-- 
2.1.0



More information about the mesa-dev mailing list