Module: Mesa Branch: main Commit: be05c9458a841e9c2e220aa776bf9e5a81bf0db3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=be05c9458a841e9c2e220aa776bf9e5a81bf0db3
Author: Jesse Natalie <jenat...@microsoft.com> Date: Thu Nov 30 12:51:42 2023 -0800 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> --- src/microsoft/clc/clc_compiler.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/microsoft/clc/clc_compiler.c b/src/microsoft/clc/clc_compiler.c index f8a9f5af076..d2105a0d153 100644 --- a/src/microsoft/clc/clc_compiler.c +++ b/src/microsoft/clc/clc_compiler.c @@ -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,