libGLX: Rework the ABI for object-to-vendor mappings.
Change the functions in __GLXapiExports to map from objects (drawables, contexts, FBConfigs) to (screen, vendor) pairs. Internally, libGLX still uses an (object -> screen -> vendor) mapping, but now that's an implementation detail.
This commit is contained in:
parent
efcfd7eebf
commit
c0d23f55d3
|
@ -100,7 +100,7 @@ static void ThreadDestroyed(void *tsdCtx)
|
|||
LKDHASH_UNLOCK(__glXPthreadFuncs, __glXCurrentContextHash);
|
||||
|
||||
if (needsUnmap) {
|
||||
__glXRemoveScreenContextMapping(tsdCtx);
|
||||
__glXRemoveScreenContextMapping(NULL, tsdCtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -153,10 +153,11 @@ PUBLIC GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis,
|
|||
|
||||
const int screen = vis->screen;
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
|
||||
GLXContext context = pDispatch->glx14ep.createContext(dpy, vis, share_list, direct);
|
||||
|
||||
__glXAddScreenContextMapping(context, screen);
|
||||
__glXAddScreenContextMapping(dpy, context, screen, vendor);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
@ -181,10 +182,11 @@ PUBLIC GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *vis, Pixmap pixma
|
|||
|
||||
const int screen = vis->screen;
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
|
||||
GLXPixmap pmap = pDispatch->glx14ep.createGLXPixmap(dpy, vis, pixmap);
|
||||
|
||||
__glXAddScreenDrawableMapping(pmap, screen);
|
||||
__glXAddScreenDrawableMapping(dpy, pmap, screen, vendor);
|
||||
|
||||
return pmap;
|
||||
}
|
||||
|
@ -194,10 +196,9 @@ PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap pix)
|
|||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
const int screen = __glXScreenFromDrawable(dpy, pix);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetDrawableStaticDispatch(dpy, pix);
|
||||
|
||||
__glXRemoveScreenDrawableMapping(pix);
|
||||
__glXRemoveScreenDrawableMapping(dpy, pix);
|
||||
|
||||
pDispatch->glx14ep.destroyGLXPixmap(dpy, pix);
|
||||
}
|
||||
|
@ -343,7 +344,7 @@ void __glXNotifyContextDestroyed(GLXContext ctx)
|
|||
* Note: this implies a lock ordering: the current context
|
||||
* hash lock must be taken before the screen pointer hash lock!
|
||||
*/
|
||||
__glXRemoveScreenContextMapping(ctx);
|
||||
__glXRemoveScreenContextMapping(NULL, ctx);
|
||||
}
|
||||
|
||||
LKDHASH_UNLOCK(__glXPthreadFuncs, __glXCurrentContextHash);
|
||||
|
@ -631,8 +632,8 @@ static Bool MakeContextCurrentInternal(Display *dpy,
|
|||
* same screen if MakeCurrent passed, then record the mapping
|
||||
* of this drawable to the context's screen.
|
||||
*/
|
||||
__glXAddScreenDrawableMapping(draw, screen);
|
||||
__glXAddScreenDrawableMapping(read, screen);
|
||||
__glXAddScreenDrawableMapping(dpy, draw, screen, newVendor);
|
||||
__glXAddScreenDrawableMapping(dpy, read, screen, newVendor);
|
||||
|
||||
/*
|
||||
* Call into GLdispatch to set up the current context and
|
||||
|
@ -727,7 +728,7 @@ PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext contex
|
|||
tmpRet = UpdateCurrentContext(oldContext, NULL, oldContextNeedsUnmap, NULL);
|
||||
assert(tmpRet);
|
||||
} else if (oldContextNeedsUnmap) {
|
||||
__glXRemoveScreenContextMapping(oldContext);
|
||||
__glXRemoveScreenContextMapping(NULL, oldContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,8 +823,7 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
|
|||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
const int screen = __glXScreenFromDrawable(dpy, drawable);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetDrawableStaticDispatch(dpy, drawable);
|
||||
|
||||
pDispatch->glx14ep.swapBuffers(dpy, drawable);
|
||||
}
|
||||
|
@ -1118,13 +1118,14 @@ PUBLIC GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen,
|
|||
__glXThreadInitialize();
|
||||
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
GLXFBConfig *fbconfigs =
|
||||
pDispatch->glx14ep.chooseFBConfig(dpy, screen, attrib_list, nelements);
|
||||
int i;
|
||||
|
||||
if (fbconfigs != NULL) {
|
||||
for (i = 0; i < *nelements; i++) {
|
||||
__glXAddScreenFBConfigMapping(fbconfigs[i], screen);
|
||||
__glXAddScreenFBConfigMapping(dpy, fbconfigs[i], screen, vendor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1140,10 +1141,11 @@ PUBLIC GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config,
|
|||
|
||||
const int screen = __glXScreenFromFBConfig(config);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
|
||||
GLXContext context = pDispatch->glx14ep.createNewContext(dpy, config, render_type,
|
||||
share_list, direct);
|
||||
__glXAddScreenContextMapping(context, screen);
|
||||
__glXAddScreenContextMapping(dpy, context, screen, vendor);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
@ -1156,10 +1158,11 @@ PUBLIC GLXPbuffer glXCreatePbuffer(Display *dpy, GLXFBConfig config,
|
|||
|
||||
const int screen = __glXScreenFromFBConfig(config);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
|
||||
GLXPbuffer pbuffer = pDispatch->glx14ep.createPbuffer(dpy, config, attrib_list);
|
||||
|
||||
__glXAddScreenDrawableMapping(pbuffer, screen);
|
||||
__glXAddScreenDrawableMapping(dpy, pbuffer, screen, vendor);
|
||||
|
||||
return pbuffer;
|
||||
}
|
||||
|
@ -1172,11 +1175,12 @@ PUBLIC GLXPixmap glXCreatePixmap(Display *dpy, GLXFBConfig config,
|
|||
|
||||
const int screen = __glXScreenFromFBConfig(config);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
|
||||
GLXPixmap glxPixmap =
|
||||
pDispatch->glx14ep.createPixmap(dpy, config, pixmap, attrib_list);
|
||||
|
||||
__glXAddScreenDrawableMapping(glxPixmap, screen);
|
||||
__glXAddScreenDrawableMapping(dpy, glxPixmap, screen, vendor);
|
||||
|
||||
return glxPixmap;
|
||||
}
|
||||
|
@ -1189,11 +1193,12 @@ PUBLIC GLXWindow glXCreateWindow(Display *dpy, GLXFBConfig config,
|
|||
|
||||
const int screen = __glXScreenFromFBConfig(config);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
|
||||
GLXWindow glxWindow =
|
||||
pDispatch->glx14ep.createWindow(dpy, config, win, attrib_list);
|
||||
|
||||
__glXAddScreenDrawableMapping(glxWindow, screen);
|
||||
__glXAddScreenDrawableMapping(dpy, glxWindow, screen, vendor);
|
||||
|
||||
return glxWindow;
|
||||
}
|
||||
|
@ -1203,10 +1208,9 @@ PUBLIC void glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
|
|||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
const int screen = __glXScreenFromDrawable(dpy, pbuf);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetDrawableStaticDispatch(dpy, pbuf);
|
||||
|
||||
__glXRemoveScreenDrawableMapping(pbuf);
|
||||
__glXRemoveScreenDrawableMapping(dpy, pbuf);
|
||||
|
||||
pDispatch->glx14ep.destroyPbuffer(dpy, pbuf);
|
||||
}
|
||||
|
@ -1216,10 +1220,9 @@ PUBLIC void glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
|
|||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
const int screen = __glXScreenFromDrawable(dpy, pixmap);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetDrawableStaticDispatch(dpy, pixmap);
|
||||
|
||||
__glXRemoveScreenDrawableMapping(pixmap);
|
||||
__glXRemoveScreenDrawableMapping(dpy, pixmap);
|
||||
|
||||
pDispatch->glx14ep.destroyPixmap(dpy, pixmap);
|
||||
}
|
||||
|
@ -1229,10 +1232,9 @@ PUBLIC void glXDestroyWindow(Display *dpy, GLXWindow win)
|
|||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
const int screen = __glXScreenFromDrawable(dpy, win);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetDrawableStaticDispatch(dpy, win);
|
||||
|
||||
__glXRemoveScreenDrawableMapping(win);
|
||||
__glXRemoveScreenDrawableMapping(dpy, win);
|
||||
|
||||
pDispatch->glx14ep.destroyWindow(dpy, win);
|
||||
}
|
||||
|
@ -1265,11 +1267,12 @@ PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
|
|||
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
GLXFBConfig *fbconfigs = pDispatch->glx14ep.getFBConfigs(dpy, screen, nelements);
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
int i;
|
||||
|
||||
if (fbconfigs != NULL) {
|
||||
for (i = 0; i < *nelements; i++) {
|
||||
__glXAddScreenFBConfigMapping(fbconfigs[i], screen);
|
||||
__glXAddScreenFBConfigMapping(dpy, fbconfigs[i], screen, vendor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1282,8 +1285,7 @@ PUBLIC void glXGetSelectedEvent(Display *dpy, GLXDrawable draw,
|
|||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
const int screen = __glXScreenFromDrawable(dpy, draw);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetDrawableStaticDispatch(dpy, draw);
|
||||
|
||||
pDispatch->glx14ep.getSelectedEvent(dpy, draw, event_mask);
|
||||
}
|
||||
|
@ -1371,7 +1373,7 @@ PUBLIC Bool glXMakeContextCurrent(Display *dpy, GLXDrawable draw,
|
|||
tmpRet = UpdateCurrentContext(oldContext, NULL, oldContextNeedsUnmap, NULL);
|
||||
assert(tmpRet);
|
||||
} else if (oldContextNeedsUnmap) {
|
||||
__glXRemoveScreenContextMapping(oldContext);
|
||||
__glXRemoveScreenContextMapping(NULL, oldContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1397,8 +1399,7 @@ PUBLIC void glXQueryDrawable(Display *dpy, GLXDrawable draw,
|
|||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
const int screen = __glXScreenFromDrawable(dpy, draw);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetDrawableStaticDispatch(dpy, draw);
|
||||
|
||||
return pDispatch->glx14ep.queryDrawable(dpy, draw, attribute, value);
|
||||
}
|
||||
|
@ -1408,8 +1409,7 @@ PUBLIC void glXSelectEvent(Display *dpy, GLXDrawable draw, unsigned long event_m
|
|||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
const int screen = __glXScreenFromDrawable(dpy, draw);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetStaticDispatch(dpy, screen);
|
||||
const __GLXdispatchTableStatic *pDispatch = __glXGetDrawableStaticDispatch(dpy, draw);
|
||||
|
||||
pDispatch->glx14ep.selectEvent(dpy, draw, event_mask);
|
||||
}
|
||||
|
@ -1725,7 +1725,7 @@ void __glXThreadInitialize(void)
|
|||
void CurrentContextHashCleanup(void *unused, __GLXcurrentContextHash *pEntry)
|
||||
{
|
||||
if (pEntry->needsUnmap) {
|
||||
__glXRemoveScreenContextMapping(pEntry->ctx);
|
||||
__glXRemoveScreenContextMapping(NULL, pEntry->ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1835,9 +1835,10 @@ void _fini(void)
|
|||
__glDispatchFini();
|
||||
}
|
||||
|
||||
__GLXdispatchTableDynamic *__glXGetCurrentDynDispatch(void)
|
||||
__GLXvendorInfo *__glXGetCurrentDynDispatch(void)
|
||||
{
|
||||
__GLXAPIState *apiState = __glXGetCurrentAPIState();
|
||||
|
||||
return apiState->currentDynDispatch;
|
||||
//return apiState->currentDynDispatch;
|
||||
return apiState->currentVendor;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ extern "C" {
|
|||
* It is allocated at runtime by the API library. Vendor-provided dispatch
|
||||
* functions retrieve and operate on this structure using the API below.
|
||||
*/
|
||||
typedef struct __GLXdispatchTableDynamicRec __GLXdispatchTableDynamic;
|
||||
typedef struct __GLXvendorInfoRec __GLXvendorInfo;
|
||||
|
||||
/*!
|
||||
* Forward declaration for createGLDispatch export.
|
||||
|
@ -89,21 +89,21 @@ typedef struct __GLXapiExportsRec {
|
|||
* This fetches the appropriate dynamic GLX dispatch table given the display
|
||||
* and screen number.
|
||||
*/
|
||||
__GLXdispatchTableDynamic *(*getDynDispatch)(Display *dpy,
|
||||
__GLXvendorInfo *(*getDynDispatch)(Display *dpy,
|
||||
const int screen);
|
||||
|
||||
/*!
|
||||
* This function retrieves the appropriate current dynamic dispatch table,
|
||||
* if a GL context is current. Otherwise, this returns NULL.
|
||||
*/
|
||||
__GLXdispatchTableDynamic *(*getCurrentDynDispatch)(void);
|
||||
__GLXvendorInfo *(*getCurrentDynDispatch)(void);
|
||||
|
||||
/*!
|
||||
* This function retrieves an entry point from the dynamic dispatch table
|
||||
* given an index into the table.
|
||||
*/
|
||||
__GLXextFuncPtr (*fetchDispatchEntry)
|
||||
(__GLXdispatchTableDynamic *dynDispatch, int index);
|
||||
(__GLXvendorInfo *dynDispatch, int index);
|
||||
|
||||
/************************************************************************
|
||||
* This routine is used by the vendor to lookup its context structure.
|
||||
|
@ -121,17 +121,44 @@ typedef struct __GLXapiExportsRec {
|
|||
* and add mappings between various objects and screens.
|
||||
************************************************************************/
|
||||
|
||||
void (*addScreenContextMapping)(GLXContext context, int screen);
|
||||
void (*removeScreenContextMapping)(GLXContext context);
|
||||
int (*screenFromContext)(GLXContext context);
|
||||
void (*addScreenContextMapping)(Display *dpy, GLXContext context, int screen, __GLXvendorInfo *vendor);
|
||||
void (*removeScreenContextMapping)(Display *dpy, GLXContext context);
|
||||
|
||||
void (*addScreenFBConfigMapping)(GLXFBConfig config, int screen);
|
||||
void (*removeScreenFBConfigMapping)(GLXFBConfig config);
|
||||
int (*screenFromFBConfig)(GLXFBConfig config);
|
||||
/**
|
||||
* Looks up the screen and vendor for a context.
|
||||
*
|
||||
* If no mapping is found, then \p retScreen and \p retVendor will be set
|
||||
* to -1 and NULL, respectively.
|
||||
*
|
||||
* Either of \p retScreen or \p retVendor may be NULL if the screen or
|
||||
* vendor are not required.
|
||||
*
|
||||
* \param dpy The display connection.
|
||||
* \param context The context to look up.
|
||||
* \param[out] retScreen Returns the screen number.
|
||||
* \param[out] retVendor Returns the vendor.
|
||||
* \return Zero if a match was found, or non-zero if it was not.
|
||||
*/
|
||||
int (*vendorFromContext)(Display *dpy, GLXContext context, int *retScreen, __GLXvendorInfo **retVendor);
|
||||
|
||||
void (*addScreenDrawableMapping)(GLXDrawable drawable, int screen);
|
||||
void (*removeScreenDrawableMapping)(GLXDrawable drawable);
|
||||
int (*screenFromDrawable)(Display *dpy, GLXDrawable drawable);
|
||||
void (*addScreenFBConfigMapping)(Display *dpy, GLXFBConfig config, int screen, __GLXvendorInfo *vendor);
|
||||
void (*removeScreenFBConfigMapping)(Display *dpy, GLXFBConfig config);
|
||||
int (*vendorFromFBConfig)(Display *dpy, GLXFBConfig config, int *retScreen, __GLXvendorInfo **retVendor);
|
||||
|
||||
void (*addScreenDrawableMapping)(Display *dpy, GLXDrawable drawable, int screen, __GLXvendorInfo *vendor);
|
||||
void (*removeScreenDrawableMapping)(Display *dpy, GLXDrawable drawable);
|
||||
|
||||
/**
|
||||
* Looks up the screen and vendor for a drawable.
|
||||
*
|
||||
* If the server does not support the x11glvnd extension, then this
|
||||
* function may not be able to determine the screen number for a drawable.
|
||||
* In that case, it will return -1 for the screen number.
|
||||
*
|
||||
* Even without x11glvnd, this function will still return a vendor
|
||||
* suitable for indirect rendering.
|
||||
*/
|
||||
int (*vendorFromDrawable)(Display *dpy, GLXDrawable drawable, int *retScreen, __GLXvendorInfo **retVendor);
|
||||
|
||||
} __GLXapiExports;
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ static inline const __GLXdispatchTableStatic *__glXGetCurrentDispatch(void)
|
|||
* This gets the current GLX dynamic dispatch table, which is stored in the API
|
||||
* state.
|
||||
*/
|
||||
__GLXdispatchTableDynamic *__glXGetCurrentDynDispatch(void);
|
||||
__GLXvendorInfo *__glXGetCurrentDynDispatch(void);
|
||||
|
||||
/*!
|
||||
* This gets the current (vendor-specific) context, which is stored directly
|
||||
|
|
|
@ -206,12 +206,13 @@ __GLXextFuncPtr __glXGetGLXDispatchAddress(const GLubyte *procName)
|
|||
return addr;
|
||||
}
|
||||
|
||||
__GLXextFuncPtr __glXFetchDispatchEntry(__GLXdispatchTableDynamic *dynDispatch,
|
||||
__GLXextFuncPtr __glXFetchDispatchEntry(__GLXvendorInfo *vendor,
|
||||
int index)
|
||||
{
|
||||
__GLXextFuncPtr addr = NULL;
|
||||
__GLXdispatchFuncHash *pEntry;
|
||||
GLubyte *procName = NULL;
|
||||
__GLXdispatchTableDynamic *dynDispatch = vendor->dynDispatch;
|
||||
|
||||
LKDHASH_RDLOCK(__glXPthreadFuncs, dynDispatch->hash);
|
||||
|
||||
|
@ -284,15 +285,15 @@ static void InitExportsTable(void)
|
|||
|
||||
glxExportsTable.addScreenContextMapping = __glXAddScreenContextMapping;
|
||||
glxExportsTable.removeScreenContextMapping = __glXRemoveScreenContextMapping;
|
||||
glxExportsTable.screenFromContext = __glXScreenFromContext;
|
||||
glxExportsTable.vendorFromContext = __glXVendorFromContext;
|
||||
|
||||
glxExportsTable.addScreenFBConfigMapping = __glXAddScreenFBConfigMapping;
|
||||
glxExportsTable.removeScreenFBConfigMapping = __glXRemoveScreenFBConfigMapping;
|
||||
glxExportsTable.screenFromFBConfig = __glXScreenFromFBConfig;
|
||||
glxExportsTable.vendorFromFBConfig = __glXVendorFromFBConfig;
|
||||
|
||||
glxExportsTable.addScreenDrawableMapping = __glXAddScreenDrawableMapping;
|
||||
glxExportsTable.removeScreenDrawableMapping = __glXRemoveScreenDrawableMapping;
|
||||
glxExportsTable.screenFromDrawable = __glXScreenFromDrawable;
|
||||
glxExportsTable.vendorFromDrawable = __glXVendorFromDrawable;
|
||||
|
||||
}
|
||||
|
||||
|
@ -549,6 +550,13 @@ const __GLXdispatchTableStatic *__glXGetStaticDispatch(Display *dpy, const int s
|
|||
}
|
||||
}
|
||||
|
||||
const __GLXdispatchTableStatic * __glXGetDrawableStaticDispatch(Display *dpy,
|
||||
GLXDrawable drawable)
|
||||
{
|
||||
int screen = __glXScreenFromDrawable(dpy, drawable);
|
||||
return __glXGetStaticDispatch(dpy, screen);
|
||||
}
|
||||
|
||||
__GLdispatchTable *__glXGetGLDispatch(Display *dpy, const int screen)
|
||||
{
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
|
@ -561,24 +569,22 @@ __GLdispatchTable *__glXGetGLDispatch(Display *dpy, const int screen)
|
|||
}
|
||||
}
|
||||
|
||||
__GLXdispatchTableDynamic *__glXGetDynDispatch(Display *dpy, const int screen)
|
||||
__GLXvendorInfo *__glXGetDynDispatch(Display *dpy, const int screen)
|
||||
{
|
||||
__glXThreadInitialize();
|
||||
|
||||
__GLXvendorInfo *vendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
|
||||
if (vendor) {
|
||||
assert(vendor->dynDispatch);
|
||||
return vendor->dynDispatch;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
return vendor;
|
||||
}
|
||||
|
||||
__GLXdisplayInfo *__glXLookupDisplay(Display *dpy)
|
||||
{
|
||||
__GLXdisplayInfoHash *pEntry = NULL;
|
||||
|
||||
if (dpy == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LKDHASH_RDLOCK(__glXPthreadFuncs, __glXDisplayInfoHash);
|
||||
HASH_FIND_PTR(_LH(__glXDisplayInfoHash), &dpy, pEntry);
|
||||
LKDHASH_UNLOCK(__glXPthreadFuncs, __glXDisplayInfoHash);
|
||||
|
@ -712,14 +718,31 @@ static int ScreenFromPointer(void *ptr)
|
|||
return screen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common function for the various __glXVendorFrom* functions.
|
||||
*/
|
||||
static int CommonVendorFromScreen(Display *dpy, int screen, int *retScreen, __GLXvendorInfo **retVendor)
|
||||
{
|
||||
if (retScreen != NULL) {
|
||||
*retScreen = screen;
|
||||
}
|
||||
if (retVendor != NULL) {
|
||||
if (screen >= 0) {
|
||||
*retVendor = __glXLookupVendorByScreen(dpy, screen);
|
||||
} else {
|
||||
*retVendor = NULL;
|
||||
}
|
||||
}
|
||||
return (screen >= 0 ? 0 : -1);
|
||||
}
|
||||
|
||||
void __glXAddScreenContextMapping(GLXContext context, int screen)
|
||||
void __glXAddScreenContextMapping(Display *dpy, GLXContext context, int screen, __GLXvendorInfo *vendor)
|
||||
{
|
||||
AddScreenPointerMapping(context, screen);
|
||||
}
|
||||
|
||||
|
||||
void __glXRemoveScreenContextMapping(GLXContext context)
|
||||
void __glXRemoveScreenContextMapping(Display *dpy, GLXContext context)
|
||||
{
|
||||
RemoveScreenPointerMapping(context);
|
||||
}
|
||||
|
@ -730,14 +753,20 @@ int __glXScreenFromContext(GLXContext context)
|
|||
return ScreenFromPointer(context);
|
||||
}
|
||||
|
||||
int __glXVendorFromContext(Display *dpy, GLXContext context, int *retScreen, __GLXvendorInfo **retVendor)
|
||||
{
|
||||
int screen = ScreenFromPointer(context);
|
||||
return CommonVendorFromScreen(dpy, screen, retScreen, retVendor);
|
||||
}
|
||||
|
||||
void __glXAddScreenFBConfigMapping(GLXFBConfig config, int screen)
|
||||
|
||||
void __glXAddScreenFBConfigMapping(Display *dpy, GLXFBConfig config, int screen, __GLXvendorInfo *vendor)
|
||||
{
|
||||
AddScreenPointerMapping(config, screen);
|
||||
}
|
||||
|
||||
|
||||
void __glXRemoveScreenFBConfigMapping(GLXFBConfig config)
|
||||
void __glXRemoveScreenFBConfigMapping(Display *dpy, GLXFBConfig config)
|
||||
{
|
||||
RemoveScreenPointerMapping(config);
|
||||
}
|
||||
|
@ -748,6 +777,12 @@ int __glXScreenFromFBConfig(GLXFBConfig config)
|
|||
return ScreenFromPointer(config);
|
||||
}
|
||||
|
||||
int __glXVendorFromFBConfig(Display *dpy, GLXFBConfig config, int *retScreen, __GLXvendorInfo **retVendor)
|
||||
{
|
||||
int screen = ScreenFromPointer(config);
|
||||
return CommonVendorFromScreen(dpy, screen, retScreen, retVendor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -838,13 +873,13 @@ static int ScreenFromXID(Display *dpy, XID xid)
|
|||
}
|
||||
|
||||
|
||||
void __glXAddScreenDrawableMapping(GLXDrawable drawable, int screen)
|
||||
void __glXAddScreenDrawableMapping(Display *dpy, GLXDrawable drawable, int screen, __GLXvendorInfo *vendor)
|
||||
{
|
||||
AddScreenXIDMapping(drawable, screen);
|
||||
}
|
||||
|
||||
|
||||
void __glXRemoveScreenDrawableMapping(GLXDrawable drawable)
|
||||
void __glXRemoveScreenDrawableMapping(Display *dpy, GLXDrawable drawable)
|
||||
{
|
||||
RemoveScreenXIDMapping(drawable);
|
||||
}
|
||||
|
@ -855,6 +890,12 @@ int __glXScreenFromDrawable(Display *dpy, GLXDrawable drawable)
|
|||
return ScreenFromXID(dpy, drawable);
|
||||
}
|
||||
|
||||
int __glXVendorFromDrawable(Display *dpy, GLXDrawable drawable, int *retScreen, __GLXvendorInfo **retVendor)
|
||||
{
|
||||
int screen = ScreenFromXID(dpy, drawable);
|
||||
return CommonVendorFromScreen(dpy, screen, retScreen, retVendor);
|
||||
}
|
||||
|
||||
/*!
|
||||
* This handles freeing all mapping state during library teardown
|
||||
* or resetting locks on fork recovery.
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#define GLX_CLIENT_STRING_LAST_ATTRIB GLX_EXTENSIONS
|
||||
|
||||
typedef struct __GLXdispatchTableDynamicRec __GLXdispatchTableDynamic;
|
||||
|
||||
/*!
|
||||
* Structure containing relevant per-vendor information.
|
||||
*/
|
||||
|
@ -61,25 +63,34 @@ typedef struct __GLXdisplayInfoRec {
|
|||
*/
|
||||
const __GLXdispatchTableStatic * __glXGetStaticDispatch(Display *dpy,
|
||||
const int screen);
|
||||
__GLXdispatchTableDynamic *__glXGetDynDispatch(Display *dpy,
|
||||
__GLXvendorInfo *__glXGetDynDispatch(Display *dpy,
|
||||
const int screen);
|
||||
__GLdispatchTable *__glXGetGLDispatch(Display *dpy, const int screen);
|
||||
|
||||
__GLXvendorInfo *__glXGetDrawableDynDispatch(Display *dpy,
|
||||
GLXDrawable drawable);
|
||||
|
||||
const __GLXdispatchTableStatic * __glXGetDrawableStaticDispatch(Display *dpy,
|
||||
GLXDrawable drawable);
|
||||
|
||||
/*!
|
||||
* Various functions to manage mappings used to determine the screen
|
||||
* of a particular GLX call.
|
||||
*/
|
||||
void __glXAddScreenContextMapping(GLXContext context, int screen);
|
||||
void __glXRemoveScreenContextMapping(GLXContext context);
|
||||
void __glXAddScreenContextMapping(Display *dpy, GLXContext context, int screen, __GLXvendorInfo *vendor);
|
||||
void __glXRemoveScreenContextMapping(Display *dpy, GLXContext context);
|
||||
int __glXScreenFromContext(GLXContext context);
|
||||
int __glXVendorFromContext(Display *dpy, GLXContext context, int *retScreen, __GLXvendorInfo **retVendor);
|
||||
|
||||
void __glXAddScreenFBConfigMapping(GLXFBConfig config, int screen);
|
||||
void __glXRemoveScreenFBConfigMapping(GLXFBConfig config);
|
||||
void __glXAddScreenFBConfigMapping(Display *dpy, GLXFBConfig config, int screen, __GLXvendorInfo *vendor);
|
||||
void __glXRemoveScreenFBConfigMapping(Display *dpy, GLXFBConfig config);
|
||||
int __glXScreenFromFBConfig(GLXFBConfig config);
|
||||
int __glXVendorFromFBConfig(Display *dpy, GLXFBConfig config, int *retScreen, __GLXvendorInfo **retVendor);
|
||||
|
||||
void __glXAddScreenDrawableMapping(GLXDrawable drawable, int screen);
|
||||
void __glXRemoveScreenDrawableMapping(GLXDrawable drawable);
|
||||
void __glXAddScreenDrawableMapping(Display *dpy, GLXDrawable drawable, int screen, __GLXvendorInfo *vendor);
|
||||
void __glXRemoveScreenDrawableMapping(Display *dpy, GLXDrawable drawable);
|
||||
int __glXScreenFromDrawable(Display *dpy, GLXDrawable drawable);
|
||||
int __glXVendorFromDrawable(Display *dpy, GLXDrawable drawable, int *retScreen, __GLXvendorInfo **retVendor);
|
||||
|
||||
__GLXextFuncPtr __glXGetGLXDispatchAddress(const GLubyte *procName);
|
||||
|
||||
|
|
|
@ -398,7 +398,7 @@ static void dispatch_glXExampleExtensionFunction(Display *dpy,
|
|||
int screen,
|
||||
int *retval)
|
||||
{
|
||||
__GLXdispatchTableDynamic *dynDispatch;
|
||||
__GLXvendorInfo *dynDispatch;
|
||||
ExampleExtensionFunctionPtr func;
|
||||
const int index = dummyExampleExtensionFunctionIndex;
|
||||
|
||||
|
|
Loading…
Reference in a new issue