microsoft/clc: Fix image lowering pass to only erase variables at the end

Otherwise, if a variable has multiple derefs in a shader, we'll crash
trying to remove it a second time. No idea how that can happen though,
seems derefs got sunk by opt_dead_cf.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26435>
This commit is contained in:
Jesse Natalie 2023-11-30 12:51:42 -08:00 committed by Marge Bot
parent aff59c63eb
commit be05c9458a

View file

@ -252,7 +252,6 @@ clc_lower_input_image_deref(nir_builder *b, struct clc_image_lower_context *cont
context->metadata->args[context->metadata_index].image.num_buf_ids = context->num_buf_ids;
nir_instr_remove(&context->deref->instr);
exec_node_remove(&in_var->node);
}
static void
@ -278,6 +277,11 @@ clc_lower_images(nir_shader *nir, struct clc_image_lower_context *context)
}
}
}
nir_foreach_variable_with_modes_safe(var, nir, nir_var_image) {
if (glsl_type_is_image(var->type) && glsl_get_sampler_result_type(var->type) == GLSL_TYPE_VOID)
exec_node_remove(&var->node);
}
}
static void
@ -856,8 +860,6 @@ clc_spirv_to_dxil(struct clc_libclc *lib,
NIR_PASS_V(nir, dxil_lower_sample_to_txf_for_integer_tex,
sampler_id, int_sampler_states, NULL, 14.0f);
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_mem_shared | nir_var_function_temp, NULL);
nir->scratch_size = 0;
NIR_PASS_V(nir, nir_lower_vars_to_explicit_types,
nir_var_mem_shared | nir_var_function_temp | nir_var_mem_global | nir_var_mem_constant,