Mesa (main): st: Fix 64-bit vertex attrib index for TGSI path

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 18 19:34:10 UTC 2021


Module: Mesa
Branch: main
Commit: be6d584de43966ee58bf1fcac156ebf8040081d1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=be6d584de43966ee58bf1fcac156ebf8040081d1

Author: Neha Bhende <bhenden at vmware.com>
Date:   Thu Oct 14 09:37:21 2021 -0700

st: Fix 64-bit vertex attrib index for TGSI path

Patch 77c2b022a0c5 removed lowering of 64-bit vertex attribs to 32bits.
This has thrown TGSI translation off the guard for 64bit attrib.
This lead to fail/crash of 1000+ piglit tests.

This patch basically fixes 64 bit attrib index for TGSI shader by adding placeholder
for second part of a double attribute.
It fixes all regressed piglit tests.

A big help from Charmaine to fix this regression
Reviewed-by: Charmaine Lee <charmainel at vmware.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

Fixes: 77c2b022a0c5 ("st/mesa: remove lowering of 64-bit vertex attribs to 32 bits")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13363>

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index a7e7c78c340..dcbdb096deb 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6650,7 +6650,7 @@ st_translate_program(
    glsl_to_tgsi_visitor *program,
    const struct gl_program *proginfo,
    GLuint numInputs,
-   const ubyte inputMapping[],
+   const ubyte attrToIndex[],
    const ubyte inputSlotToAttr[],
    const ubyte inputSemanticName[],
    const ubyte inputSemanticIndex[],
@@ -6666,6 +6666,7 @@ st_translate_program(
    struct gl_program_constants *prog_const =
       &ctx->Const.Program[program->shader->Stage];
    enum pipe_error ret = PIPE_OK;
+   uint8_t inputMapping[VARYING_SLOT_TESS_MAX] = {0};
 
    assert(numInputs <= ARRAY_SIZE(t->inputs));
    assert(numOutputs <= ARRAY_SIZE(t->outputs));
@@ -6683,6 +6684,27 @@ st_translate_program(
    ASSERT_BITFIELD_SIZE(glsl_to_tgsi_instruction, op,
                         (enum tgsi_opcode) (TGSI_OPCODE_LAST - 1));
 
+   if (proginfo->DualSlotInputs != 0) {
+      /* adjust attrToIndex to include placeholder for second
+       * part of a double attribute
+       */
+      numInputs = 0;
+      for (unsigned attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+         if ((proginfo->info.inputs_read & BITFIELD64_BIT(attr)) != 0) {
+            inputMapping[attr] = numInputs++;
+
+            if ((proginfo->DualSlotInputs & BITFIELD64_BIT(attr)) != 0) {
+               /* add placeholder for second part of a double attribute */
+               numInputs++;
+            }
+         }
+      }
+      inputMapping[VERT_ATTRIB_EDGEFLAG] = numInputs;
+   }
+   else {
+      memcpy(inputMapping, attrToIndex, sizeof(inputMapping));
+   }
+
    t = CALLOC_STRUCT(st_translate);
    if (!t) {
       ret = PIPE_ERROR_OUT_OF_MEMORY;



More information about the mesa-commit mailing list