diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index c49c4a5fa58..15f87fbcc59 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -328,6 +328,27 @@ nir_optimize(nir_shader *nir, bool allow_copies) static void preprocess_nir(nir_shader *nir) { + /* We have to lower away local variable initializers right before we + * inline functions. That way they get properly initialized at the top + * of the function and not at the top of its caller. + */ + NIR_PASS_V(nir, nir_lower_variable_initializers, nir_var_function_temp); + NIR_PASS_V(nir, nir_lower_returns); + NIR_PASS_V(nir, nir_inline_functions); + NIR_PASS_V(nir, nir_opt_deref); + + /* Pick off the single entrypoint that we want */ + foreach_list_typed_safe(nir_function, func, node, &nir->functions) { + if (func->is_entrypoint) + func->name = ralloc_strdup(func, "main"); + else + exec_node_remove(&func->node); + } + assert(exec_list_length(&nir->functions) == 1); + + /* Vulkan uses the separate-shader linking model */ + nir->info.separate_shader = true; + /* Make sure we lower variable initializers on output variables so that * nir_remove_dead_variables below sees the corresponding stores */ @@ -493,27 +514,6 @@ shader_module_compile_to_nir(struct v3dv_device *device, fprintf(stderr, "\n"); } - /* We have to lower away local variable initializers right before we - * inline functions. That way they get properly initialized at the top - * of the function and not at the top of its caller. - */ - NIR_PASS_V(nir, nir_lower_variable_initializers, nir_var_function_temp); - NIR_PASS_V(nir, nir_lower_returns); - NIR_PASS_V(nir, nir_inline_functions); - NIR_PASS_V(nir, nir_opt_deref); - - /* Pick off the single entrypoint that we want */ - foreach_list_typed_safe(nir_function, func, node, &nir->functions) { - if (func->is_entrypoint) - func->name = ralloc_strdup(func, "main"); - else - exec_node_remove(&func->node); - } - assert(exec_list_length(&nir->functions) == 1); - - /* Vulkan uses the separate-shader linking model */ - nir->info.separate_shader = true; - preprocess_nir(nir); return nir;