VOOZH about

URL: https://www.phoronix.com/news/Mesa-Shader-Stats-Framework

⇱ Mesa Lands A Shader Statistics Framework For More Unification Across Drivers - Phoronix


👁 Phoronix

Mesa Lands A Shader Statistics Framework For More Unification Across Drivers

Written by Michael Larabel in Mesa on 7 March 2025 at 06:19 AM EST. 9 Comments
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.

👁 Mesa shader stats MR


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.

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.