On Thu, Apr 11, 2013 at 2:00 PM, Kenneth Graunke <kenn...@whitecape.org> 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 <kenn...@whitecape.org> > --- > 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/sources.mak | 1 + > 9 files changed, 115 insertions(+) > > diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am > index 36e47e2..baf8afc 100644 > --- a/src/mapi/glapi/gen/Makefile.am > +++ b/src/mapi/glapi/gen/Makefile.am > @@ -115,6 +115,7 @@ API_XML = \ > ARB_texture_storage.xml \ > ARB_vertex_array_object.xml \ > AMD_draw_buffers_blend.xml \ > + AMD_performance_monitor.xml \ > ARB_vertex_type_2_10_10_10_rev.xml \
I was going to ask if you could alphabetize this, but the whole list is hosed. > APPLE_object_purgeable.xml \ > APPLE_vertex_array_object.xml \ > diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml > index df95924..afc7673 100644 > --- a/src/mapi/glapi/gen/gl_API.xml > +++ b/src/mapi/glapi/gen/gl_API.xml > @@ -12743,6 +12743,8 @@ > <enum name="FRAMEBUFFER_SRGB_CAPABLE_EXT" value="0x8DBA"/> > </category> > > +<xi:include href="AMD_performance_monitor.xml" > xmlns:xi="http://www.w3.org/2001/XInclude"/> > + > <category name="GL_APPLE_texture_range" number="367"> > <enum name="TEXTURE_STORAGE_HINT_APPLE" count="1" value="0x85BC"> > <size name="TexParameteriv"/> > diff --git a/src/mapi/glapi/gen/gl_genexec.py > b/src/mapi/glapi/gen/gl_genexec.py > index a85b447..e1233c4 100644 > --- a/src/mapi/glapi/gen/gl_genexec.py > +++ b/src/mapi/glapi/gen/gl_genexec.py > @@ -82,6 +82,7 @@ header = """/** > #include "main/lines.h" > #include "main/matrix.h" > #include "main/multisample.h" > +#include "main/performance_monitor.h" > #include "main/pixel.h" > #include "main/pixelstore.h" > #include "main/points.h" > diff --git a/src/mesa/SConscript b/src/mesa/SConscript > index ca9b70b..9726c95 100644 > --- a/src/mesa/SConscript > +++ b/src/mesa/SConscript > @@ -97,6 +97,7 @@ main_sources = [ > 'main/multisample.c', > 'main/pack.c', > 'main/pbo.c', > + 'main/performance_monitor.c', > 'main/pixel.c', > 'main/pixelstore.c', > 'main/pixeltransfer.c', > diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c > index 0539934..960239a 100644 > --- a/src/mesa/main/context.c > +++ b/src/mesa/main/context.c > @@ -106,6 +106,7 @@ > #include "macros.h" > #include "matrix.h" > #include "multisample.h" > +#include "performance_monitor.h" > #include "pixel.h" > #include "pixelstore.h" > #include "points.h" > @@ -762,6 +763,7 @@ init_attrib_groups(struct gl_context *ctx) > _mesa_init_lighting( ctx ); > _mesa_init_matrix( ctx ); > _mesa_init_multisample( ctx ); > + _mesa_init_performance_monitors( ctx ); > _mesa_init_pixel( ctx ); > _mesa_init_pixelstore( ctx ); > _mesa_init_point( ctx ); > diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h > index 8f3cd3d..60e7653 100644 > --- a/src/mesa/main/dd.h > +++ b/src/mesa/main/dd.h > @@ -646,6 +646,28 @@ struct dd_function_table { > void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q); > /*@}*/ > > + /** > + * \name Performance monitors > + */ > + /*@{*/ > + struct gl_perf_monitor_object * (*NewPerfMonitor)(void); > + void (*DeletePerfMonitor)(struct gl_perf_monitor_object *m); > + void (*BeginPerfMonitor)(struct gl_context *ctx, > + struct gl_perf_monitor_object *m); > + > + /** Stop an active performance monitor, discarding results. */ > + void (*ResetPerfMonitor)(struct gl_context *ctx, > + struct gl_perf_monitor_object *m); > + void (*EndPerfMonitor)(struct gl_context *ctx, > + struct gl_perf_monitor_object *m); > + GLboolean (*IsPerfMonitorResultAvailable)(struct gl_perf_monitor_object > *m); > + void (*GetPerfMonitorResult)(struct gl_context *ctx, > + struct gl_perf_monitor_object *m, > + GLsizei dataSize, > + GLuint *data, > + GLint *bytesWritten); > + /*@}*/ > + > > /** > * \name Vertex Array objects > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c > index c7f038b..16d3383 100644 > --- a/src/mesa/main/extensions.c > +++ b/src/mesa/main/extensions.c > @@ -287,6 +287,7 @@ static const struct extension extension_table[] = { > { "GL_AMD_draw_buffers_blend", > o(ARB_draw_buffers_blend), GL, 2009 }, > { "GL_AMD_seamless_cubemap_per_texture", > o(AMD_seamless_cubemap_per_texture), GL, 2009 }, > { "GL_AMD_shader_stencil_export", > o(ARB_shader_stencil_export), GL, 2009 }, > + { "GL_AMD_performance_monitor", > o(AMD_performance_monitor), GL, 2007 }, This one actually is in the wrong place. > { "GL_APPLE_object_purgeable", > o(APPLE_object_purgeable), GL, 2006 }, > { "GL_APPLE_packed_pixels", o(dummy_true), > GLL, 2002 }, > { "GL_APPLE_texture_max_level", o(dummy_true), > ES1 | ES2, 2009 }, > diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h > index e46fa39..892f8e8 100644 > --- a/src/mesa/main/mtypes.h > +++ b/src/mesa/main/mtypes.h > @@ -1774,6 +1774,87 @@ struct gl_transform_feedback_state > > > /** > + * 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; > +}; > + > + > +union gl_perf_monitor_counter_value > +{ > + float f; > + uint64_t u64; > + uint32_t u32; > +}; > + > + > +struct gl_perf_monitor_counter > +{ > + /** Human readable name for the counter. */ > + const char *Name; > + > + /** > + * Unique ID for the counter. > + * > + * Core mesa requests counter values from the driver using this ID; > + * most likely the driver will represent it using an enum of all possible > + * counters. > + */ > + unsigned ID; > + > + /** ID of the group this counter belongs to. */ > + unsigned GroupID; > + > + /** > + * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT, > + * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD. > + */ > + GLenum Type; > + > + /** Minimum counter value. */ > + union gl_perf_monitor_counter_value Minimum; > + > + /** Maximum counter value. */ > + union gl_perf_monitor_counter_value Maximum; > +}; > + > + > +struct gl_perf_monitor_group > +{ > + const char *Name; /**< Human readable name for the group. */ > + > + /** > + * Maximum number of counters in this group which can be active at the > + * same time. > + */ > + GLint MaxActiveCounters; > +}; > + > + > +/** > + * Context state for AMD_performance_monitor. > + */ > +struct gl_perf_monitor_state > +{ > + /** Array of performance monitor groups (indexed by group ID) */ > + const struct gl_perf_monitor_group *Groups; > + GLint NumGroups; > + > + /** Array of performance monitor counters (indexed by counter ID) */ > + const struct gl_perf_monitor_counter *Counters; > + GLint NumCounters; > + > + /** The table of all performance monitors. */ > + struct _mesa_HashTable *Monitors; > +}; > + > + > +/** > * Names of the various vertex/fragment program register files, etc. > * > * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) > @@ -3051,6 +3132,7 @@ struct gl_extensions > GLboolean EXT_vertex_array_bgra; > GLboolean OES_standard_derivatives; > /* vendor extensions */ > + GLboolean AMD_performance_monitor; > GLboolean AMD_seamless_cubemap_per_texture; > GLboolean APPLE_object_purgeable; > GLboolean ATI_envmap_bumpmap; > @@ -3520,6 +3602,8 @@ struct gl_context > > struct gl_transform_feedback_state TransformFeedback; > > + struct gl_perf_monitor_state PerfMonitor; > + > struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ > struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */ > > diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak > index 3c88108..565d1a5 100644 > --- a/src/mesa/sources.mak > +++ b/src/mesa/sources.mak > @@ -64,6 +64,7 @@ MAIN_FILES = \ > $(SRCDIR)main/multisample.c \ > $(SRCDIR)main/pack.c \ > $(SRCDIR)main/pbo.c \ > + $(SRCDIR)main/performance_monitor.c \ > $(SRCDIR)main/pixel.c \ > $(SRCDIR)main/pixelstore.c \ > $(SRCDIR)main/pixeltransfer.c \ > -- > 1.8.2.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev