glsl: fix a possible crash in gl_nir_lower_xfb_varying
If the last block is empty, nir_block_last_instr returns NULL, which
sets the cursor to NULL, which crashes.
I think this can't crash currently because if xfb is present, there is
always at least 1 output store in the last block due to
lower_io_vars_to_temporaries, but that won't be true after we stop
calling it in a later commit.
Fixes: fa9cee4247 - glsl: implement lower_xfb_varying() as a NIR pass
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35945>
This commit is contained in:
@@ -182,7 +182,7 @@ gl_nir_lower_xfb_varying(nir_shader *shader, const char *old_var_name,
|
||||
b.cursor = nir_before_instr(nir_block_last_instr(block));
|
||||
copy_to_new_var(&b, deref, new_var_deref, type);
|
||||
} else if (block == nir_impl_last_block(impl)) {
|
||||
b.cursor = nir_after_instr(nir_block_last_instr(block));
|
||||
b.cursor = nir_after_block(block);
|
||||
copy_to_new_var(&b, deref, new_var_deref, type);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user