Module: Mesa Branch: main Commit: 13e467a147dd4f33ae223dded226d85dc24c1a87 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=13e467a147dd4f33ae223dded226d85dc24c1a87
Author: Timur Kristóf <[email protected]> Date: Fri Sep 3 12:21:47 2021 +0200 ac/nir: Fix match_mask to work correctly for VS outputs. match_mask checks the intrinsic type and decides whether it's per-patch or not. VS don't have per-patch outputs, so this causes wrong behaviour there. Found using the GCC undefined behavior sanitizer. Fixes the following error: runtime error: shift exponent 18446744073709551584 is too large for 64-bit type 'long unsigned int' Closes: #5319 Fixes: bf966d1c1dd968116b8b547ca2739f5113caccb5 Signed-off-by: Timur Kristóf <[email protected]> Reviewed-by: Rhys Perry <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12719> --- src/amd/common/ac_nir_lower_tess_io_to_mem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/amd/common/ac_nir_lower_tess_io_to_mem.c b/src/amd/common/ac_nir_lower_tess_io_to_mem.c index 58d489e3776..2137b4f9c0f 100644 --- a/src/amd/common/ac_nir_lower_tess_io_to_mem.c +++ b/src/amd/common/ac_nir_lower_tess_io_to_mem.c @@ -154,7 +154,8 @@ typedef struct { } lower_tess_io_state; static bool -match_mask(nir_intrinsic_instr *intrin, +match_mask(gl_shader_stage stage, + nir_intrinsic_instr *intrin, uint64_t mask, bool match_indirect) { @@ -163,7 +164,8 @@ match_mask(nir_intrinsic_instr *intrin, return match_indirect; uint64_t slot = nir_intrinsic_io_semantics(intrin).location; - if (intrin->intrinsic != nir_intrinsic_load_per_vertex_input && + if (stage == MESA_SHADER_TESS_CTRL && + intrin->intrinsic != nir_intrinsic_load_per_vertex_input && intrin->intrinsic != nir_intrinsic_store_per_vertex_output) slot -= VARYING_SLOT_PATCH0; @@ -178,7 +180,7 @@ tcs_output_needs_vmem(nir_intrinsic_instr *intrin, ? st->tes_inputs_read : st->tes_patch_inputs_read; - return match_mask(intrin, mask, true); + return match_mask(MESA_SHADER_TESS_CTRL, intrin, mask, true); } static bool @@ -189,7 +191,7 @@ tcs_output_needs_lds(nir_intrinsic_instr *intrin, ? shader->info.outputs_read : shader->info.patch_outputs_read; - return match_mask(intrin, mask, true); + return match_mask(MESA_SHADER_TESS_CTRL, intrin, mask, true); } static bool @@ -208,7 +210,7 @@ lower_ls_output_store(nir_builder *b, lower_tess_io_state *st = (lower_tess_io_state *) state; /* If this is a temp-only TCS input, we don't need to use shared memory at all. */ - if (match_mask(intrin, st->tcs_temp_only_inputs, false)) + if (match_mask(MESA_SHADER_VERTEX, intrin, st->tcs_temp_only_inputs, false)) return false; b->cursor = nir_before_instr(instr);
