nir/lower_clip: don't set cursor to fix crashes due to removed instructions

The original builder already points at the end of the function impl.
Just use that.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32363>
This commit is contained in:
Marek Olšák 2024-11-26 22:01:57 -05:00 committed by Marge Bot
parent 1a0b4531d1
commit 3e40c2010e

View file

@ -161,7 +161,6 @@ static nir_def *
find_output(nir_builder *b, unsigned location)
{
nir_def *comp[4] = {NULL};
nir_instr *last_comp = NULL;
nir_foreach_function_impl(impl, b->shader) {
nir_foreach_block(block, impl) {
@ -184,9 +183,7 @@ find_output(nir_builder *b, unsigned location)
/* Each component should be written only once. */
assert(!comp[index]);
b->cursor = nir_before_instr(&intr->instr);
comp[index] = nir_channel(b, intr->src[0].ssa, i);
last_comp = comp[index]->parent_instr;
}
/* Remove it because it's going to be replaced by CLIP_DIST. */
@ -196,11 +193,7 @@ find_output(nir_builder *b, unsigned location)
}
}
}
if (!last_comp)
return NULL;
b->cursor = nir_after_instr(last_comp);
assert(comp[0] || comp[1] || comp[2] || comp[3]);
for (unsigned i = 0; i < 4; i++) {
if (!comp[i])