From 39e24082fcb3959f5e56567bd7260b8ee3b470a9 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Tue, 25 Jul 2023 13:29:57 -0700 Subject: [PATCH] radv: Use nir_opt_reuse_constants() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right now, this won't change much the shaders since most of the NIR constants are reused in the NIR generated by SPIR-V, but will make radv resilient to when that behavior change. ``` RADV GFX1100 results for radv fossils: Totals: Instrs: 71623585 -> 71623708 (+0.00%); split: -0.00%, +0.00% CodeSize: 369326156 -> 369324312 (-0.00%); split: -0.00%, +0.00% SpillSGPRs: 13576 -> 13586 (+0.07%) Latency: 632889681 -> 632887831 (-0.00%); split: -0.00%, +0.00% InvThroughput: 81674616 -> 81674859 (+0.00%); split: -0.00%, +0.00% SClause: 2409601 -> 2409593 (-0.00%); split: -0.00%, +0.00% Copies: 4063438 -> 4063579 (+0.00%); split: -0.00%, +0.01% Branches: 1196703 -> 1196723 (+0.00%) PreSGPRs: 4242897 -> 4243061 (+0.00%); split: -0.00%, +0.00% PreVGPRs: 3926739 -> 3926742 (+0.00%) Totals from 217 (0.16% of 133461) affected shaders: Instrs: 353567 -> 353690 (+0.03%); split: -0.04%, +0.07% CodeSize: 1790200 -> 1788356 (-0.10%); split: -0.15%, +0.04% SpillSGPRs: 8 -> 18 (+125.00%) Latency: 5152817 -> 5150967 (-0.04%); split: -0.05%, +0.01% InvThroughput: 664273 -> 664516 (+0.04%); split: -0.03%, +0.06% SClause: 10164 -> 10156 (-0.08%); split: -0.10%, +0.02% Copies: 24225 -> 24366 (+0.58%); split: -0.32%, +0.90% Branches: 7116 -> 7136 (+0.28%) PreSGPRs: 13351 -> 13515 (+1.23%); split: -0.16%, +1.39% PreVGPRs: 11583 -> 11586 (+0.03%) ``` Reviewed-by: Timur Kristóf Part-of: --- src/amd/vulkan/radv_shader.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 7cff6e1bdd8..6f9f484d355 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -467,6 +467,9 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st free(spec_entries); + /* TODO: This can be removed once GCM (which is more general) is used. */ + NIR_PASS(_, nir, nir_opt_reuse_constants); + const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = { .point_coord = true, };