zink: fix add_derefs case for compact arrays

only compact arrays use the aoa size as the vector length

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28466>
(cherry picked from commit 2185da6c89)
This commit is contained in:
Mike Blumenkrantz 2024-03-27 15:59:54 -04:00 committed by Eric Engestrom
parent f08cb1aa44
commit b87c4de1b6
2 changed files with 5 additions and 4 deletions

View File

@ -3974,7 +3974,7 @@
"description": "zink: fix add_derefs case for compact arrays",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View File

@ -3631,6 +3631,8 @@ add_derefs_instr(nir_builder *b, nir_intrinsic_instr *intr, void *data)
bool is_interp = false;
if (!filter_io_instr(intr, &is_load, &is_input, &is_interp))
return false;
bool is_special_io = (b->shader->info.stage == MESA_SHADER_VERTEX && is_input) ||
(b->shader->info.stage == MESA_SHADER_FRAGMENT && !is_input);
unsigned loc = nir_intrinsic_io_semantics(intr).location;
nir_src *src_offset = nir_get_io_offset_src(intr);
const unsigned slot_offset = src_offset && nir_src_is_const(*src_offset) ? nir_src_as_uint(*src_offset) : 0;
@ -3659,9 +3661,8 @@ add_derefs_instr(nir_builder *b, nir_intrinsic_instr *intr, void *data)
bool is_struct = glsl_type_is_struct(glsl_without_array(type));
if (is_struct)
size = get_slot_components(var, var->data.location + slot_offset, var->data.location);
else if ((var->data.mode == nir_var_shader_out && var->data.location < VARYING_SLOT_VAR0) ||
(var->data.mode == nir_var_shader_in && var->data.location < (b->shader->info.stage == MESA_SHADER_VERTEX ? VERT_ATTRIB_GENERIC0 : VARYING_SLOT_VAR0)))
size = glsl_type_is_array(type) ? glsl_get_aoa_size(type) : glsl_get_vector_elements(type);
else if (!is_special_io && var->data.compact)
size = glsl_get_aoa_size(type);
else
size = glsl_get_vector_elements(glsl_without_array(type));
assert(size);