mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 15:48:36 +02:00
glx/glvnd: rework dispatch functions/indices tables lookup
Rather than checking if the function name maps to a valid entry in the respective table, just create a dummy entry at the end of each table. This allows us to remove some unnessesary "index >= 0" checks, which get executed quite often. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
parent
eab7e54981
commit
3bf00b6c6a
2 changed files with 13 additions and 13 deletions
|
|
@ -9,7 +9,8 @@
|
|||
#include "g_glxglvnddispatchindices.h"
|
||||
|
||||
const int DI_FUNCTION_COUNT = DI_LAST_INDEX;
|
||||
int __glXDispatchTableIndices[DI_LAST_INDEX];
|
||||
/* Allocate an extra 'dummy' to ease lookup. See FindGLXFunction() */
|
||||
int __glXDispatchTableIndices[DI_LAST_INDEX + 1];
|
||||
const __GLXapiExports *__glXGLVNDAPIExports;
|
||||
|
||||
const char * const __glXDispatchTableStrings[DI_LAST_INDEX] = {
|
||||
|
|
@ -922,7 +923,8 @@ static Bool dispatch_glXWaitForSbcOML(Display *dpy, GLXDrawable drawable,
|
|||
#undef __FETCH_FUNCTION_PTR
|
||||
|
||||
|
||||
const void * const __glXDispatchFunctions[DI_LAST_INDEX] = {
|
||||
/* Allocate an extra 'dummy' to ease lookup. See FindGLXFunction() */
|
||||
const void * const __glXDispatchFunctions[DI_LAST_INDEX + 1] = {
|
||||
#define __ATTRIB(field) \
|
||||
[DI_##field] = (void *)dispatch_##field
|
||||
|
||||
|
|
@ -972,5 +974,6 @@ const void * const __glXDispatchFunctions[DI_LAST_INDEX] = {
|
|||
__ATTRIB(glXWaitForMscOML),
|
||||
__ATTRIB(glXWaitForSbcOML),
|
||||
|
||||
[DI_LAST_INDEX] = NULL,
|
||||
#undef __ATTRIB
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ static void *__glXGLVNDGetProcAddress(const GLubyte *procName)
|
|||
return glXGetProcAddressARB(procName);
|
||||
}
|
||||
|
||||
static int FindGLXFunction(const GLubyte *name)
|
||||
static unsigned FindGLXFunction(const GLubyte *name)
|
||||
{
|
||||
unsigned first = 0;
|
||||
unsigned last = DI_FUNCTION_COUNT - 1;
|
||||
|
|
@ -34,26 +34,23 @@ static int FindGLXFunction(const GLubyte *name)
|
|||
else
|
||||
return middle;
|
||||
}
|
||||
return -1;
|
||||
|
||||
/* Just point to the dummy entry at the end of the respective table */
|
||||
return DI_FUNCTION_COUNT;
|
||||
}
|
||||
|
||||
static void *__glXGLVNDGetDispatchAddress(const GLubyte *procName)
|
||||
{
|
||||
int internalIndex = FindGLXFunction(procName);
|
||||
unsigned internalIndex = FindGLXFunction(procName);
|
||||
|
||||
if (internalIndex >= 0) {
|
||||
return __glXDispatchFunctions[internalIndex];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return __glXDispatchFunctions[internalIndex];
|
||||
}
|
||||
|
||||
static void __glXGLVNDSetDispatchIndex(const GLubyte *procName, int index)
|
||||
{
|
||||
int internalIndex = FindGLXFunction(procName);
|
||||
unsigned internalIndex = FindGLXFunction(procName);
|
||||
|
||||
if (internalIndex >= 0)
|
||||
__glXDispatchTableIndices[internalIndex] = index;
|
||||
__glXDispatchTableIndices[internalIndex] = index;
|
||||
}
|
||||
|
||||
_X_EXPORT Bool __glx_Main(uint32_t version, const __GLXapiExports *exports,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue