From 28374b466ca0d5797177dd5cd3d3af6e15c21cb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 28 Feb 2023 23:12:58 -0500 Subject: [PATCH] nir: don't remove dead IO variables in nir_lower_io_passes for st_link_nir MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We need to keep variables in the IR because a few places use them, like nir_build_program_resource_list. This will allow us to lower IO in the linker. Reviewed-by: Qiang Yu Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_lower_io.c | 3 +-- src/gallium/drivers/radeonsi/si_shader_nir.c | 1 + src/mesa/state_tracker/st_glsl_to_nir.cpp | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index ab29036..eff8d15 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -3183,8 +3183,7 @@ nir_lower_io_passes(nir_shader *nir) /* Lower and remove dead derefs and variables to clean up the IR. */ NIR_PASS_V(nir, nir_lower_vars_to_ssa); NIR_PASS_V(nir, nir_opt_dce); - NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp | - nir_var_shader_in | nir_var_shader_out, NULL); + NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL); if (nir->xfb_info) NIR_PASS_V(nir, nir_io_add_intrinsic_xfb_info); diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index e5424c4..62f3a2d 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -413,6 +413,7 @@ char *si_finalize_nir(struct pipe_screen *screen, void *nirptr) struct nir_shader *nir = (struct nir_shader *)nirptr; nir_lower_io_passes(nir); + NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in | nir_var_shader_out, NULL); NIR_PASS_V(nir, ac_nir_lower_subdword_loads, (ac_nir_lower_subdword_options) { diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 02d588b..ed2ef5c 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -1076,8 +1076,11 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, /* Lower load_deref/store_deref of inputs and outputs. * This depends on st_nir_assign_varying_locations. */ - if (nir->options->lower_io_variables) + if (nir->options->lower_io_variables) { nir_lower_io_passes(nir); + NIR_PASS_V(nir, nir_remove_dead_variables, + nir_var_shader_in | nir_var_shader_out, NULL); + } /* Set num_uniforms in number of attribute slots (vec4s) */ nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4); -- 2.7.4