From fc19ce6c179b5a1f501a020e436daa8dd7fb89b3 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Thu, 2 Apr 2026 21:13:48 +0200 Subject: [PATCH] nir/opt_load_skip_helpers: don't skip helpers for store_scratch data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scratch stores store data for helper lanes that might be used later by an instruction that cares about helpers, or even by control flow. Fixes: a65009e8087 ("nir: Add a nir_opt_tex_skip_helpers optimization") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/work_items/14965 Reviewed-by: Rhys Perry Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_opt_load_skip_helpers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opt_load_skip_helpers.c b/src/compiler/nir/nir_opt_load_skip_helpers.c index 752ce89ea59..c00a850cdf1 100644 --- a/src/compiler/nir/nir_opt_load_skip_helpers.c +++ b/src/compiler/nir/nir_opt_load_skip_helpers.c @@ -161,7 +161,11 @@ nir_opt_load_skip_helpers(nir_shader *shader, nir_opt_load_skip_helpers_options case nir_instr_type_intrinsic: { nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); - if (nir_intrinsic_has_semantic(intr, NIR_INTRINSIC_SUBGROUP)) { + if (nir_intrinsic_has_semantic(intr, NIR_INTRINSIC_SUBGROUP) || + intr->intrinsic == nir_intrinsic_store_scratch) { + /* Subgroup ops might access data from helper lanes and we don't + * know how scratch data is used without more complex tracking. + */ nir_foreach_src(instr, set_src_needs_helpers, &hs); } else if (intr->intrinsic == nir_intrinsic_terminate_if) { /* Unlike demote, terminate disables invocations completely.