nir/opt_load_skip_helpers: don't skip helpers for store_scratch data

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: a65009e808 ("nir: Add a nir_opt_tex_skip_helpers optimization")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/work_items/14965
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit fc19ce6c17)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40979>
This commit is contained in:
Georg Lehmann 2026-04-02 21:13:48 +02:00 committed by Eric Engestrom
parent fa14f8e6d5
commit 7757ddb8a9
2 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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.