[PATCH 2/3] glx: Flush context which is being made non-current due to drawable going away

Jon TURNEY jon.turney at dronecode.org.uk
Fri Apr 18 04:17:05 PDT 2014


Some sequences of glean tests fail with GLXBadCurrentWindow when using indirect
rendering, e.g. glean -t 'fpexceptions getString'.

Flush a context which is being made non-current due to the drawable on which is
it is current going away.  Waiting until another context is made current is too
late, as the drawable no longer exists.

v2: Rewrite for direct GL dispatch

e.g. LIBGL_ALWAYS_INDIRECT=1  ./glean -r results -o --quick -t "fpexceptions
getString" fails with a BadContextTag error.

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 glx/glxcmds.c    | 7 +++++++
 glx/glxcontext.h | 2 ++
 glx/glxext.c     | 1 +
 3 files changed, 10 insertions(+)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index f447e06..80b2361 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -213,6 +213,13 @@ __glXdirectContextCreate(__GLXscreen * screen,
     return context;
 }
 
+void
+FlushContext(__GLXcontext * cx)
+{
+    glFlush();
+    cx->hasUnflushedCommands = GL_FALSE;
+}
+
 /**
  * Create a GL context with the given properties.  This routine is used
  * to implement \c glXCreateContext, \c glXCreateNewContext, and
diff --git a/glx/glxcontext.h b/glx/glxcontext.h
index 677898a..c7cca0b 100644
--- a/glx/glxcontext.h
+++ b/glx/glxcontext.h
@@ -138,4 +138,6 @@ extern __GLXcontext *__glXdirectContextCreate(__GLXscreen * screen,
                                               __GLXconfig * modes,
                                               __GLXcontext * shareContext);
 
+extern void FlushContext(__GLXcontext * cx);
+
 #endif                          /* !__GLX_context_h__ */
diff --git a/glx/glxext.c b/glx/glxext.c
index c9b8cc5..8c837b0 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -140,6 +140,7 @@ DrawableGone(__GLXdrawable * glxPriv, XID xid)
         if (c->currentClient &&
 		(c->drawPriv == glxPriv || c->readPriv == glxPriv)) {
             /* just force a re-bind the next time through */
+            FlushContext(c);
             (*c->loseCurrent) (c);
             if (c == __glXLastContext)
                 __glXFlushContextCache();
-- 
1.8.5.5



More information about the xorg-devel mailing list