[Mesa-dev] [PATCH] radv: Add NIR loop unrolling.

Timothy Arceri tarceri at itsqueeze.com
Sun Apr 30 00:10:36 UTC 2017


On 29/04/17 07:11, Bas Nieuwenhuizen wrote:
> Not much effect on dota2/talos, but positive on deferred.

Yeah I had a similar patch but didn't send it because I didn't see any 
difference. Feral tend to have loop heavy shader maybe mad max will show 
something? Anyway.

Reviewed-by: Timothy Arceri <timothy.arceri at itsqueeze.com>

> 
> Signed-off-by: Bas Nieuwenhuizen <basni at google.com>
> ---
>   src/amd/vulkan/radv_pipeline.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
> index d6989137a55..7340675915f 100644
> --- a/src/amd/vulkan/radv_pipeline.c
> +++ b/src/amd/vulkan/radv_pipeline.c
> @@ -61,6 +61,7 @@ static const struct nir_shader_compiler_options nir_options = {
>   	.lower_unpack_unorm_4x8 = true,
>   	.lower_extract_byte = true,
>   	.lower_extract_word = true,
> +	.max_unroll_iterations = 32
>   };
>   
>   VkResult radv_CreateShaderModule(
> @@ -152,6 +153,12 @@ radv_optimize_nir(struct nir_shader *shader)
>                   NIR_PASS(progress, shader, nir_copy_prop);
>                   NIR_PASS(progress, shader, nir_opt_remove_phis);
>                   NIR_PASS(progress, shader, nir_opt_dce);
> +                if (nir_opt_trivial_continues(shader)) {
> +                        progress = true;
> +                        NIR_PASS(progress, shader, nir_copy_prop);
> +                        NIR_PASS(progress, shader, nir_opt_dce);
> +                }
> +                NIR_PASS(progress, shader, nir_opt_if);
>                   NIR_PASS(progress, shader, nir_opt_dead_cf);
>                   NIR_PASS(progress, shader, nir_opt_cse);
>                   NIR_PASS(progress, shader, nir_opt_peephole_select, 8);
> @@ -159,6 +166,9 @@ radv_optimize_nir(struct nir_shader *shader)
>                   NIR_PASS(progress, shader, nir_opt_constant_folding);
>                   NIR_PASS(progress, shader, nir_opt_undef);
>                   NIR_PASS(progress, shader, nir_opt_conditional_discard);
> +                if (shader->options->max_unroll_iterations) {
> +                        NIR_PASS(progress, shader, nir_opt_loop_unroll, 0);
> +                }
>           } while (progress);
>   }
>   
> 


More information about the mesa-dev mailing list