[Mesa-dev] [PATCH resend] mesa: Add core support for the GL_AMD_performance_monitor extension.
Christoph Bumiller
e0425955 at student.tuwien.ac.at
Sat Apr 13 03:50:39 PDT 2013
On 12.04.2013 21:14, Kenneth Graunke wrote:
> 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.
>
> 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.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
> src/mapi/glapi/gen/AMD_performance_monitor.xml | 87 ++++
> src/mapi/glapi/gen/Makefile.am | 1 +
> src/mapi/glapi/gen/gl_API.xml | 2 +
> src/mapi/glapi/gen/gl_genexec.py | 1 +
> src/mesa/SConscript | 1 +
> src/mesa/main/context.c | 2 +
> src/mesa/main/dd.h | 22 +
> src/mesa/main/extensions.c | 1 +
> src/mesa/main/mtypes.h | 84 ++++
> src/mesa/main/performance_monitor.c | 563 +++++++++++++++++++++++++
> src/mesa/main/performance_monitor.h | 85 ++++
> src/mesa/sources.mak | 1 +
> 12 files changed, 850 insertions(+)
> create mode 100644 src/mapi/glapi/gen/AMD_performance_monitor.xml
> create mode 100644 src/mesa/main/performance_monitor.c
> create mode 100644 src/mesa/main/performance_monitor.h
>
> /**
> + * A "performance monitor" as described in AMD_performance_monitor.
> + */
> +struct gl_perf_monitor_object
> +{
> + GLboolean Active;
> +
> + /* Actually BITSET_WORD but we can't #include that here. */
> + GLuint *ActiveCounters;
> +};
> +
Started to implement this for mesa/st, got a question about ActiveCounters:
Does this bitset refer to the counter IDs or the Counters array index ?
Do the IDs have to be consecutive ? Do they have to correspond to the
array index ?
> +
> +void GLAPIENTRY
> +_mesa_SelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable,
> + GLuint group, GLint numCounters,
> + GLuint *counterList)
> +{
...
> + if (enable) {
> + /* Enable the counters */
> + for (i = 0; i < numCounters; i++) {
> + BITSET_SET(m->ActiveCounters, counterList[i]);
> + }
> + } else {
> + /* Disable the counters */
> + for (i = 0; i < numCounters; i++) {
> + BITSET_CLEAR(m->ActiveCounters, counterList[i]);
> + }
> + }
> +}
counterList is an ID, so this implies ActiveCounters refers to IDs.
You also do:
m->ActiveCounters = calloc(ctx->PerfMonitor.NumCounters, sizeof(BITSET_WORD));
So, this implies it refers to the Counters array of size NumCounters
(unless the overallocation by 8 * sizeof(BITSET_WORD) bits has some
purpose that escapes me).
Hence, we cannot freely select IDs, can we ?
I had different graciously spaced ranges of gallium query IDs reserved
of different counter domains (since I haven't added all possible
counters, I don't even know all of them, needs REing), so I guess I have
to remap them in the state tracker ...
Anyway, I think this should be mentioned in a comment [that is easy to
find].
Thanks,
Christoph
More information about the mesa-dev
mailing list