From a1f4664cf13657ffd1c7e3ff7c11142dec4e28e8 Mon Sep 17 00:00:00 2001 From: Allen Akin Date: Wed, 24 Jun 2009 10:19:03 -0700 Subject: Ensure GL command queues are empty If the implementation doesn't mark the GL command queue as empty after a glReadPixels command, this prevents GLXBadCurrentWindow errors from occurring on glXMakeCurrent commands issued after the window is destroyed. --- src/glean/tbinding.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/glean/tbinding.cpp b/src/glean/tbinding.cpp index 6aedd02..c73cfae 100644 --- a/src/glean/tbinding.cpp +++ b/src/glean/tbinding.cpp @@ -88,7 +88,6 @@ MakeCurrentTest::runOne(MakeCurrentResult& r, Window& w) { // The rendering contexts to be used: vector rcs; - // Short descriptions of the rendering contexts: RandomBitsDouble rRand(config.r, 712105); RandomBitsDouble gRand(config.g, 63230); @@ -153,8 +152,24 @@ failed: r.pass = false; cleanup: for (i = 0; i < static_cast(rcs.size()); ++i) - if (rcs[i]) + if (rcs[i]) { + // We need to make sure that no GL commands are + // pending when the window is destroyed, or we + // risk a GLXBadCurrentWindow error at some + // indeterminate time in the future when + // glXMakeCurrent() is executed. + // In theory, if glReadPixels() is the last + // command executed by a test, then an implicit + // flush has occurred, and the command queue is + // empty. In practice, we have to protect + // against the possibility that the implicit + // flush is not enough to avoid the error. + ws.makeCurrent(*rcs[i], w); + glFinish(); + ws.makeCurrent(); + delete rcs[i]; + } } // MakeCurrentTest::runOne /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3