nir/opt_dce: add shader_info::assert_inputs_not_dead

Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41166>
This commit is contained in:
Marek Olšák 2026-04-20 19:05:10 -04:00 committed by Marge Bot
parent 7bd5856cc6
commit a3e3bf0ac2
2 changed files with 22 additions and 0 deletions

View file

@ -114,6 +114,17 @@ struct loop_state {
static void
remove_instr(nir_instr *instr, struct exec_list *dead_instrs)
{
#ifndef NDEBUG
/* Fail an assertion if an input load is dead. This is a debug option. */
if (instr->type == nir_instr_type_intrinsic) {
nir_shader *nir =
nir_cf_node_get_function(&instr->block->cf_node)->function->shader;
if (nir->info.assert_inputs_not_dead)
assert(!nir_is_input_load(nir_instr_as_intrinsic(instr)));
}
#endif
nir_instr_remove(instr);
exec_list_push_tail(dead_instrs, &instr->node);
}

View file

@ -258,6 +258,17 @@ typedef struct shader_info {
*/
bool io_lowered:1;
/* If true, fail an assertion in nir_opt_dce if a dead input is eliminated.
*
* This is a debug aid to easily identify passes that cause shader inputs
* to become dead after nir_opt_varyings when it's preferrable that dead
* shader inputs are identified before nir_opt_varyings.
*
* It shouldn't be enabled by default because inputs can become dead late
* for all sorts of reasons.
*/
bool assert_inputs_not_dead : 1;
/** Has nir_lower_var_copies called. To avoid calling any
* lowering/optimization that would introduce any copy_deref later.
*/