From a12a71e6c0c3f09a88c5b857f8e225f6bb35a3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Sun, 26 Jun 2022 01:21:40 +0200 Subject: [PATCH] radv: use shader_info->var_copies_lowered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of passing allow_copies as a parameter for radv_optimize_nir (so manually doing that tracking). Reviewed-by: Timur Kristóf Part-of: --- src/amd/vulkan/radv_pipeline.c | 4 ++-- src/amd/vulkan/radv_shader.c | 15 +++++++-------- src/amd/vulkan/radv_shader.h | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 4c283ee0a94..9d0ae9f40e8 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -3640,7 +3640,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, if (stages[i].nir) { int64_t stage_start = os_time_get_nano(); - radv_optimize_nir(stages[i].nir, optimize_conservatively, false); + radv_optimize_nir(stages[i].nir, optimize_conservatively); /* Gather info again, information such as outputs_read can be out-of-date. */ nir_shader_gather_info(stages[i].nir, nir_shader_get_entrypoint(stages[i].nir)); @@ -5528,7 +5528,7 @@ radv_compute_pipeline_compile(struct radv_compute_pipeline *pipeline, /* Compile SPIR-V shader to NIR. */ cs_stage.nir = radv_shader_spirv_to_nir(device, &cs_stage, pipeline_key, pipeline->base.is_internal); - radv_optimize_nir(cs_stage.nir, pipeline_key->optimisations_disabled, false); + radv_optimize_nir(cs_stage.nir, pipeline_key->optimisations_disabled); /* Gather info again, information such as outputs_read can be out-of-date. */ nir_shader_gather_info(cs_stage.nir, diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index a47bcbf748f..6239408e574 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -170,7 +170,7 @@ radv_can_dump_shader_stats(struct radv_device *device, nir_shader *nir) } void -radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively, bool allow_copies) +radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively) { bool progress; @@ -180,11 +180,10 @@ radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively, bool NIR_PASS(progress, shader, nir_split_array_vars, nir_var_function_temp); NIR_PASS(progress, shader, nir_shrink_vec_array_vars, nir_var_function_temp); - if (allow_copies) { - /* Only run this pass in the first call to - * radv_optimize_nir. Later calls assume that we've - * lowered away any copy_deref instructions and we - * don't want to introduce any more. + if (!shader->info.var_copies_lowered) { + /* Only run this pass if nir_lower_var_copies was not called + * yet. That would lower away any copy_deref instructions and we + * don't want to introduce any more. */ NIR_PASS(progress, shader, nir_opt_find_array_copies); } @@ -1044,7 +1043,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_pipeline_ NIR_PASS(_, nir, nir_opt_shrink_stores, !device->instance->disable_shrink_image_store); if (!key->optimisations_disabled) - radv_optimize_nir(nir, false, true); + radv_optimize_nir(nir, false); /* We call nir_lower_var_copies() after the first radv_optimize_nir() * to remove any copies introduced by nir_opt_find_array_copies(). @@ -1124,7 +1123,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_pipeline_ if (ac_nir_lower_indirect_derefs(nir, device->physical_device->rad_info.gfx_level) && !key->optimisations_disabled && nir->info.stage != MESA_SHADER_COMPUTE) { /* Optimize the lowered code before the linking optimizations. */ - radv_optimize_nir(nir, false, false); + radv_optimize_nir(nir, false); } diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index ff5edc7685e..54727cbb7e9 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -530,7 +530,7 @@ struct radv_shader_part { struct radv_pipeline_layout; -void radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively, bool allow_copies); +void radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively); void radv_optimize_nir_algebraic(nir_shader *shader, bool opt_offsets); bool radv_nir_lower_ray_queries(nir_shader *shader, struct radv_device *device);