From 7757ddb8a9c67c3f73bd1af8aa84d3f39437f13e 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 (cherry picked from commit fc19ce6c179b5a1f501a020e436daa8dd7fb89b3) Part-of: --- .pick_status.json | 2 +- src/compiler/nir/nir_opt_load_skip_helpers.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 1cde0e0e861..0b3de5b5fc9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4404,7 +4404,7 @@ "description": "nir/opt_load_skip_helpers: don't skip helpers for store_scratch data", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "a65009e8087ff0d36bfc6714eaf42874e7b0ade2", "notes": null 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.