X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glwrap.c;h=a7d62c5c1ef2be57d650591302923197c0fbb05f;hb=6014e77b9f7cf0570fe799fde240970a7cafb7ce;hp=323c321107c5d37dc7cd0775e0475afe431869c5;hpb=c10f5f0deb7723aa8462ce52e58f40c9490a8340;p=fips diff --git a/glwrap.c b/glwrap.c index 323c321..a7d62c5 100644 --- a/glwrap.c +++ b/glwrap.c @@ -19,12 +19,6 @@ * THE SOFTWARE. */ -#include "fips.h" - -#include "glwrap.h" - -#include "metrics.h" - /* The prototypes for some OpenGL functions changed at one point from: * * const void* *indices @@ -45,6 +39,12 @@ #define GL_GLEXT_PROTOTYPES #include +#include "fips.h" + +#include "glwrap.h" + +#include "metrics.h" + #include "dlwrap.h" static int inside_new_list = 0; @@ -67,16 +67,16 @@ glwrap_lookup (char *name) return dlwrap_real_dlsym (libgl_handle, name); } -/* Execute a glBeginQuery/glEndQuery pair around an OpenGL call. */ +/* Execute an OpenGL call and time it with a GPU metrics counter. */ #define TIMED_DEFER(function,...) do { \ if (! inside_new_list) { \ unsigned counter; \ - counter = metrics_add_counter (); \ - glBeginQuery (GL_TIME_ELAPSED, counter); \ + counter = metrics_counter_new (); \ + metrics_counter_start (counter); \ } \ GLWRAP_DEFER(function, __VA_ARGS__); \ if (! inside_new_list) { \ - glEndQuery (GL_TIME_ELAPSED); \ + metrics_counter_stop (); \ } \ } while (0); @@ -337,17 +337,18 @@ glClear (GLbitfield mask) TIMED_DEFER (glClear, mask); } -/* We can't just use TIMED_DEFER for glBegin/glEnd since the - * glBeginQuery/glEndQuery calls must both be outside - * glBegin/glEnd. */ +/* We can't just use TIMED_DEFER for glBegin/glEnd since the metrics + * counter must be started before glBegin and stopped after glEnd, + * (that is, everything from glBegin to glEnd is counted as a single + * operation). */ void glBegin (GLenum mode) { if (! inside_new_list) { unsigned counter; - counter = metrics_add_counter (); - glBeginQuery (GL_TIME_ELAPSED, counter); + counter = metrics_counter_new (); + metrics_counter_start (counter); } GLWRAP_DEFER (glBegin, mode); @@ -359,7 +360,7 @@ glEnd (void) GLWRAP_DEFER (glEnd); if (! inside_new_list) { - glEndQuery (GL_TIME_ELAPSED); + metrics_counter_stop (); } }