The latest bit of increased driver code unification and decreasing code duplication among Mesa’s OpenGL and Vulkan drivers is finally introducing a common shader statistic framework.
Alyssa Rosenzweig has been working on a common shader statistic framework for Mesa drivers to help unify some of the shader statistic options between drivers, help with code deduplication, and unifying some of the related options around dumping shader stats. Plus making it easier for new drivers to implement shader statistics reporting.
Rosenzweig explains in the merge that was accepted this week for Mesa 25.1:
“All mature drivers report shader statistics in various places. GL drivers use util_debug for shader-db’s report script. VK drivers use executable statistics feeding the report fossil script. Many drivers also have a magic env var to dump the stats to stdout/stderr in addition to these standard forms.Implementing any of these 3 reports requires doing brittle string processing in C (GL, stdout) or piles of boilerplate (VK). Additionally, the logic gets duplicated in every driver and duplicated between GL and VK.
And to add insult to injury, the information is duplicated again in the report fossil script :'(
This commit introduces a new ‘shader statistic framework’ that aims to unify statistics reporting across all drivers and across GL&VK. With the new approach, a common XML file defines all the statistics for the tree. The common code introduced here then autogenerates from that XML file an appropriate C header. The header contains a C struct for each ISA, and autogenerated print/report functions. Minimal driver integration is required: just filling out the stats struct and calling the appropriate functions.
In this MR, 3 driver families are added as examples. Panfrost/PanVK and Asahi/Honeykrisp are added as “complete” examples. Neither Vulkan driver reported nontrivial executable statistics; with these changes, both report all the same statistics that the GL drivers report. Turnip is also added partially – it’s not plumbed into ir3/gallium yet but just using the XML reduces boilerplate a ton for Vulkan statistics.”
A useful and arguably long overdue addition to Mesa.