X-Git-Url: https://git.cworth.org/git?p=fips;a=blobdiff_plain;f=glwrap.c;h=8e8b64d193194aa8ffd7a127e00d59448d8f0a36;hp=a90ef8c4707b9f67f13de51495534aa6d6d5258a;hb=499af6e2043af80750f5b2a2866ebb430e085851;hpb=e7e5c4643bbf59b0df88356ef5c511ebe764ff58 diff --git a/glwrap.c b/glwrap.c index a90ef8c..8e8b64d 100644 --- a/glwrap.c +++ b/glwrap.c @@ -47,6 +47,8 @@ #include "dlwrap.h" +static int inside_new_list = 0; + void * glwrap_lookup (char *name) { @@ -65,13 +67,17 @@ glwrap_lookup (char *name) return dlwrap_real_dlsym (libgl_handle, name); } -/* Execute a glBegineQuery/glEndQuery pair around an OpenGL call. */ -#define TIMED_DEFER(function,...) do { \ - unsigned counter; \ - counter = metrics_add_counter (); \ - glBeginQuery (GL_TIME_ELAPSED, counter); \ - GLWRAP_DEFER(function, __VA_ARGS__); \ - glEndQuery (GL_TIME_ELAPSED); \ +/* Execute a glBeginQuery/glEndQuery pair around an OpenGL call. */ +#define TIMED_DEFER(function,...) do { \ + if (! inside_new_list) { \ + unsigned counter; \ + counter = metrics_add_counter (); \ + glBeginQuery (GL_TIME_ELAPSED, counter); \ + } \ + GLWRAP_DEFER(function, __VA_ARGS__); \ + if (! inside_new_list) { \ + glEndQuery (GL_TIME_ELAPSED); \ + } \ } while (0); /* Thanks to apitrace source code for the list of OpenGL draw calls. */ @@ -358,6 +364,22 @@ glEnd (void) } } +/* And we need to track display lists to avoid inserting queries + * inside the list while it's being constructed. */ +void +glNewList (GLuint list, GLenum mode) +{ + inside_new_list = 1; + GLWRAP_DEFER (glNewList, list, mode); +} + +void +glEndList (void) +{ + GLWRAP_DEFER (glEndList); + inside_new_list = 0; +} + void glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)