glsl: remove dead code due to IO being always lowered
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33146>
This commit is contained in:
@@ -484,47 +484,6 @@ gl_nir_can_add_pointsize_to_program(const struct gl_constants *consts,
|
||||
return num_components + needed_components <= max_components;
|
||||
}
|
||||
|
||||
static void
|
||||
gl_nir_link_opts(nir_shader *producer, nir_shader *consumer)
|
||||
{
|
||||
MESA_TRACE_FUNC();
|
||||
|
||||
if (producer->options->lower_to_scalar) {
|
||||
NIR_PASS(_, producer, nir_lower_io_to_scalar_early, nir_var_shader_out);
|
||||
NIR_PASS(_, consumer, nir_lower_io_to_scalar_early, nir_var_shader_in);
|
||||
}
|
||||
|
||||
nir_lower_io_arrays_to_elements(producer, consumer);
|
||||
|
||||
gl_nir_opts(producer);
|
||||
gl_nir_opts(consumer);
|
||||
|
||||
if (nir_link_opt_varyings(producer, consumer))
|
||||
gl_nir_opts(consumer);
|
||||
|
||||
NIR_PASS(_, producer, nir_remove_dead_variables, nir_var_shader_out, NULL);
|
||||
NIR_PASS(_, consumer, nir_remove_dead_variables, nir_var_shader_in, NULL);
|
||||
|
||||
if (nir_remove_unused_varyings(producer, consumer)) {
|
||||
NIR_PASS(_, producer, nir_lower_global_vars_to_local);
|
||||
NIR_PASS(_, consumer, nir_lower_global_vars_to_local);
|
||||
|
||||
gl_nir_opts(producer);
|
||||
gl_nir_opts(consumer);
|
||||
|
||||
/* Optimizations can cause varyings to become unused.
|
||||
* nir_compact_varyings() depends on all dead varyings being removed so
|
||||
* we need to call nir_remove_dead_variables() again here.
|
||||
*/
|
||||
NIR_PASS(_, producer, nir_remove_dead_variables, nir_var_shader_out,
|
||||
NULL);
|
||||
NIR_PASS(_, consumer, nir_remove_dead_variables, nir_var_shader_in,
|
||||
NULL);
|
||||
}
|
||||
|
||||
nir_link_varying_precision(producer, consumer);
|
||||
}
|
||||
|
||||
static bool
|
||||
can_remove_var(nir_variable *var, UNUSED void *data)
|
||||
{
|
||||
@@ -1644,18 +1603,6 @@ gl_nir_link_spirv(const struct gl_constants *consts,
|
||||
gl_nir_link_assign_xfb_resources(consts, prog);
|
||||
gl_nir_lower_optimize_varyings(consts, prog, true);
|
||||
|
||||
if (!linked_shader[0]->Program->nir->info.io_lowered) {
|
||||
/* Linking the stages in the opposite order (from fragment to vertex)
|
||||
* ensures that inter-shader outputs written to in an earlier stage
|
||||
* are eliminated if they are (transitively) not used in a later
|
||||
* stage.
|
||||
*/
|
||||
for (int i = num_shaders - 2; i >= 0; i--) {
|
||||
gl_nir_link_opts(linked_shader[i]->Program->nir,
|
||||
linked_shader[i + 1]->Program->nir);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
||||
struct gl_linked_shader *shader = prog->_LinkedShaders[i];
|
||||
if (shader) {
|
||||
@@ -4017,18 +3964,6 @@ gl_nir_link_glsl(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
if (prog->data->LinkStatus == LINKING_FAILURE)
|
||||
goto done;
|
||||
|
||||
if (!linked_shader[0]->Program->nir->info.io_lowered) {
|
||||
/* Linking the stages in the opposite order (from fragment to vertex)
|
||||
* ensures that inter-shader outputs written to in an earlier stage
|
||||
* are eliminated if they are (transitively) not used in a later
|
||||
* stage.
|
||||
*/
|
||||
for (int i = num_linked_shaders - 2; i >= 0; i--) {
|
||||
gl_nir_link_opts(linked_shader[i]->Program->nir,
|
||||
linked_shader[i + 1]->Program->nir);
|
||||
}
|
||||
}
|
||||
|
||||
/* Tidy up any left overs from the linking process for single shaders.
|
||||
* For example varying arrays that get packed may have dead elements that
|
||||
* can be now be eliminated now that array access has been lowered.
|
||||
|
||||
Reference in New Issue
Block a user