]> git.cworth.org Git - fips/commitdiff
Avoid trying to start a timer query within glBegin/glEnd
authorCarl Worth <cworth@cworth.org>
Fri, 24 May 2013 18:10:12 +0000 (11:10 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 30 May 2013 20:09:57 +0000 (13:09 -0700)
Instead, treat the entire sequence from glBegin..glEnd as a single drawing
operation and execute the timer query around the whole thing.

glwrap.c
libfips.sym

index beb1c97fd38cb05830e6ce1f37b9680c872804bc..a90ef8c4707b9f67f13de51495534aa6d6d5258a 100644 (file)
--- a/glwrap.c
+++ b/glwrap.c
@@ -332,10 +332,30 @@ 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. */
+void
+glBegin (GLenum mode)
+{
+       if (! inside_new_list)
+       {
+               unsigned counter;
+               counter = metrics_add_counter ();
+               glBeginQuery (GL_TIME_ELAPSED, counter);
+       }
+
+       GLWRAP_DEFER (glBegin, mode);
+}
+
 void
 glEnd (void)
 {
-       TIMED_DEFER (glEnd,);
+       GLWRAP_DEFER (glEnd);
+
+       if (! inside_new_list) {
+               glEndQuery (GL_TIME_ELAPSED);
+       }
 }
 
 void
index 773d9c3db2653c90aa35db332b02a7435eaf1008..6ad13377293c4210102fc31e85d46a48caa6542a 100644 (file)
@@ -34,6 +34,7 @@ global:
        glCallList;
        glCallLists;
        glClear;
+       glBegin;
        glEnd;
        glDrawPixels;
        glBlitFramebuffer;