diff options
author | Kyle Brenneman <[email protected]> | 2016-05-11 14:01:53 -0400 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2016-05-30 16:29:49 +0100 |
commit | 22a9e00aab66d3dd6890e9eaac3f429c0ddec17e (patch) | |
tree | cd4568b2381dd25cfa611bc6bc676016d89b6f2f /src/glx/glxglvnd.c | |
parent | cee459d84de7533d0e0a74a37f7fc4c0f2b77bcf (diff) |
glx: Implement the libglvnd interface.
With reference to the libglvnd branch:
https://cgit.freedesktop.org/mesa/mesa/log/?h=libglvnd
This is a squashed commit containing all of Kyle's commits, all but two
of Emil's commits (to follow), and a small fixup from myself to mark the
rest of the glX* functions as _GLX_PUBLIC so they are not exported when
building for libglvnd. I (ajax) squashed them together both for ease of
review, and because most of the changes are un-useful intermediate
states representing the evolution of glvnd's internal API.
Co-author: Emil Velikov <[email protected]>
Reviewed-by: Adam Jackson <[email protected]>
Diffstat (limited to 'src/glx/glxglvnd.c')
-rw-r--r-- | src/glx/glxglvnd.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/glx/glxglvnd.c b/src/glx/glxglvnd.c new file mode 100644 index 00000000000..c7c35ca3a14 --- /dev/null +++ b/src/glx/glxglvnd.c @@ -0,0 +1,75 @@ +#include <string.h> +#include <X11/Xlib.h> + +#include "glvnd/libglxabi.h" + +#include "glxglvnd.h" + + +static Bool __glXGLVNDIsScreenSupported(Display *dpy, int screen) +{ + /* TODO: Think of a better heuristic... */ + return True; +} + +static void *__glXGLVNDGetProcAddress(const GLubyte *procName) +{ + return glXGetProcAddressARB(procName); +} + +static int FindGLXFunction(const GLubyte *name) +{ + int i; + + for (i = 0; i < DI_FUNCTION_COUNT; i++) { + if (strcmp((const char *) name, __glXDispatchTableStrings[i]) == 0) + return i; + } + return -1; +} + +static void *__glXGLVNDGetDispatchAddress(const GLubyte *procName) +{ + int internalIndex = FindGLXFunction(procName); + + if (internalIndex >= 0) { + return __glXDispatchFunctions[internalIndex]; + } + + return NULL; +} + +static void __glXGLVNDSetDispatchIndex(const GLubyte *procName, int index) +{ + int internalIndex = FindGLXFunction(procName); + + if (internalIndex >= 0) + __glXDispatchTableIndices[internalIndex] = index; +} + +_X_EXPORT Bool __glx_Main(uint32_t version, const __GLXapiExports *exports, + __GLXvendorInfo *vendor, __GLXapiImports *imports) +{ + static Bool initDone = False; + + if (GLX_VENDOR_ABI_GET_MAJOR_VERSION(version) != + GLX_VENDOR_ABI_MAJOR_VERSION || + GLX_VENDOR_ABI_GET_MINOR_VERSION(version) < + GLX_VENDOR_ABI_MINOR_VERSION) + return False; + + if (!initDone) { + initDone = True; + __glXGLVNDAPIExports = exports; + + imports->isScreenSupported = __glXGLVNDIsScreenSupported; + imports->getProcAddress = __glXGLVNDGetProcAddress; + imports->getDispatchAddress = __glXGLVNDGetDispatchAddress; + imports->setDispatchIndex = __glXGLVNDSetDispatchIndex; + imports->notifyError = NULL; + imports->isPatchSupported = NULL; + imports->initiatePatch = NULL; + } + + return True; +} |