/* * Copyright (c) 2013, NVIDIA CORPORATION. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * unaltered in all copies or substantial portions of the Materials. * Any additions, deletions, or changes to the original source files * must be clearly indicated in accompanying documentation. * * If only executable code is distributed, then the accompanying * documentation must state that "this software is based in part on the * work of the Khronos Group." * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ #if !defined(__LIB_GLX_MAPPING_H) #define __LIB_GLX_MAPPING_H #include "libglxabipriv.h" #include "GLdispatch.h" #include "lkdhash.h" #define GLX_CLIENT_STRING_LAST_ATTRIB GLX_EXTENSIONS typedef struct __GLXdispatchTableDynamicRec __GLXdispatchTableDynamic; /*! * Structure containing relevant per-vendor information. */ struct __GLXvendorInfoRec { int vendorID; //< unique GLdispatch ID char *name; //< name of the vendor void *dlhandle; //< shared library handle __GLXdispatchTableDynamic *dynDispatch; //< dynamic GLX dispatch table __GLdispatchTable *glDispatch; //< GL dispatch table const __GLXapiImports *glxvc; __GLXdispatchTableStatic staticDispatch; //< static GLX dispatch table }; typedef struct __GLXscreenXIDMappingHashRec __GLXscreenXIDMappingHash; /*! * Structure containing per-display information. */ typedef struct __GLXdisplayInfoRec { char *clientStrings[GLX_CLIENT_STRING_LAST_ATTRIB]; /** * An array of vendors for each screen. * * Do not access this directly. Instead, call \c __glXLookupVendorByScreen. */ __GLXvendorInfo **vendors; glvnd_rwlock_t vendorLock; DEFINE_LKDHASH(__GLXscreenXIDMappingHash, xidScreenHash); /// True if the server supports the GLX extension. Bool glxSupported; /// The major opcode for GLX, if it's supported. int glxMajorOpcode; int glxFirstError; Bool x11glvndSupported; int x11glvndMajor; int x11glvndMinor; } __GLXdisplayInfo; /*! * Accessor functions used to retrieve the "current" dispatch table for each of * the three types of dispatch tables (see libglxabi.h for an explanation of * these types). */ const __GLXdispatchTableStatic * __glXGetStaticDispatch(Display *dpy, const int screen); __GLXvendorInfo *__glXGetDynDispatch(Display *dpy, const int screen); __GLdispatchTable *__glXGetGLDispatch(Display *dpy, const int screen); /*! * Various functions to manage mappings used to determine the screen * of a particular GLX call. */ void __glXAddVendorContextMapping(Display *dpy, GLXContext context, __GLXvendorInfo *vendor); void __glXRemoveVendorContextMapping(Display *dpy, GLXContext context); int __glXVendorFromContext(GLXContext context, __GLXvendorInfo **retVendor); void __glXAddVendorFBConfigMapping(Display *dpy, GLXFBConfig config, __GLXvendorInfo *vendor); void __glXRemoveVendorFBConfigMapping(Display *dpy, GLXFBConfig config); int __glXVendorFromFBConfig(Display *dpy, GLXFBConfig config, __GLXvendorInfo **retVendor); void __glXAddScreenVisualMapping(Display *dpy, const XVisualInfo *visual, __GLXvendorInfo *vendor); void __glXRemoveScreenVisualMapping(Display *dpy, const XVisualInfo *visual); int __glXVendorFromVisual(Display *dpy, const XVisualInfo *visual, __GLXvendorInfo **retVendor); void __glXAddVendorDrawableMapping(Display *dpy, GLXDrawable drawable, __GLXvendorInfo *vendor); void __glXRemoveVendorDrawableMapping(Display *dpy, GLXDrawable drawable); int __glXVendorFromDrawable(Display *dpy, GLXDrawable drawable, __GLXvendorInfo **retVendor); __GLXextFuncPtr __glXGetGLXDispatchAddress(const GLubyte *procName); __GLXextFuncPtr __glXGenerateGLXEntrypoint(const GLubyte *procName); /*! * Looks up the vendor by name or screen number. This has the side effect of * loading the vendor library if it has not been previously loaded. */ __GLXvendorInfo *__glXLookupVendorByName(const char *vendorName); __GLXvendorInfo *__glXLookupVendorByScreen(Display *dpy, const int screen); /*! * Looks up the __GLXdisplayInfo structure for a display, creating it if * necessary. */ __GLXdisplayInfo *__glXLookupDisplay(Display *dpy); /*! * Frees the __GLXdisplayInfo structure for a display, if one exists. */ void __glXFreeDisplay(Display *dpy); /*! * Notifies libglvnd that a context has been marked for destruction. */ void __glXNotifyContextDestroyed(GLXContext ctx); /* * Close the vendor library and perform any relevant teardown. This should * be called when the API library is unloaded. */ void __glXMappingTeardown(Bool doReset); #endif /* __LIB_GLX_MAPPING_H */