nvk_lower_nir(struct nvk_device *device, nir_shader *nir,
const struct nvk_pipeline_layout *layout)
{
- NIR_PASS(_, nir, nir_lower_global_vars_to_local);
-
NIR_PASS(_, nir, nir_split_struct_vars, nir_var_function_temp);
NIR_PASS(_, nir, nir_lower_vars_to_ssa);
+ if (nir->info.stage == MESA_SHADER_VERTEX || nir->info.stage == MESA_SHADER_GEOMETRY ||
+ nir->info.stage == MESA_SHADER_FRAGMENT) {
+ NIR_PASS_V(nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir), true, true);
+ }
+
+ NIR_PASS(_, nir, nir_split_var_copies);
+ NIR_PASS(_, nir, nir_lower_var_copies);
+ NIR_PASS(_, nir, nir_lower_vars_to_ssa);
+
+ NIR_PASS(_, nir, nir_lower_global_vars_to_local);
+ NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
NIR_PASS(_, nir, nir_lower_system_values);
if (nir->info.stage == MESA_SHADER_FRAGMENT) {