From 13e467a147dd4f33ae223dded226d85dc24c1a87 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Fri, 3 Sep 2021 12:21:47 +0200 Subject: [PATCH] ac/nir: Fix match_mask to work correctly for VS outputs. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Rhys Perry Part-of: --- 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 58d489e..2137b4f 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); -- 2.7.4