From 859e059aa912dee5a7ef36e21eac00e6f5fcc7b3 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 14 Apr 2023 17:50:04 +0100 Subject: [PATCH] radv: use fix_derivs_in_divergent_cf fossil-db (navi21): Totals from 3256 (2.40% of 135636) affected shaders: MaxWaves: 65430 -> 64366 (-1.63%) Instrs: 3517336 -> 3517724 (+0.01%); split: -0.12%, +0.13% CodeSize: 18963788 -> 18946904 (-0.09%); split: -0.14%, +0.05% VGPRs: 172464 -> 175872 (+1.98%); split: -0.02%, +2.00% Latency: 33643792 -> 33643179 (-0.00%); split: -0.12%, +0.12% InvThroughput: 5912965 -> 5934404 (+0.36%); split: -0.09%, +0.46% VClause: 60268 -> 60275 (+0.01%); split: -0.12%, +0.13% SClause: 125227 -> 125241 (+0.01%); split: -0.09%, +0.10% Copies: 253452 -> 254638 (+0.47%); split: -1.29%, +1.76% Branches: 100951 -> 100953 (+0.00%); split: -0.00%, +0.00% PreSGPRs: 186403 -> 185641 (-0.41%) PreVGPRs: 153751 -> 156915 (+2.06%); split: -0.06%, +2.12% Signed-off-by: Rhys Perry Reviewed-by: Georg Lehmann Part-of: --- src/amd/vulkan/radv_pipeline.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 275531f..e9c58ef 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -530,12 +530,21 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_pipeline_layo if (progress) nir_shader_gather_info(stage->nir, nir_shader_get_entrypoint(stage->nir)); - NIR_PASS( - _, stage->nir, ac_nir_lower_tex, - &(ac_nir_lower_tex_options){ - .gfx_level = gfx_level, - .lower_array_layer_round_even = !device->physical_device->rad_info.conformant_trunc_coord, - }); + bool fix_derivs_in_divergent_cf = + stage->stage == MESA_SHADER_FRAGMENT && !radv_use_llvm_for_stage(device, stage->stage); + if (fix_derivs_in_divergent_cf) { + NIR_PASS(_, stage->nir, nir_convert_to_lcssa, true, true); + nir_divergence_analysis(stage->nir); + } + NIR_PASS(_, stage->nir, ac_nir_lower_tex, + &(ac_nir_lower_tex_options){ + .gfx_level = gfx_level, + .lower_array_layer_round_even = !device->physical_device->rad_info.conformant_trunc_coord, + .fix_derivs_in_divergent_cf = fix_derivs_in_divergent_cf, + .max_wqm_vgprs = 64, // TODO: improve spiller and RA support for linear VGPRs + }); + if (fix_derivs_in_divergent_cf) + NIR_PASS(_, stage->nir, nir_opt_remove_phis); /* cleanup LCSSA phis */ if (stage->nir->info.uses_resource_info_query) NIR_PASS(_, stage->nir, ac_nir_lower_resinfo, gfx_level); -- 2.7.4