[PATCH 03/12] glx: Move GLX MakeCurrent lastGLContext updates next to makeCurrent().

Eric Anholt eric at anholt.net
Fri Apr 18 11:40:01 PDT 2014


We want to make sure that lastGLContext is set correctly during
makeCurrent, because we may have recursive GL context changes in the
DRI2 interfaces due to glamor.

Signed-off-by: Eric Anholt <eric at anholt.net>
---
 glx/glxcmds.c | 6 ++----
 glx/glxext.c  | 3 ++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index a451d2b..fb236b6 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -434,9 +434,6 @@ static void
 StopUsingContext(__GLXcontext * glxc)
 {
     if (glxc) {
-        if (glxc == lastGLContext) {
-            lastGLContext = NULL;
-        }
         glxc->currentClient = NULL;
         if (!glxc->idExists) {
             FreeResourceByType(glxc->id, __glXContextRes, FALSE);
@@ -447,7 +444,6 @@ StopUsingContext(__GLXcontext * glxc)
 static void
 StartUsingContext(__GLXclientState * cl, __GLXcontext * glxc)
 {
-    lastGLContext = glxc;
     glxc->currentClient = cl->client;
 }
 
@@ -639,7 +635,9 @@ DoMakeCurrent(__GLXclientState * cl,
         glxc->readPriv = readPriv;
 
         /* make the context current */
+        lastGLContext = glxc;
         if (!(*glxc->makeCurrent) (glxc)) {
+            lastGLContext = NULL;
             glxc->drawPriv = NULL;
             glxc->readPriv = NULL;
             return __glXError(GLXBadContext);
diff --git a/glx/glxext.c b/glx/glxext.c
index 85fd219..9855767 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -444,14 +444,15 @@ __glXForceCurrent(__GLXclientState * cl, GLXContextTag tag, int *error)
 
     /* Make this context the current one for the GL. */
     if (!cx->isDirect) {
+        lastGLContext = cx;
         if (!(*cx->makeCurrent) (cx)) {
             /* Bind failed, and set the error code.  Bummer */
+            lastGLContext = NULL;
             cl->client->errorValue = cx->id;
             *error = __glXError(GLXBadContextState);
             return 0;
         }
     }
-    lastGLContext = cx;
     return cx;
 }
 
-- 
1.9.2



More information about the xorg-devel mailing list