nir/lower_helper_writes: fix stores after discard

We need to use nir_is_helper_invocation instead of
nir_load_helper_invocation, to correctly predicate stores after demote.

Identified in a Piglit on AGX a year ago but I forgot to upstream this.

Fixes: 586da7b329 ("nir: Add nir_lower_helper_writes pass")
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33939>
This commit is contained in:
Alyssa Rosenzweig 2025-03-07 09:43:59 -05:00 committed by Marge Bot
parent e90ccf91a3
commit bc6b527b52

View file

@ -53,7 +53,10 @@ lower(nir_builder *b, nir_intrinsic_instr *intr, void *data)
bool has_dest = nir_intrinsic_infos[intr->intrinsic].has_dest;
nir_def *undef = NULL;
nir_def *helper = nir_load_helper_invocation(b, 1);
/* We need to use nir_is_helper_invocation instead of
* nir_load_helper_invocation, to correctly predicate stores after demote.
*/
nir_def *helper = nir_is_helper_invocation(b, 1);
nir_push_if(b, nir_inot(b, helper));
nir_instr_remove(&intr->instr);
nir_builder_instr_insert(b, &intr->instr);