radeonsi: do late NIR optimizations after uniform inlining

This was missing.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9028>
This commit is contained in:
Marek Olšák 2021-02-11 03:23:32 -05:00
parent 33ac9dec91
commit 19e6601413
3 changed files with 16 additions and 9 deletions

View file

@ -1412,6 +1412,7 @@ struct nir_shader *si_get_nir_shader(struct si_shader_selector *sel,
nir->info.inlinable_uniform_dw_offsets); nir->info.inlinable_uniform_dw_offsets);
si_nir_opts(sel->screen, nir, true); si_nir_opts(sel->screen, nir, true);
si_nir_late_opts(nir);
/* This must be done again. */ /* This must be done again. */
NIR_PASS_V(nir, nir_io_add_const_offset_to_base, nir_var_shader_in | NIR_PASS_V(nir, nir_io_add_const_offset_to_base, nir_var_shader_in |

View file

@ -877,6 +877,7 @@ struct si_shader *si_generate_gs_copy_shader(struct si_screen *sscreen,
/* si_shader_nir.c */ /* si_shader_nir.c */
void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *info); void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *info);
void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first); void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first);
void si_nir_late_opts(nir_shader *nir);
void si_finalize_nir(struct pipe_screen *screen, void *nirptr, bool optimize); void si_finalize_nir(struct pipe_screen *screen, void *nirptr, bool optimize);
/* si_state_shaders.c */ /* si_state_shaders.c */

View file

@ -550,6 +550,19 @@ void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first)
NIR_PASS_V(nir, nir_lower_var_copies); NIR_PASS_V(nir, nir_lower_var_copies);
} }
void si_nir_late_opts(nir_shader *nir)
{
bool more_late_algebraic = true;
while (more_late_algebraic) {
more_late_algebraic = false;
NIR_PASS(more_late_algebraic, nir, nir_opt_algebraic_late);
NIR_PASS_V(nir, nir_opt_constant_folding);
NIR_PASS_V(nir, nir_copy_prop);
NIR_PASS_V(nir, nir_opt_dce);
NIR_PASS_V(nir, nir_opt_cse);
}
}
static int type_size_vec4(const struct glsl_type *type, bool bindless) static int type_size_vec4(const struct glsl_type *type, bool bindless)
{ {
return glsl_count_attribute_slots(type, false); return glsl_count_attribute_slots(type, false);
@ -765,15 +778,7 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir)
si_nir_opts(sscreen, nir, false); si_nir_opts(sscreen, nir, false);
/* Run late optimizations to fuse ffma. */ /* Run late optimizations to fuse ffma. */
bool more_late_algebraic = true; si_nir_late_opts(nir);
while (more_late_algebraic) {
more_late_algebraic = false;
NIR_PASS(more_late_algebraic, nir, nir_opt_algebraic_late);
NIR_PASS_V(nir, nir_opt_constant_folding);
NIR_PASS_V(nir, nir_copy_prop);
NIR_PASS_V(nir, nir_opt_dce);
NIR_PASS_V(nir, nir_opt_cse);
}
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL); NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);