GLX: Change libGLX to use its own copy of the __GLXapiImports struct.

libGLX now allocates its own copy of the __GLXapiImports struct for each vendor
library. This is in preparation for providing an allocated and zeroed struct to
__glx_Main to fill in.
This commit is contained in:
Kyle Brenneman 2016-03-03 13:50:24 -07:00
parent 58d8dcaeb0
commit 3887b8e90e

View file

@ -104,6 +104,15 @@ typedef struct __GLXdispatchFuncHashRec {
*/
typedef struct __GLXvendorNameHashRec {
__GLXvendorInfo vendor;
/**
* The imports table for this vendor. This is allocated and zeroed by
* libGLX.so, so that we can add functions to the end without breaking
* backward compatibility.
*/
__GLXapiImports imports;
__GLdispatchPatchCallbacks patchCallbacks;
UT_hash_handle hh;
} __GLXvendorNameHash;
@ -472,6 +481,7 @@ __GLXvendorInfo *__glXLookupVendorByName(const char *vendorName)
__GLXvendorInfo *vendor;
__PFNGLXMAINPROC glxMainProc;
char *filename;
const __GLXapiImports *imports;
// Previously unseen vendor. dlopen() the new vendor and add it to the
// hash table.
@ -510,16 +520,33 @@ __GLXvendorInfo *__glXLookupVendorByName(const char *vendorName)
goto fail;
}
// Plug in the vendor imports table.
pEntry->imports.patchCallbacks = &pEntry->patchCallbacks;
vendor->glxvc = &pEntry->imports;
/* Initialize the dynamic dispatch table */
LKDHASH_INIT(vendor->dynDispatchHash);
vendor->glxvc = (*glxMainProc)(GLX_VENDOR_ABI_VERSION,
imports = (*glxMainProc)(GLX_VENDOR_ABI_VERSION,
&glxExportsTable,
vendor);
if (!vendor->glxvc) {
if (!imports) {
goto fail;
}
// Copy the imports table from the vendor library.
memcpy(&pEntry->imports, imports, sizeof(__GLXapiImports));
if (imports->patchCallbacks != NULL) {
memcpy(&pEntry->patchCallbacks, imports->patchCallbacks, sizeof(__GLdispatchPatchCallbacks));
}
// Set the patchCallbacks table.
if (pEntry->patchCallbacks.isPatchSupported != NULL
&& pEntry->patchCallbacks.initiatePatch != NULL) {
pEntry->imports.patchCallbacks = &pEntry->patchCallbacks;
} else {
pEntry->imports.patchCallbacks = NULL;
}
if (!LookupVendorEntrypoints(vendor)) {
goto fail;
}