mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-30 23:28:06 +02:00
nir/lower_vars_to_scratch: Remove all unused derefs
If the shader passed to nir_lower_vars_to_scratch contains some unused derefs to a variable that will be lowered, validation will fail because the variable is not part of the shader after the pass. cc: mesa-stable Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26271>
This commit is contained in:
parent
f9c7f33613
commit
827b0fa1ef
1 changed files with 9 additions and 2 deletions
|
|
@ -145,13 +145,21 @@ nir_lower_vars_to_scratch(nir_shader *shader,
|
|||
return false;
|
||||
}
|
||||
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_deref)
|
||||
continue;
|
||||
|
||||
nir_deref_instr *deref = nir_instr_as_deref(instr);
|
||||
|
||||
if (nir_deref_instr_remove_if_unused(deref)) {
|
||||
progress = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (deref->deref_type != nir_deref_type_var)
|
||||
continue;
|
||||
|
||||
|
|
@ -178,7 +186,6 @@ nir_lower_vars_to_scratch(nir_shader *shader,
|
|||
var->data.location = INT_MAX;
|
||||
}
|
||||
|
||||
bool progress = false;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder build = nir_builder_create(impl);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue