summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/glvnd/GLdispatchABI.h21
-rw-r--r--include/glvnd/libglxabi.h2
-rw-r--r--src/GLdispatch/GLdispatch.c4
3 files changed, 26 insertions, 1 deletions
diff --git a/include/glvnd/GLdispatchABI.h b/include/glvnd/GLdispatchABI.h
index d16de2d..ab70361 100644
--- a/include/glvnd/GLdispatchABI.h
+++ b/include/glvnd/GLdispatchABI.h
@@ -138,6 +138,27 @@ typedef struct __GLdispatchPatchCallbacksRec {
* original state. The vendor library must not try to modify them.
*/
void (*releasePatch)(void);
+
+ /*!
+ * Called at the start of window-system functions (GLX and EGL). This
+ * callback allows vendor libraries to perform any per-thread
+ * initialization.
+ *
+ * This is basically a workaround for broken applications. A lot of apps
+ * will make one or more invalid GLX/EGL calls on a thread (often including
+ * a MakeCurrent with invalid parameters), and then will try to call an
+ * OpenGL function.
+ *
+ * A non-libglvnd-based driver would be able to initialize any thread state
+ * even on a bogus GLX call, but with libglvnd, those calls wouldn't get
+ * past libGLX.
+ *
+ * This function is optional. If it's \c NULL, then libGLdispatch will
+ * simply ignore it.
+ *
+ * \note This function may be called concurrently from multiple threads.
+ */
+ void (*threadAttach)(void);
} __GLdispatchPatchCallbacks;
#if defined(__cplusplus)
diff --git a/include/glvnd/libglxabi.h b/include/glvnd/libglxabi.h
index 3a59691..23b8303 100644
--- a/include/glvnd/libglxabi.h
+++ b/include/glvnd/libglxabi.h
@@ -91,7 +91,7 @@ extern "C" {
/*!
* Current version of the ABI.
*/
-#define GLX_VENDOR_ABI_VERSION 0
+#define GLX_VENDOR_ABI_VERSION 1
/*!
diff --git a/src/GLdispatch/GLdispatch.c b/src/GLdispatch/GLdispatch.c
index aecc3b4..f68c525 100644
--- a/src/GLdispatch/GLdispatch.c
+++ b/src/GLdispatch/GLdispatch.c
@@ -826,6 +826,10 @@ void __glDispatchCheckMultithreaded(void)
}
}
UnlockDispatch();
+
+ if (stubCurrentPatchCb != NULL && stubCurrentPatchCb->threadAttach != NULL) {
+ stubCurrentPatchCb->threadAttach();
+ }
}
}