[Mesa-dev] [PATCH 5/6] radv: reorder and add passes to match i965

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Thu Jul 6 21:18:33 UTC 2017


Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

On Thu, Jul 6, 2017 at 9:50 PM, Connor Abbott <connora at valvesoftware.com> wrote:
> From: Connor Abbott <cwabbott0 at gmail.com>
>
> This makes the radv shader pipeline much closer to brw_preprocess_nir().
> The main changes are:
>
> - Now we call nir_split_var_copies(), which is necessary for
> nir_lower_var_copies() to work correctly. The SPIR-V frontend never
> generates variable copies, so we didn't notice this, but this will
> prevent regressions after the next commit that turns on
> nir_lower_io_to_temporaries, which does use copies. We add a call to
> radv_optimize() after nir_split_var_copies() but before lowering var
> copies and other stuff so that NIR optimization passes have a chance to
> work on the un-lowered form. This matches i965.
> - We now call nir_lower_load_const_to_scalar(), which should provide
> more optimization opportunities for NIR.
> - We now get rid of local variables after optimization is done, in case
> an optimization removed one.
> ---
>  src/amd/vulkan/radv_pipeline.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
> index 49610a1..237e146 100644
> --- a/src/amd/vulkan/radv_pipeline.c
> +++ b/src/amd/vulkan/radv_pipeline.c
> @@ -284,12 +284,20 @@ radv_shader_compile_to_nir(struct radv_device *device,
>
>         nir_lower_tex(nir, &tex_options);
>
> -       nir_lower_vars_to_ssa(nir);
> -       nir_lower_var_copies(nir);
>         nir_lower_global_vars_to_local(nir);
> -       nir_remove_dead_variables(nir, nir_var_local);
> +
> +       nir_split_var_copies(nir);
> +
>         radv_optimize_nir(nir);
>
> +       nir_lower_load_const_to_scalar(nir);
> +
> +       nir_lower_var_copies(nir);
> +
> +       radv_optimize_nir(nir);
> +
> +       nir_remove_dead_variables(nir, nir_var_local);
> +
>         if (dump)
>                 nir_print_shader(nir, stderr);
>
> --
> 2.9.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list