From d63549a64293b3a35a90f8a165ce3a903265c39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Sat, 1 Apr 2023 02:19:55 +0200 Subject: [PATCH] ac/nir/ngg: Follow tex sources when analyzing before culling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Helps find more possible reusable uniforms variables. Also prepares the code for more improvements to the analysis. Fossil DB stats on GFX10.3: Totals from 6745 (5.00% of 134913) affected shaders: VGPRs: 304824 -> 304632 (-0.06%) SpillSGPRs: 228 -> 231 (+1.32%) CodeSize: 24975152 -> 24863684 (-0.45%); split: -0.56%, +0.11% Instrs: 4774357 -> 4760913 (-0.28%); split: -0.42%, +0.13% Latency: 22381084 -> 22218421 (-0.73%); split: -0.88%, +0.15% InvThroughput: 3984765 -> 3981677 (-0.08%); split: -0.10%, +0.02% VClause: 110036 -> 110265 (+0.21%); split: -0.67%, +0.88% SClause: 116296 -> 104576 (-10.08%); split: -10.89%, +0.81% Copies: 366923 -> 377370 (+2.85%); split: -0.78%, +3.63% Branches: 119882 -> 119891 (+0.01%); split: -0.00%, +0.01% PreSGPRs: 314591 -> 350697 (+11.48%); split: -0.36%, +11.83% PreVGPRs: 252279 -> 252267 (-0.00%); split: -0.02%, +0.01% Signed-off-by: Timur Kristóf Reviewed-by: Qiang Yu Reviewed-by: Rhys Perry Part-of: --- src/amd/common/ac_nir_lower_ngg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/amd/common/ac_nir_lower_ngg.c b/src/amd/common/ac_nir_lower_ngg.c index 07b461a4f40..12c25e038f0 100644 --- a/src/amd/common/ac_nir_lower_ngg.c +++ b/src/amd/common/ac_nir_lower_ngg.c @@ -1092,6 +1092,16 @@ analyze_shader_before_culling_walk(nir_ssa_def *ssa, break; } + case nir_instr_type_tex: { + nir_tex_instr *tex = nir_instr_as_tex(instr); + unsigned num_srcs = tex->num_srcs; + + for (unsigned i = 0; i < num_srcs; ++i) { + analyze_shader_before_culling_walk(tex->src[i].src.ssa, flag, s); + } + + break; + } case nir_instr_type_phi: { nir_phi_instr *phi = nir_instr_as_phi(instr); nir_foreach_phi_src_safe(phi_src, phi) {