From be6d584de43966ee58bf1fcac156ebf8040081d1 Mon Sep 17 00:00:00 2001 From: Neha Bhende Date: Thu, 14 Oct 2021 09:37:21 -0700 Subject: [PATCH] st: Fix 64-bit vertex attrib index for TGSI path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák Reviewed-by: Ilia Mirkin Fixes: 77c2b022a0c5 ("st/mesa: remove lowering of 64-bit vertex attribs to 32 bits") Part-of: --- 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;