From e7e5c4643bbf59b0df88356ef5c511ebe764ff58 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 24 May 2013 11:10:12 -0700 Subject: [PATCH] Avoid trying to start a timer query within glBegin/glEnd Instead, treat the entire sequence from glBegin..glEnd as a single drawing operation and execute the timer query around the whole thing. --- glwrap.c | 22 +++++++++++++++++++++- libfips.sym | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/glwrap.c b/glwrap.c index beb1c97..a90ef8c 100644 --- 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 diff --git a/libfips.sym b/libfips.sym index 773d9c3..6ad1337 100644 --- a/libfips.sym +++ b/libfips.sym @@ -34,6 +34,7 @@ global: glCallList; glCallLists; glClear; + glBegin; glEnd; glDrawPixels; glBlitFramebuffer; -- 2.43.0