glx: Move vertex array protocol state into the indirect backend
authorAdam Jackson <ajax@redhat.com>
Tue, 14 Nov 2017 20:13:03 +0000 (15:13 -0500)
committerAdam Jackson <ajax@redhat.com>
Tue, 24 Sep 2019 00:21:01 +0000 (20:21 -0400)
Only relevant for indirect contexts, so let's get that code out of the
common path.

src/glx/glxcurrent.c
src/glx/indirect_glx.c

index 9c5d2af895639a380b536379352c1bb0a3a2fe5b..a388df7a78dc9017f47448daa191ed1cb72a7bb8 100644 (file)
@@ -245,18 +245,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
 
    __glXUnlock();
 
-   /* The indirect vertex array state must to be initialised after we
-    * have setup the context, as it needs to query server attributes.
-    */
-   if (gc && !gc->isDirect) {
-      __GLXattribute *state = gc->client_state_private;
-      if (state && state->array_state == NULL) {
-         glGetString(GL_EXTENSIONS);
-         glGetString(GL_VERSION);
-         __glXInitVertexArrayState(gc);
-      }
-   }
-
    return GL_TRUE;
 }
 
index d4a0b640ada5f1920d89ab5dc43e8b7eda4188cd..f370daf8bb6074111e8ad5ce03cc8bd16c2da0bc 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "glapi.h"
 #include "glxclient.h"
-
+#include "indirect.h"
 #include "util/debug.h"
 
 #ifndef GLX_USE_APPLEGL
@@ -148,9 +148,27 @@ indirect_bind_context(struct glx_context *gc, struct glx_context *old,
    sent = SendMakeCurrentRequest(dpy, gc->xid, tag, draw, read,
                                 &gc->currentContextTag);
 
-   if (!IndirectAPI)
-      IndirectAPI = __glXNewIndirectAPI();
-   _glapi_set_dispatch(IndirectAPI);
+   if (sent) {
+      if (!IndirectAPI)
+         IndirectAPI = __glXNewIndirectAPI();
+      _glapi_set_dispatch(IndirectAPI);
+
+      /* The indirect vertex array state must to be initialised after we
+       * have setup the context, as it needs to query server attributes.
+       *
+       * At the point this is called gc->currentDpy is not initialized
+       * nor is the thread's current context actually set. Hence the
+       * cleverness before the GetString calls.
+       */
+      __GLXattribute *state = gc->client_state_private;
+      if (state && state->array_state == NULL) {
+         gc->currentDpy = gc->psc->dpy;
+         __glXSetCurrentContext(gc);
+         __indirect_glGetString(GL_EXTENSIONS);
+         __indirect_glGetString(GL_VERSION);
+         __glXInitVertexArrayState(gc);
+      }
+   }
 
    return !sent;
 }