From 959520e227a4059527752bae62caf7b01a66b74e Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 25 Nov 2025 16:40:20 -0800 Subject: [PATCH] tu: Add a loop count to VK_pipeline_executable_properties. This will improve the report-fossil summaries I'm looking at for loop unrolling, by showing me that loop count changed. With a followup change for my report-fossil to bring over behavior from GL report.py where we ignore other counters when loop count changes (yeah, you expected to increase instruction counts, it's fine), we go from: Totals: Instrs: 73000 -> 73242 (+0.33%) CodeSize: 142250 -> 142506 (+0.18%) NOPs: 13896 -> 13964 (+0.49%) MOVs: 2440 -> 2438 (-0.08%) Full: 1489 -> 1490 (+0.07%) (ss): 1742 -> 1754 (+0.69%) (ss)-stall: 7226 -> 7354 (+1.77%) Number of hardware loops: 79 -> 78 (-1.27%) [...] Totals from 1 (0.60% of 168) affected shaders: Instrs: 184 -> 426 (+131.52%) CodeSize: 288 -> 544 (+88.89%) NOPs: 80 -> 148 (+85.00%) MOVs: 9 -> 7 (-22.22%) Full: 11 -> 12 (+9.09%) (ss): 14 -> 26 (+85.71%) (ss)-stall: 58 -> 186 (+220.69%) Number of hardware loops: 2 -> 1 (-50.00%) [...] PERCENTAGE DELTAS Shaders Instrs CodeSize NOPs MOVs Full [...] app_name 168 +0.33% +0.18% +0.49% -0.08% +0.07% +0.69% +1.77% [...] -------------------------------------------------------------------------------------------------------[...] All affected 1 +131.52% +88.89% +85.00% -22.22% +9.09% +85.71% +220.69% [...] -------------------------------------------------------------------------------------------------------[...] Total 168 +0.33% +0.18% +0.49% -0.08% +0.07% +0.69% +1.77% [...] to: Totals: Number of hardware loops: 79 -> 78 (-1.27%) Totals from 1 (0.60% of 168) affected shaders: Number of hardware loops: 2 -> 1 (-50.00%) PERCENTAGE DELTAS Shaders Number of hardware loops app_name 168 -1.27% --------------------------------------------------------- All affected 1 -50.00% --------------------------------------------------------- Total 168 -1.27% Part-of: --- src/freedreno/ir3/ir3.c | 1 + src/freedreno/ir3/ir3.h | 1 + src/freedreno/vulkan/tu_pipeline.cc | 1 + src/util/shader_stats.xml | 1 + 4 files changed, 4 insertions(+) diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c index 94a9bfaf71e..086f4cb16a9 100644 --- a/src/freedreno/ir3/ir3.c +++ b/src/freedreno/ir3/ir3.c @@ -380,6 +380,7 @@ ir3_collect_info(struct ir3_shader_variant *v) info->sizedwords = info->size / 4; info->early_preamble = v->early_preamble; + info->loops = v->loops; bool in_preamble = false; bool has_eq = false; diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h index 89c63f11ab9..864642f9dc7 100644 --- a/src/freedreno/ir3/ir3.h +++ b/src/freedreno/ir3/ir3.h @@ -42,6 +42,7 @@ struct ir3_info { uint16_t nops_count; /* # of nop instructions, including nopN */ uint16_t mov_count; uint16_t cov_count; + uint16_t loops; uint16_t stp_count; uint16_t ldp_count; /* NOTE: max_reg, etc, does not include registers not touched diff --git a/src/freedreno/vulkan/tu_pipeline.cc b/src/freedreno/vulkan/tu_pipeline.cc index 5081bbf4aa9..161f2a4e71a 100644 --- a/src/freedreno/vulkan/tu_pipeline.cc +++ b/src/freedreno/vulkan/tu_pipeline.cc @@ -4952,6 +4952,7 @@ tu_GetPipelineExecutableStatisticsKHR( stats.sy = exe->stats.sy; stats.ss_stall = exe->stats.sstall; stats.sy_stall = exe->stats.systall; + stats.loops = exe->stats.loops; stats.stps = exe->stats.stp_count; stats.ldps = exe->stats.ldp_count; stats.preamble_inst = exe->stats.preamble_instrs_count; diff --git a/src/util/shader_stats.xml b/src/util/shader_stats.xml index 10c449f8de3..36f870b9060 100644 --- a/src/util/shader_stats.xml +++ b/src/util/shader_stats.xml @@ -15,6 +15,7 @@ A better metric to estimate the impact of SS syncs. A better metric to estimate the impact of SY syncs. Number of cat# instructions. + Number of hardware loops Number of STore Private instructions in the final generated shader executable. Number of LoaD Private instructions in the final generated shader executable. Total number of IR3 instructions in the preamble.