libGLdispatch: Add a void* parameter to the getProcAddress callback.
The getProcAddress callback that libGLdispatch uses to populate the dispatch table now takes an extra parameter, which contains arbitrary data used by the callback. This allows much better flexibility in a how window system library populates a dispatch table.
This commit is contained in:
parent
735de93053
commit
a924afad34
|
@ -453,6 +453,12 @@ static GLboolean LookupVendorEntrypoints(__GLXvendorInfo *vendor)
|
|||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void *VendorGetProcAddressCallback(const char *procName, void *param)
|
||||
{
|
||||
__GLXvendorInfo *vendor = (__GLXvendorInfo *) param;
|
||||
return vendor->glxvc->getProcAddress((const GLubyte *) procName);
|
||||
}
|
||||
|
||||
__GLXvendorInfo *__glXLookupVendorByName(const char *vendorName)
|
||||
{
|
||||
__GLXvendorNameHash *pEntry = NULL;
|
||||
|
@ -543,7 +549,8 @@ __GLXvendorInfo *__glXLookupVendorByName(const char *vendorName)
|
|||
|
||||
vendor->glDispatch = (__GLdispatchTable *)
|
||||
__glDispatchCreateTable(
|
||||
vendor->glxvc->getProcAddress
|
||||
VendorGetProcAddressCallback,
|
||||
vendor
|
||||
);
|
||||
if (!vendor->glDispatch) {
|
||||
goto fail;
|
||||
|
|
|
@ -284,7 +284,8 @@ static void FixupDispatchTable(__GLdispatchTable *dispatch)
|
|||
assert(curProc->procName);
|
||||
|
||||
procAddr = (void*)(*dispatch->getProcAddress)(
|
||||
(const GLubyte *)curProc->procName);
|
||||
curProc->procName,
|
||||
dispatch->getProcAddressParam);
|
||||
|
||||
tbl[curProc->offset] = procAddr ? procAddr : (void *)noop_func;
|
||||
DBG_PRINTF(20, "extProc procName=%s, addr=%p, noop=%p\n",
|
||||
|
@ -355,7 +356,8 @@ PUBLIC __GLdispatchProc __glDispatchGetProcAddress(const char *procName)
|
|||
return addr;
|
||||
}
|
||||
|
||||
PUBLIC __GLdispatchTable *__glDispatchCreateTable(__GLgetProcAddressCallback getProcAddress)
|
||||
PUBLIC __GLdispatchTable *__glDispatchCreateTable(
|
||||
__GLgetProcAddressCallback getProcAddress, void *param)
|
||||
{
|
||||
__GLdispatchTable *dispatch = malloc(sizeof(__GLdispatchTable));
|
||||
|
||||
|
@ -364,6 +366,7 @@ PUBLIC __GLdispatchTable *__glDispatchCreateTable(__GLgetProcAddressCallback get
|
|||
dispatch->table = NULL;
|
||||
|
||||
dispatch->getProcAddress = getProcAddress;
|
||||
dispatch->getProcAddressParam = param;
|
||||
|
||||
return dispatch;
|
||||
}
|
||||
|
@ -383,7 +386,7 @@ PUBLIC void __glDispatchDestroyTable(__GLdispatchTable *dispatch)
|
|||
}
|
||||
|
||||
static struct _glapi_table
|
||||
*CreateGLAPITable(__GLgetProcAddressCallback getProcAddress)
|
||||
*CreateGLAPITable(__GLgetProcAddressCallback getProcAddress, void *param)
|
||||
{
|
||||
size_t entries = _glapi_get_dispatch_table_size();
|
||||
struct _glapi_table *table = (struct _glapi_table *)
|
||||
|
@ -394,7 +397,8 @@ static struct _glapi_table
|
|||
if (table) {
|
||||
_glapi_init_table_from_callback(table,
|
||||
entries,
|
||||
getProcAddress);
|
||||
getProcAddress,
|
||||
param);
|
||||
}
|
||||
|
||||
return table;
|
||||
|
@ -656,7 +660,8 @@ PUBLIC GLboolean __glDispatchMakeCurrent(__GLdispatchAPIState *apiState,
|
|||
|
||||
// Lazily create the dispatch table if we haven't already
|
||||
if (!dispatch->table) {
|
||||
dispatch->table = CreateGLAPITable(dispatch->getProcAddress);
|
||||
dispatch->table = CreateGLAPITable(dispatch->getProcAddress,
|
||||
dispatch->getProcAddressParam);
|
||||
}
|
||||
|
||||
FixupDispatchTable(dispatch);
|
||||
|
|
|
@ -58,6 +58,15 @@ enum {
|
|||
GLDISPATCH_API_EGL
|
||||
};
|
||||
|
||||
/*!
|
||||
* This opaque structure describes the core GL dispatch table.
|
||||
*/
|
||||
typedef struct __GLdispatchTableRec __GLdispatchTable;
|
||||
|
||||
typedef void (*__GLdispatchProc)(void);
|
||||
|
||||
typedef void *(*__GLgetProcAddressCallback)(const char *procName, void *param);
|
||||
|
||||
/**
|
||||
* An opaque structure used for internal API state data.
|
||||
*/
|
||||
|
@ -162,16 +171,14 @@ PUBLIC __GLdispatchProc __glDispatchGetProcAddress(const char *procName);
|
|||
* client GLX or EGL context, and is passed into GLdispatch during make current.
|
||||
* A dispatch table is owned by a particular vendor.
|
||||
*
|
||||
* \param [in] getProcAddress a vendor library callback GLdispatch can use to
|
||||
* \param[in] getProcAddress a vendor library callback GLdispatch can use to
|
||||
* query addresses of functions from the vendor. This callback also takes
|
||||
* a pointer to vendor-private data.
|
||||
* \param [in] destroyVendorData a vendor library callback to destroy private
|
||||
* data when the dispatch table is destroyed.
|
||||
* \param [in] vendorData a pointer to vendor library private data, which can
|
||||
* be used by the getProcAddress callback.
|
||||
* a pointer to caller-private data.
|
||||
* \param[in] param A pointer to pass to \p getProcAddress.
|
||||
*/
|
||||
PUBLIC __GLdispatchTable *__glDispatchCreateTable(
|
||||
__GLgetProcAddressCallback getProcAddress
|
||||
__GLgetProcAddressCallback getProcAddress,
|
||||
void *param
|
||||
);
|
||||
|
||||
/*!
|
||||
|
|
|
@ -44,15 +44,6 @@ extern "C" {
|
|||
* these client ABIs.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* This opaque structure describes the core GL dispatch table.
|
||||
*/
|
||||
typedef struct __GLdispatchTableRec __GLdispatchTable;
|
||||
|
||||
typedef void (*__GLdispatchProc)(void);
|
||||
|
||||
typedef void *(*__GLgetProcAddressCallback)(const GLubyte *procName);
|
||||
|
||||
/*
|
||||
* Thread-local implementation used by libglvnd. This is passed into
|
||||
* the patch function callback via the type parameter.
|
||||
|
|
|
@ -68,6 +68,7 @@ struct __GLdispatchTableRec {
|
|||
|
||||
/*! Saved vendor library callbacks */
|
||||
__GLgetProcAddressCallback getProcAddress;
|
||||
void *getProcAddressParam;
|
||||
|
||||
/*! The real dispatch table */
|
||||
struct _glapi_table *table;
|
||||
|
|
|
@ -113,7 +113,8 @@ __glapi_inittable_set_remaining_noop(struct _glapi_table *disp,
|
|||
void
|
||||
_glapi_init_table_from_callback(struct _glapi_table *table,
|
||||
size_t entries,
|
||||
void *(*get_proc_addr)(const unsigned char *name))
|
||||
void *(*get_proc_addr)(const char *name, void *param),
|
||||
void *param)
|
||||
{
|
||||
"""
|
||||
|
||||
|
@ -125,7 +126,7 @@ footer = """
|
|||
body_template = """
|
||||
if(!table->%(name)s) {
|
||||
void ** procp = (void **) &table->%(name)s;
|
||||
*procp = (*get_proc_addr)((const unsigned char *)"gl%(entry_point)s");
|
||||
*procp = (*get_proc_addr)("gl%(entry_point)s", param);
|
||||
}
|
||||
"""
|
||||
|
||||
|
|
|
@ -160,7 +160,8 @@ _glapi_get_proc_name(unsigned int offset);
|
|||
void
|
||||
_glapi_init_table_from_callback(struct _glapi_table *table,
|
||||
size_t entries,
|
||||
void *(*get_proc_addr)(const unsigned char *name));
|
||||
void *(*get_proc_addr)(const char *name, void *param),
|
||||
void *param);
|
||||
|
||||
/**
|
||||
* Functions used for patching entrypoints. These functions are exported from
|
||||
|
|
Loading…
Reference in a new issue