The GL_AMD_performance_monitor extension allows for capturing and reporting of performance monitors. These counters can hold arbitrary counted data, usually about the performance of the graphics processor and other hardware. The specification on this AMD-spawned GL extension can be found at OpenGL.org.
Implementing this extension has been talked about before for Mesa, but a patch surfaced on Friday by Intel's Kenneth Graunke to provide the actual implementation. Intel implemented support for this AMD-developed extension (though it's already been implemented elsewhere) rather than Intel's own performance counter extension since the company hasn't submitted a specification for their extension to the Khronos registry.
This provides an interface for applications (and OpenGL-based tools) to access GPU performance counters. Since the exact performance counters available vary between vendors and hardware generations, the extension provides an API the application can use to get the names, types, and minimum/maximum values of all available counters. Counters are also organized into groups.The patch providing this Mesa support can be found for now on the mesa-dev list but will likely be merged into mainline Mesa in the near future. The patch is 850 lines of new code.
Applications create "performance monitor" objects, select the counters they want to track, and Begin/End monitoring, much like OpenGL's query API. Multiple monitors can be in flight simultaneously.
We chose not to implement the similar GL_INTEL_performance_queries extension because Intel has not bothered to publish a specification in the OpenGL registry.