X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fglapi%2Fglapi.c;h=47a1f164582fb77de2d52f435eb43e93b28814aa;hb=711555d1e347f0e64e6b1b2d0e402e0ee72ace07;hp=7d0ceb50924f926380031ae7285e41522b6b267f;hpb=d7361e171738d92af6b4201d69faea0c55c2601c;p=mesa.git diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 7d0ceb50924..47a1f164582 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -1,10 +1,8 @@ -/* $Id: glapi.c,v 1.39 2000/03/27 21:13:58 rjfrank Exp $ */ - /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 6.3 * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -37,64 +35,247 @@ * flexible enough to be reused in several places: XFree86, DRI- * based libGL.so, and perhaps the SGI SI. * - * There are no dependencies on Mesa in this code. + * NOTE: There are no dependencies on Mesa in this code. + * + * Versions (API changes): + * 2000/02/23 - original version for Mesa 3.3 and XFree86 4.0 + * 2001/01/16 - added dispatch override feature for Mesa 3.5 + * 2002/06/28 - added _glapi_set_warning_func(), Mesa 4.1. + * 2002/10/01 - _glapi_get_proc_address() will now generate new entrypoints + * itself (using offset ~0). _glapi_add_entrypoint() can be + * called afterward and it'll fill in the correct dispatch + * offset. This allows DRI libGL to avoid probing for DRI + * drivers! No changes to the public glapi interface. */ #include "glheader.h" #include "glapi.h" -#include "glapinoop.h" #include "glapioffsets.h" #include "glapitable.h" #include "glthread.h" +/***** BEGIN NO-OP DISPATCH *****/ -/* This is used when thread safety is disabled */ -struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table; +static GLboolean WarnFlag = GL_FALSE; +static _glapi_warning_func warning_func; -/* Used when thread safety disabled */ -void *_glapi_Context = NULL; +static void init_glapi_relocs(void); + +static _glapi_proc generate_entrypoint(GLuint functionOffset); +static void fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset); + +/* + * Enable/disable printing of warning messages. + */ +PUBLIC void +_glapi_noop_enable_warnings(GLboolean enable) +{ + WarnFlag = enable; +} + +/* + * Register a callback function for reporting errors. + */ +PUBLIC void +_glapi_set_warning_func( _glapi_warning_func func ) +{ + warning_func = func; +} + +static GLboolean +warn(void) +{ + if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) + && warning_func) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + +#define KEYWORD1 static +#define KEYWORD2 GLAPIENTRY +#define NAME(func) NoOp##func + +#define F NULL + +#define DISPATCH(func, args, msg) \ + if (warn()) { \ + warning_func(NULL, "GL User Error: called without context: %s", #func); \ + } +#define RETURN_DISPATCH(func, args, msg) \ + if (warn()) { \ + warning_func(NULL, "GL User Error: called without context: %s", #func); \ + } \ + return 0 + +#define DISPATCH_TABLE_NAME __glapi_noop_table +#define UNUSED_TABLE_NAME __unused_noop_functions + +#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name + +static GLint NoOpUnused(void) +{ + if (warn()) { + warning_func(NULL, "GL User Error: calling extension function without a current context\n"); + } + return 0; +} + +#include "glapitemp.h" + +/***** END NO-OP DISPATCH *****/ + + + +/***** BEGIN THREAD-SAFE DISPATCH *****/ #if defined(THREADS) -/* Flag to indicate whether thread-safe dispatch is enabled */ -static GLboolean ThreadSafe = GL_FALSE; +#if defined(GLX_USE_TLS) + +__thread struct _glapi_table * _glapi_tls_Dispatch + __attribute__((tls_model("initial-exec"))) + = (struct _glapi_table *) __glapi_noop_table; + +static __thread struct _glapi_table * _glapi_tls_RealDispatch + __attribute__((tls_model("initial-exec"))) + = (struct _glapi_table *) __glapi_noop_table; + +__thread void * _glapi_tls_Context + __attribute__((tls_model("initial-exec"))); + +/** + * Legacy per-thread dispatch pointer. This is only needed to support + * non-TLS DRI drivers. + */ + +_glthread_TSD _gl_DispatchTSD; + +#else + +/** + * \name Multi-threaded control support variables + * + * If thread-safety is supported, there are two potential mechanisms that can + * be used. The old-style mechanism would set \c _glapi_Dispatch to a special + * thread-safe dispatch table. These dispatch routines would call + * \c _glapi_get_dispatch to get the actual dispatch pointer. In this + * setup \c _glapi_Dispatch could never be \c NULL. This dual layered + * dispatch setup performed great for single-threaded apps, but didn't + * perform well for multithreaded apps. + * + * In the new mechansim, there are two variables. The first is + * \c _glapi_DispatchTSD. In the single-threaded case, this variable points + * to the dispatch table. In the multi-threaded case, this variable is + * \c NULL, and thread-specific variable \c _gl_DispatchTSD points to the + * actual dispatch table. \c _glapi_DispatchTSD is used to signal to the + * static dispatch functions to call \c _glapi_get_dispatch to get the real + * dispatch table. + * + * There is a race condition in setting \c _glapi_DispatchTSD to \c NULL. + * It is possible for the original thread to be setting it at the same instant + * a new thread, perhaps running on a different processor, is clearing it. + * Because of that, \c ThreadSafe, which can only ever be changed to + * \c GL_TRUE, is used to determine whether or not the application is + * multithreaded. + */ +/*@{*/ +static GLboolean ThreadSafe = GL_FALSE; /**< In thread-safe mode? */ +_glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */ +static _glthread_TSD RealDispatchTSD; /**< only when using override */ +static _glthread_TSD ContextTSD; /**< Per-thread context pointer */ +/*@}*/ + +#endif /* defined(GLX_USE_TLS) */ -static _glthread_TSD DispatchTSD; +#define DISPATCH_TABLE_NAME __glapi_threadsafe_table +#define UNUSED_TABLE_NAME __unused_threadsafe_functions -static _glthread_TSD ContextTSD; +#define TABLE_ENTRY(name) (_glapi_proc) gl##name + +static GLint glUnused(void) +{ + return 0; +} + +#include "glapitemp.h" #endif +/***** END THREAD-SAFE DISPATCH *****/ + +#if defined(GLX_USE_TLS) -static GLuint MaxDispatchOffset = sizeof(struct _glapi_table) / sizeof(void *) - 1; -static GLboolean GetSizeCalled = GL_FALSE; +/** + * \name Old dispatch pointers + * + * Very old DRI based drivers assume that \c _glapi_Dispatch will never be + * \c NULL. Becuase of that, special "thread-safe" dispatch functions are + * needed here. Slightly more recent drivers detect the multi-threaded case + * by \c _glapi_DispatchTSD being \c NULL. + * + * \deprecated + * + * \warning + * \c _glapi_RealDispatch does not exist in TLS builds. I don't think it was + * ever used outside libGL.so, so this should be safe. + */ +/*@{*/ +PUBLIC const struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_threadsafe_table; +PUBLIC const struct _glapi_table *_glapi_DispatchTSD = NULL; +PUBLIC const void *_glapi_Context = NULL; +/*@}*/ + +#else + +PUBLIC struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table; +#if defined( THREADS ) +PUBLIC struct _glapi_table *_glapi_DispatchTSD = (struct _glapi_table *) __glapi_noop_table; +#endif +PUBLIC struct _glapi_table *_glapi_RealDispatch = (struct _glapi_table *) __glapi_noop_table; -/* strdup is actually not a standard ANSI C or POSIX routine - Irix will not define it if ANSI mode is in effect. */ -static char *mesaStrdup(const char *str) +/* Used when thread safety disabled */ +PUBLIC void *_glapi_Context = NULL; + +#endif /* defined(GLX_USE_TLS) */ + + +static GLboolean DispatchOverride = GL_FALSE; + + + +/** + * strdup() is actually not a standard ANSI C or POSIX routine. + * Irix will not define it if ANSI mode is in effect. + */ +static char * +str_dup(const char *str) { - char *copy; - copy = (char*) malloc(strlen(str) + 1); - if (!copy) return(NULL); - strcpy(copy,str); - return(copy); + char *copy; + copy = (char*) malloc(strlen(str) + 1); + if (!copy) + return NULL; + strcpy(copy, str); + return copy; } -/* +/** * We should call this periodically from a function such as glXMakeCurrent - * in order to test if multiple threads are being used. When we detect - * that situation we should then call _glapi_enable_thread_safety() + * in order to test if multiple threads are being used. */ -void +PUBLIC void _glapi_check_multithread(void) { -#if defined(THREADS) +#if defined(THREADS) && !defined(GLX_USE_TLS) if (!ThreadSafe) { static unsigned long knownID; static GLboolean firstCall = GL_TRUE; @@ -104,33 +285,33 @@ _glapi_check_multithread(void) } else if (knownID != _glthread_GetID()) { ThreadSafe = GL_TRUE; + _glapi_set_dispatch(NULL); } } - if (ThreadSafe) { + else if (!_glapi_get_dispatch()) { /* make sure that this thread's dispatch pointer isn't null */ - if (!_glapi_get_dispatch()) { - _glapi_set_dispatch(NULL); - } + _glapi_set_dispatch(NULL); } #endif } -/* +/** * Set the current context pointer for this thread. * The context pointer is an opaque type which should be cast to * void from the real context pointer type. */ -void +PUBLIC void _glapi_set_context(void *context) { -#if defined(THREADS) + (void) __unused_noop_functions; /* silence a warning */ +#if defined(GLX_USE_TLS) + _glapi_tls_Context = context; +#elif defined(THREADS) + (void) __unused_threadsafe_functions; /* silence a warning */ _glthread_SetTSD(&ContextTSD, context); - if (ThreadSafe) - _glapi_Context = NULL; - else - _glapi_Context = context; + _glapi_Context = (ThreadSafe) ? NULL : context; #else _glapi_Context = context; #endif @@ -138,15 +319,17 @@ _glapi_set_context(void *context) -/* +/** * Get the current context pointer for this thread. * The context pointer is an opaque type which should be cast from * void to the real context pointer type. */ -void * +PUBLIC void * _glapi_get_context(void) { -#if defined(THREADS) +#if defined(GLX_USE_TLS) + return _glapi_tls_Context; +#elif defined(THREADS) if (ThreadSafe) { return _glthread_GetTSD(&ContextTSD); } @@ -160,12 +343,19 @@ _glapi_get_context(void) -/* +/** * Set the global or per-thread dispatch table pointer. */ -void +PUBLIC void _glapi_set_dispatch(struct _glapi_table *dispatch) { +#if defined(PTHREADS) || defined(GLX_USE_TLS) + static pthread_once_t once_control = PTHREAD_ONCE_INIT; + + + pthread_once( & once_control, init_glapi_relocs ); +#endif + if (!dispatch) { /* use the no-op functions */ dispatch = (struct _glapi_table *) __glapi_noop_table; @@ -176,32 +366,76 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) } #endif -#if defined(THREADS) - _glthread_SetTSD(&DispatchTSD, (void*) dispatch); - if (ThreadSafe) - _glapi_Dispatch = NULL; - else +#if defined(GLX_USE_TLS) + if (DispatchOverride) { + _glapi_tls_RealDispatch = dispatch; + } + else { + _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch); + _glapi_tls_Dispatch = dispatch; + } +#elif defined(THREADS) + if (DispatchOverride) { + _glthread_SetTSD(&RealDispatchTSD, (void *) dispatch); + if (ThreadSafe) + _glapi_RealDispatch = (struct _glapi_table*) __glapi_threadsafe_table; + else + _glapi_RealDispatch = dispatch; + } + else { + /* normal operation */ + _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch); + if (ThreadSafe) { + _glapi_Dispatch = (struct _glapi_table *) __glapi_threadsafe_table; + _glapi_DispatchTSD = NULL; + } + else { + _glapi_Dispatch = dispatch; + _glapi_DispatchTSD = dispatch; + } + } +#else /*THREADS*/ + if (DispatchOverride) { + _glapi_RealDispatch = dispatch; + } + else { _glapi_Dispatch = dispatch; -#else - _glapi_Dispatch = dispatch; -#endif + } +#endif /*THREADS*/ } -/* +/** * Return pointer to current dispatch table for calling thread. */ -struct _glapi_table * +PUBLIC struct _glapi_table * _glapi_get_dispatch(void) { -#if defined(THREADS) +#if defined(GLX_USE_TLS) + struct _glapi_table * api = (DispatchOverride) + ? _glapi_tls_RealDispatch : _glapi_tls_Dispatch; + + assert( api != NULL ); + return api; +#elif defined(THREADS) if (ThreadSafe) { - return (struct _glapi_table *) _glthread_GetTSD(&DispatchTSD); + if (DispatchOverride) { + return (struct _glapi_table *) _glthread_GetTSD(&RealDispatchTSD); + } + else { + return (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD); + } } else { - assert(_glapi_Dispatch); - return _glapi_Dispatch; + if (DispatchOverride) { + assert(_glapi_RealDispatch); + return _glapi_RealDispatch; + } + else { + assert(_glapi_DispatchTSD); + return _glapi_DispatchTSD; + } } #else return _glapi_Dispatch; @@ -209,1210 +443,612 @@ _glapi_get_dispatch(void) } - /* - * Return size of dispatch table struct as number of functions (or - * slots). - */ -GLuint -_glapi_get_dispatch_table_size(void) -{ - /* return sizeof(struct _glapi_table) / sizeof(void *);*/ - GetSizeCalled = GL_TRUE; - return MaxDispatchOffset + 1; -} - - - -/* - * Get API dispatcher version string. + * Notes on dispatch overrride: + * + * Dispatch override allows an external agent to hook into the GL dispatch + * mechanism before execution goes into the core rendering library. For + * example, a trace mechanism would insert itself as an overrider, print + * logging info for each GL function, then dispatch to the real GL function. + * + * libGLS (GL Stream library) is another agent that might use override. + * + * We don't allow more than one layer of overriding at this time. + * In the future we may allow nested/layered override. In that case + * _glapi_begin_dispatch_override() will return an override layer, + * _glapi_end_dispatch_override(layer) will remove an override layer + * and _glapi_get_override_dispatch(layer) will return the dispatch + * table for a given override layer. layer = 0 will be the "real" + * dispatch table. */ -const char * -_glapi_get_version(void) -{ - return "20000223"; /* YYYYMMDD */ -} - /* - * For each entry in static_functions[] which use this function - * we should implement a dispatch function in glapitemp.h and - * in glapinoop.c + * Return: dispatch override layer number. */ -static int NotImplemented(void) +PUBLIC int +_glapi_begin_dispatch_override(struct _glapi_table *override) { - return 0; -} + struct _glapi_table *real = _glapi_get_dispatch(); + assert(!DispatchOverride); /* can't nest at this time */ + DispatchOverride = GL_TRUE; -struct name_address_offset { - const char *Name; - GLvoid *Address; - GLuint Offset; -}; + _glapi_set_dispatch(real); - -static struct name_address_offset static_functions[] = { - /* GL 1.1 */ - { "glNewList", (GLvoid *) glNewList, _gloffset_NewList }, - { "glEndList", (GLvoid *) glEndList, _gloffset_EndList }, - { "glCallList", (GLvoid *) glCallList, _gloffset_CallList }, - { "glCallLists", (GLvoid *) glCallLists, _gloffset_CallLists }, - { "glDeleteLists", (GLvoid *) glDeleteLists, _gloffset_DeleteLists }, - { "glGenLists", (GLvoid *) glGenLists, _gloffset_GenLists }, - { "glListBase", (GLvoid *) glListBase, _gloffset_ListBase }, - { "glBegin", (GLvoid *) glBegin, _gloffset_Begin }, - { "glBitmap", (GLvoid *) glBitmap, _gloffset_Bitmap }, - { "glColor3b", (GLvoid *) glColor3b, _gloffset_Color3b }, - { "glColor3bv", (GLvoid *) glColor3bv, _gloffset_Color3bv }, - { "glColor3d", (GLvoid *) glColor3d, _gloffset_Color3d }, - { "glColor3dv", (GLvoid *) glColor3dv, _gloffset_Color3dv }, - { "glColor3f", (GLvoid *) glColor3f, _gloffset_Color3f }, - { "glColor3fv", (GLvoid *) glColor3fv, _gloffset_Color3fv }, - { "glColor3i", (GLvoid *) glColor3i, _gloffset_Color3i }, - { "glColor3iv", (GLvoid *) glColor3iv, _gloffset_Color3iv }, - { "glColor3s", (GLvoid *) glColor3s, _gloffset_Color3s }, - { "glColor3sv", (GLvoid *) glColor3sv, _gloffset_Color3sv }, - { "glColor3ub", (GLvoid *) glColor3ub, _gloffset_Color3ub }, - { "glColor3ubv", (GLvoid *) glColor3ubv, _gloffset_Color3ubv }, - { "glColor3ui", (GLvoid *) glColor3ui, _gloffset_Color3ui }, - { "glColor3uiv", (GLvoid *) glColor3uiv, _gloffset_Color3uiv }, - { "glColor3us", (GLvoid *) glColor3us, _gloffset_Color3us }, - { "glColor3usv", (GLvoid *) glColor3usv, _gloffset_Color3usv }, - { "glColor4b", (GLvoid *) glColor4b, _gloffset_Color4b }, - { "glColor4bv", (GLvoid *) glColor4bv, _gloffset_Color4bv }, - { "glColor4d", (GLvoid *) glColor4d, _gloffset_Color4d }, - { "glColor4dv", (GLvoid *) glColor4dv, _gloffset_Color4dv }, - { "glColor4f", (GLvoid *) glColor4f, _gloffset_Color4f }, - { "glColor4fv", (GLvoid *) glColor4fv, _gloffset_Color4fv }, - { "glColor4i", (GLvoid *) glColor4i, _gloffset_Color4i }, - { "glColor4iv", (GLvoid *) glColor4iv, _gloffset_Color4iv }, - { "glColor4s", (GLvoid *) glColor4s, _gloffset_Color4s }, - { "glColor4sv", (GLvoid *) glColor4sv, _gloffset_Color4sv }, - { "glColor4ub", (GLvoid *) glColor4ub, _gloffset_Color4ub }, - { "glColor4ubv", (GLvoid *) glColor4ubv, _gloffset_Color4ubv }, - { "glColor4ui", (GLvoid *) glColor4ui, _gloffset_Color4ui }, - { "glColor4uiv", (GLvoid *) glColor4uiv, _gloffset_Color4uiv }, - { "glColor4us", (GLvoid *) glColor4us, _gloffset_Color4us }, - { "glColor4usv", (GLvoid *) glColor4usv, _gloffset_Color4usv }, - { "glEdgeFlag", (GLvoid *) glEdgeFlag, _gloffset_EdgeFlag }, - { "glEdgeFlagv", (GLvoid *) glEdgeFlagv, _gloffset_EdgeFlagv }, - { "glEnd", (GLvoid *) glEnd, _gloffset_End }, - { "glIndexd", (GLvoid *) glIndexd, _gloffset_Indexd }, - { "glIndexdv", (GLvoid *) glIndexdv, _gloffset_Indexdv }, - { "glIndexf", (GLvoid *) glIndexf, _gloffset_Indexf }, - { "glIndexfv", (GLvoid *) glIndexfv, _gloffset_Indexfv }, - { "glIndexi", (GLvoid *) glIndexi, _gloffset_Indexi }, - { "glIndexiv", (GLvoid *) glIndexiv, _gloffset_Indexiv }, - { "glIndexs", (GLvoid *) glIndexs, _gloffset_Indexs }, - { "glIndexsv", (GLvoid *) glIndexsv, _gloffset_Indexsv }, - { "glNormal3b", (GLvoid *) glNormal3b, _gloffset_Normal3b }, - { "glNormal3bv", (GLvoid *) glNormal3bv, _gloffset_Normal3bv }, - { "glNormal3d", (GLvoid *) glNormal3d, _gloffset_Normal3d }, - { "glNormal3dv", (GLvoid *) glNormal3dv, _gloffset_Normal3dv }, - { "glNormal3f", (GLvoid *) glNormal3f, _gloffset_Normal3f }, - { "glNormal3fv", (GLvoid *) glNormal3fv, _gloffset_Normal3fv }, - { "glNormal3i", (GLvoid *) glNormal3i, _gloffset_Normal3i }, - { "glNormal3iv", (GLvoid *) glNormal3iv, _gloffset_Normal3iv }, - { "glNormal3s", (GLvoid *) glNormal3s, _gloffset_Normal3s }, - { "glNormal3sv", (GLvoid *) glNormal3sv, _gloffset_Normal3sv }, - { "glRasterPos2d", (GLvoid *) glRasterPos2d, _gloffset_RasterPos2d }, - { "glRasterPos2dv", (GLvoid *) glRasterPos2dv, _gloffset_RasterPos2dv }, - { "glRasterPos2f", (GLvoid *) glRasterPos2f, _gloffset_RasterPos2f }, - { "glRasterPos2fv", (GLvoid *) glRasterPos2fv, _gloffset_RasterPos2fv }, - { "glRasterPos2i", (GLvoid *) glRasterPos2i, _gloffset_RasterPos2i }, - { "glRasterPos2iv", (GLvoid *) glRasterPos2iv, _gloffset_RasterPos2iv }, - { "glRasterPos2s", (GLvoid *) glRasterPos2s, _gloffset_RasterPos2s }, - { "glRasterPos2sv", (GLvoid *) glRasterPos2sv, _gloffset_RasterPos2sv }, - { "glRasterPos3d", (GLvoid *) glRasterPos3d, _gloffset_RasterPos3d }, - { "glRasterPos3dv", (GLvoid *) glRasterPos3dv, _gloffset_RasterPos3dv }, - { "glRasterPos3f", (GLvoid *) glRasterPos3f, _gloffset_RasterPos3f }, - { "glRasterPos3fv", (GLvoid *) glRasterPos3fv, _gloffset_RasterPos3fv }, - { "glRasterPos3i", (GLvoid *) glRasterPos3i, _gloffset_RasterPos3i }, - { "glRasterPos3iv", (GLvoid *) glRasterPos3iv, _gloffset_RasterPos3iv }, - { "glRasterPos3s", (GLvoid *) glRasterPos3s, _gloffset_RasterPos3s }, - { "glRasterPos3sv", (GLvoid *) glRasterPos3sv, _gloffset_RasterPos3sv }, - { "glRasterPos4d", (GLvoid *) glRasterPos4d, _gloffset_RasterPos4d }, - { "glRasterPos4dv", (GLvoid *) glRasterPos4dv, _gloffset_RasterPos4dv }, - { "glRasterPos4f", (GLvoid *) glRasterPos4f, _gloffset_RasterPos4f }, - { "glRasterPos4fv", (GLvoid *) glRasterPos4fv, _gloffset_RasterPos4fv }, - { "glRasterPos4i", (GLvoid *) glRasterPos4i, _gloffset_RasterPos4i }, - { "glRasterPos4iv", (GLvoid *) glRasterPos4iv, _gloffset_RasterPos4iv }, - { "glRasterPos4s", (GLvoid *) glRasterPos4s, _gloffset_RasterPos4s }, - { "glRasterPos4sv", (GLvoid *) glRasterPos4sv, _gloffset_RasterPos4sv }, - { "glRectd", (GLvoid *) glRectd, _gloffset_Rectd }, - { "glRectdv", (GLvoid *) glRectdv, _gloffset_Rectdv }, - { "glRectf", (GLvoid *) glRectf, _gloffset_Rectf }, - { "glRectfv", (GLvoid *) glRectfv, _gloffset_Rectfv }, - { "glRecti", (GLvoid *) glRecti, _gloffset_Recti }, - { "glRectiv", (GLvoid *) glRectiv, _gloffset_Rectiv }, - { "glRects", (GLvoid *) glRects, _gloffset_Rects }, - { "glRectsv", (GLvoid *) glRectsv, _gloffset_Rectsv }, - { "glTexCoord1d", (GLvoid *) glTexCoord1d, _gloffset_TexCoord1d }, - { "glTexCoord1dv", (GLvoid *) glTexCoord1dv, _gloffset_TexCoord1dv }, - { "glTexCoord1f", (GLvoid *) glTexCoord1f, _gloffset_TexCoord1f }, - { "glTexCoord1fv", (GLvoid *) glTexCoord1fv, _gloffset_TexCoord1fv }, - { "glTexCoord1i", (GLvoid *) glTexCoord1i, _gloffset_TexCoord1i }, - { "glTexCoord1iv", (GLvoid *) glTexCoord1iv, _gloffset_TexCoord1iv }, - { "glTexCoord1s", (GLvoid *) glTexCoord1s, _gloffset_TexCoord1s }, - { "glTexCoord1sv", (GLvoid *) glTexCoord1sv, _gloffset_TexCoord1sv }, - { "glTexCoord2d", (GLvoid *) glTexCoord2d, _gloffset_TexCoord2d }, - { "glTexCoord2dv", (GLvoid *) glTexCoord2dv, _gloffset_TexCoord2dv }, - { "glTexCoord2f", (GLvoid *) glTexCoord2f, _gloffset_TexCoord2f }, - { "glTexCoord2fv", (GLvoid *) glTexCoord2fv, _gloffset_TexCoord2fv }, - { "glTexCoord2i", (GLvoid *) glTexCoord2i, _gloffset_TexCoord2i }, - { "glTexCoord2iv", (GLvoid *) glTexCoord2iv, _gloffset_TexCoord2iv }, - { "glTexCoord2s", (GLvoid *) glTexCoord2s, _gloffset_TexCoord2s }, - { "glTexCoord2sv", (GLvoid *) glTexCoord2sv, _gloffset_TexCoord2sv }, - { "glTexCoord3d", (GLvoid *) glTexCoord3d, _gloffset_TexCoord3d }, - { "glTexCoord3dv", (GLvoid *) glTexCoord3dv, _gloffset_TexCoord3dv }, - { "glTexCoord3f", (GLvoid *) glTexCoord3f, _gloffset_TexCoord3f }, - { "glTexCoord3fv", (GLvoid *) glTexCoord3fv, _gloffset_TexCoord3fv }, - { "glTexCoord3i", (GLvoid *) glTexCoord3i, _gloffset_TexCoord3i }, - { "glTexCoord3iv", (GLvoid *) glTexCoord3iv, _gloffset_TexCoord3iv }, - { "glTexCoord3s", (GLvoid *) glTexCoord3s, _gloffset_TexCoord3s }, - { "glTexCoord3sv", (GLvoid *) glTexCoord3sv, _gloffset_TexCoord3sv }, - { "glTexCoord4d", (GLvoid *) glTexCoord4d, _gloffset_TexCoord4d }, - { "glTexCoord4dv", (GLvoid *) glTexCoord4dv, _gloffset_TexCoord4dv }, - { "glTexCoord4f", (GLvoid *) glTexCoord4f, _gloffset_TexCoord4f }, - { "glTexCoord4fv", (GLvoid *) glTexCoord4fv, _gloffset_TexCoord4fv }, - { "glTexCoord4i", (GLvoid *) glTexCoord4i, _gloffset_TexCoord4i }, - { "glTexCoord4iv", (GLvoid *) glTexCoord4iv, _gloffset_TexCoord4iv }, - { "glTexCoord4s", (GLvoid *) glTexCoord4s, _gloffset_TexCoord4s }, - { "glTexCoord4sv", (GLvoid *) glTexCoord4sv, _gloffset_TexCoord4sv }, - { "glVertex2d", (GLvoid *) glVertex2d, _gloffset_Vertex2d }, - { "glVertex2dv", (GLvoid *) glVertex2dv, _gloffset_Vertex2dv }, - { "glVertex2f", (GLvoid *) glVertex2f, _gloffset_Vertex2f }, - { "glVertex2fv", (GLvoid *) glVertex2fv, _gloffset_Vertex2fv }, - { "glVertex2i", (GLvoid *) glVertex2i, _gloffset_Vertex2i }, - { "glVertex2iv", (GLvoid *) glVertex2iv, _gloffset_Vertex2iv }, - { "glVertex2s", (GLvoid *) glVertex2s, _gloffset_Vertex2s }, - { "glVertex2sv", (GLvoid *) glVertex2sv, _gloffset_Vertex2sv }, - { "glVertex3d", (GLvoid *) glVertex3d, _gloffset_Vertex3d }, - { "glVertex3dv", (GLvoid *) glVertex3dv, _gloffset_Vertex3dv }, - { "glVertex3f", (GLvoid *) glVertex3f, _gloffset_Vertex3f }, - { "glVertex3fv", (GLvoid *) glVertex3fv, _gloffset_Vertex3fv }, - { "glVertex3i", (GLvoid *) glVertex3i, _gloffset_Vertex3i }, - { "glVertex3iv", (GLvoid *) glVertex3iv, _gloffset_Vertex3iv }, - { "glVertex3s", (GLvoid *) glVertex3s, _gloffset_Vertex3s }, - { "glVertex3sv", (GLvoid *) glVertex3sv, _gloffset_Vertex3sv }, - { "glVertex4d", (GLvoid *) glVertex4d, _gloffset_Vertex4d }, - { "glVertex4dv", (GLvoid *) glVertex4dv, _gloffset_Vertex4dv }, - { "glVertex4f", (GLvoid *) glVertex4f, _gloffset_Vertex4f }, - { "glVertex4fv", (GLvoid *) glVertex4fv, _gloffset_Vertex4fv }, - { "glVertex4i", (GLvoid *) glVertex4i, _gloffset_Vertex4i }, - { "glVertex4iv", (GLvoid *) glVertex4iv, _gloffset_Vertex4iv }, - { "glVertex4s", (GLvoid *) glVertex4s, _gloffset_Vertex4s }, - { "glVertex4sv", (GLvoid *) glVertex4sv, _gloffset_Vertex4sv }, - { "glClipPlane", (GLvoid *) glClipPlane, _gloffset_ClipPlane }, - { "glColorMaterial", (GLvoid *) glColorMaterial, _gloffset_ColorMaterial }, - { "glCullFace", (GLvoid *) glCullFace, _gloffset_CullFace }, - { "glFogf", (GLvoid *) glFogf, _gloffset_Fogf }, - { "glFogfv", (GLvoid *) glFogfv, _gloffset_Fogfv }, - { "glFogi", (GLvoid *) glFogi, _gloffset_Fogi }, - { "glFogiv", (GLvoid *) glFogiv, _gloffset_Fogiv }, - { "glFrontFace", (GLvoid *) glFrontFace, _gloffset_FrontFace }, - { "glHint", (GLvoid *) glHint, _gloffset_Hint }, - { "glLightf", (GLvoid *) glLightf, _gloffset_Lightf }, - { "glLightfv", (GLvoid *) glLightfv, _gloffset_Lightfv }, - { "glLighti", (GLvoid *) glLighti, _gloffset_Lighti }, - { "glLightiv", (GLvoid *) glLightiv, _gloffset_Lightiv }, - { "glLightModelf", (GLvoid *) glLightModelf, _gloffset_LightModelf }, - { "glLightModelfv", (GLvoid *) glLightModelfv, _gloffset_LightModelfv }, - { "glLightModeli", (GLvoid *) glLightModeli, _gloffset_LightModeli }, - { "glLightModeliv", (GLvoid *) glLightModeliv, _gloffset_LightModeliv }, - { "glLineStipple", (GLvoid *) glLineStipple, _gloffset_LineStipple }, - { "glLineWidth", (GLvoid *) glLineWidth, _gloffset_LineWidth }, - { "glMaterialf", (GLvoid *) glMaterialf, _gloffset_Materialf }, - { "glMaterialfv", (GLvoid *) glMaterialfv, _gloffset_Materialfv }, - { "glMateriali", (GLvoid *) glMateriali, _gloffset_Materiali }, - { "glMaterialiv", (GLvoid *) glMaterialiv, _gloffset_Materialiv }, - { "glPointSize", (GLvoid *) glPointSize, _gloffset_PointSize }, - { "glPolygonMode", (GLvoid *) glPolygonMode, _gloffset_PolygonMode }, - { "glPolygonStipple", (GLvoid *) glPolygonStipple, _gloffset_PolygonStipple }, - { "glScissor", (GLvoid *) glScissor, _gloffset_Scissor }, - { "glShadeModel", (GLvoid *) glShadeModel, _gloffset_ShadeModel }, - { "glTexParameterf", (GLvoid *) glTexParameterf, _gloffset_TexParameterf }, - { "glTexParameterfv", (GLvoid *) glTexParameterfv, _gloffset_TexParameterfv }, - { "glTexParameteri", (GLvoid *) glTexParameteri, _gloffset_TexParameteri }, - { "glTexParameteriv", (GLvoid *) glTexParameteriv, _gloffset_TexParameteriv }, - { "glTexImage1D", (GLvoid *) glTexImage1D, _gloffset_TexImage1D }, - { "glTexImage2D", (GLvoid *) glTexImage2D, _gloffset_TexImage2D }, - { "glTexEnvf", (GLvoid *) glTexEnvf, _gloffset_TexEnvf }, - { "glTexEnvfv", (GLvoid *) glTexEnvfv, _gloffset_TexEnvfv }, - { "glTexEnvi", (GLvoid *) glTexEnvi, _gloffset_TexEnvi }, - { "glTexEnviv", (GLvoid *) glTexEnviv, _gloffset_TexEnviv }, - { "glTexGend", (GLvoid *) glTexGend, _gloffset_TexGend }, - { "glTexGendv", (GLvoid *) glTexGendv, _gloffset_TexGendv }, - { "glTexGenf", (GLvoid *) glTexGenf, _gloffset_TexGenf }, - { "glTexGenfv", (GLvoid *) glTexGenfv, _gloffset_TexGenfv }, - { "glTexGeni", (GLvoid *) glTexGeni, _gloffset_TexGeni }, - { "glTexGeniv", (GLvoid *) glTexGeniv, _gloffset_TexGeniv }, - { "glFeedbackBuffer", (GLvoid *) glFeedbackBuffer, _gloffset_FeedbackBuffer }, - { "glSelectBuffer", (GLvoid *) glSelectBuffer, _gloffset_SelectBuffer }, - { "glRenderMode", (GLvoid *) glRenderMode, _gloffset_RenderMode }, - { "glInitNames", (GLvoid *) glInitNames, _gloffset_InitNames }, - { "glLoadName", (GLvoid *) glLoadName, _gloffset_LoadName }, - { "glPassThrough", (GLvoid *) glPassThrough, _gloffset_PassThrough }, - { "glPopName", (GLvoid *) glPopName, _gloffset_PopName }, - { "glPushName", (GLvoid *) glPushName, _gloffset_PushName }, - { "glDrawBuffer", (GLvoid *) glDrawBuffer, _gloffset_DrawBuffer }, - { "glClear", (GLvoid *) glClear, _gloffset_Clear }, - { "glClearAccum", (GLvoid *) glClearAccum, _gloffset_ClearAccum }, - { "glClearIndex", (GLvoid *) glClearIndex, _gloffset_ClearIndex }, - { "glClearColor", (GLvoid *) glClearColor, _gloffset_ClearColor }, - { "glClearStencil", (GLvoid *) glClearStencil, _gloffset_ClearStencil }, - { "glClearDepth", (GLvoid *) glClearDepth, _gloffset_ClearDepth }, - { "glStencilMask", (GLvoid *) glStencilMask, _gloffset_StencilMask }, - { "glColorMask", (GLvoid *) glColorMask, _gloffset_ColorMask }, - { "glDepthMask", (GLvoid *) glDepthMask, _gloffset_DepthMask }, - { "glIndexMask", (GLvoid *) glIndexMask, _gloffset_IndexMask }, - { "glAccum", (GLvoid *) glAccum, _gloffset_Accum }, - { "glDisable", (GLvoid *) glDisable, _gloffset_Disable }, - { "glEnable", (GLvoid *) glEnable, _gloffset_Enable }, - { "glFinish", (GLvoid *) glFinish, _gloffset_Finish }, - { "glFlush", (GLvoid *) glFlush, _gloffset_Flush }, - { "glPopAttrib", (GLvoid *) glPopAttrib, _gloffset_PopAttrib }, - { "glPushAttrib", (GLvoid *) glPushAttrib, _gloffset_PushAttrib }, - { "glMap1d", (GLvoid *) glMap1d, _gloffset_Map1d }, - { "glMap1f", (GLvoid *) glMap1f, _gloffset_Map1f }, - { "glMap2d", (GLvoid *) glMap2d, _gloffset_Map2d }, - { "glMap2f", (GLvoid *) glMap2f, _gloffset_Map2f }, - { "glMapGrid1d", (GLvoid *) glMapGrid1d, _gloffset_MapGrid1d }, - { "glMapGrid1f", (GLvoid *) glMapGrid1f, _gloffset_MapGrid1f }, - { "glMapGrid2d", (GLvoid *) glMapGrid2d, _gloffset_MapGrid2d }, - { "glMapGrid2f", (GLvoid *) glMapGrid2f, _gloffset_MapGrid2f }, - { "glEvalCoord1d", (GLvoid *) glEvalCoord1d, _gloffset_EvalCoord1d }, - { "glEvalCoord1dv", (GLvoid *) glEvalCoord1dv, _gloffset_EvalCoord1dv }, - { "glEvalCoord1f", (GLvoid *) glEvalCoord1f, _gloffset_EvalCoord1f }, - { "glEvalCoord1fv", (GLvoid *) glEvalCoord1fv, _gloffset_EvalCoord1fv }, - { "glEvalCoord2d", (GLvoid *) glEvalCoord2d, _gloffset_EvalCoord2d }, - { "glEvalCoord2dv", (GLvoid *) glEvalCoord2dv, _gloffset_EvalCoord2dv }, - { "glEvalCoord2f", (GLvoid *) glEvalCoord2f, _gloffset_EvalCoord2f }, - { "glEvalCoord2fv", (GLvoid *) glEvalCoord2fv, _gloffset_EvalCoord2fv }, - { "glEvalMesh1", (GLvoid *) glEvalMesh1, _gloffset_EvalMesh1 }, - { "glEvalPoint1", (GLvoid *) glEvalPoint1, _gloffset_EvalPoint1 }, - { "glEvalMesh2", (GLvoid *) glEvalMesh2, _gloffset_EvalMesh2 }, - { "glEvalPoint2", (GLvoid *) glEvalPoint2, _gloffset_EvalPoint2 }, - { "glAlphaFunc", (GLvoid *) glAlphaFunc, _gloffset_AlphaFunc }, - { "glBlendFunc", (GLvoid *) glBlendFunc, _gloffset_BlendFunc }, - { "glLogicOp", (GLvoid *) glLogicOp, _gloffset_LogicOp }, - { "glStencilFunc", (GLvoid *) glStencilFunc, _gloffset_StencilFunc }, - { "glStencilOp", (GLvoid *) glStencilOp, _gloffset_StencilOp }, - { "glDepthFunc", (GLvoid *) glDepthFunc, _gloffset_DepthFunc }, - { "glPixelZoom", (GLvoid *) glPixelZoom, _gloffset_PixelZoom }, - { "glPixelTransferf", (GLvoid *) glPixelTransferf, _gloffset_PixelTransferf }, - { "glPixelTransferi", (GLvoid *) glPixelTransferi, _gloffset_PixelTransferi }, - { "glPixelStoref", (GLvoid *) glPixelStoref, _gloffset_PixelStoref }, - { "glPixelStorei", (GLvoid *) glPixelStorei, _gloffset_PixelStorei }, - { "glPixelMapfv", (GLvoid *) glPixelMapfv, _gloffset_PixelMapfv }, - { "glPixelMapuiv", (GLvoid *) glPixelMapuiv, _gloffset_PixelMapuiv }, - { "glPixelMapusv", (GLvoid *) glPixelMapusv, _gloffset_PixelMapusv }, - { "glReadBuffer", (GLvoid *) glReadBuffer, _gloffset_ReadBuffer }, - { "glCopyPixels", (GLvoid *) glCopyPixels, _gloffset_CopyPixels }, - { "glReadPixels", (GLvoid *) glReadPixels, _gloffset_ReadPixels }, - { "glDrawPixels", (GLvoid *) glDrawPixels, _gloffset_DrawPixels }, - { "glGetBooleanv", (GLvoid *) glGetBooleanv, _gloffset_GetBooleanv }, - { "glGetClipPlane", (GLvoid *) glGetClipPlane, _gloffset_GetClipPlane }, - { "glGetDoublev", (GLvoid *) glGetDoublev, _gloffset_GetDoublev }, - { "glGetError", (GLvoid *) glGetError, _gloffset_GetError }, - { "glGetFloatv", (GLvoid *) glGetFloatv, _gloffset_GetFloatv }, - { "glGetIntegerv", (GLvoid *) glGetIntegerv, _gloffset_GetIntegerv }, - { "glGetLightfv", (GLvoid *) glGetLightfv, _gloffset_GetLightfv }, - { "glGetLightiv", (GLvoid *) glGetLightiv, _gloffset_GetLightiv }, - { "glGetMapdv", (GLvoid *) glGetMapdv, _gloffset_GetMapdv }, - { "glGetMapfv", (GLvoid *) glGetMapfv, _gloffset_GetMapfv }, - { "glGetMapiv", (GLvoid *) glGetMapiv, _gloffset_GetMapiv }, - { "glGetMaterialfv", (GLvoid *) glGetMaterialfv, _gloffset_GetMaterialfv }, - { "glGetMaterialiv", (GLvoid *) glGetMaterialiv, _gloffset_GetMaterialiv }, - { "glGetPixelMapfv", (GLvoid *) glGetPixelMapfv, _gloffset_GetPixelMapfv }, - { "glGetPixelMapuiv", (GLvoid *) glGetPixelMapuiv, _gloffset_GetPixelMapuiv }, - { "glGetPixelMapusv", (GLvoid *) glGetPixelMapusv, _gloffset_GetPixelMapusv }, - { "glGetPolygonStipple", (GLvoid *) glGetPolygonStipple, _gloffset_GetPolygonStipple }, - { "glGetString", (GLvoid *) glGetString, _gloffset_GetString }, - { "glGetTexEnvfv", (GLvoid *) glGetTexEnvfv, _gloffset_GetTexEnvfv }, - { "glGetTexEnviv", (GLvoid *) glGetTexEnviv, _gloffset_GetTexEnviv }, - { "glGetTexGendv", (GLvoid *) glGetTexGendv, _gloffset_GetTexGendv }, - { "glGetTexGenfv", (GLvoid *) glGetTexGenfv, _gloffset_GetTexGenfv }, - { "glGetTexGeniv", (GLvoid *) glGetTexGeniv, _gloffset_GetTexGeniv }, - { "glGetTexImage", (GLvoid *) glGetTexImage, _gloffset_GetTexImage }, - { "glGetTexParameterfv", (GLvoid *) glGetTexParameterfv, _gloffset_GetTexParameterfv }, - { "glGetTexParameteriv", (GLvoid *) glGetTexParameteriv, _gloffset_GetTexParameteriv }, - { "glGetTexLevelParameterfv", (GLvoid *) glGetTexLevelParameterfv, _gloffset_GetTexLevelParameterfv }, - { "glGetTexLevelParameteriv", (GLvoid *) glGetTexLevelParameteriv, _gloffset_GetTexLevelParameteriv }, - { "glIsEnabled", (GLvoid *) glIsEnabled, _gloffset_IsEnabled }, - { "glIsList", (GLvoid *) glIsList, _gloffset_IsList }, - { "glDepthRange", (GLvoid *) glDepthRange, _gloffset_DepthRange }, - { "glFrustum", (GLvoid *) glFrustum, _gloffset_Frustum }, - { "glLoadIdentity", (GLvoid *) glLoadIdentity, _gloffset_LoadIdentity }, - { "glLoadMatrixf", (GLvoid *) glLoadMatrixf, _gloffset_LoadMatrixf }, - { "glLoadMatrixd", (GLvoid *) glLoadMatrixd, _gloffset_LoadMatrixd }, - { "glMatrixMode", (GLvoid *) glMatrixMode, _gloffset_MatrixMode }, - { "glMultMatrixf", (GLvoid *) glMultMatrixf, _gloffset_MultMatrixf }, - { "glMultMatrixd", (GLvoid *) glMultMatrixd, _gloffset_MultMatrixd }, - { "glOrtho", (GLvoid *) glOrtho, _gloffset_Ortho }, - { "glPopMatrix", (GLvoid *) glPopMatrix, _gloffset_PopMatrix }, - { "glPushMatrix", (GLvoid *) glPushMatrix, _gloffset_PushMatrix }, - { "glRotated", (GLvoid *) glRotated, _gloffset_Rotated }, - { "glRotatef", (GLvoid *) glRotatef, _gloffset_Rotatef }, - { "glScaled", (GLvoid *) glScaled, _gloffset_Scaled }, - { "glScalef", (GLvoid *) glScalef, _gloffset_Scalef }, - { "glTranslated", (GLvoid *) glTranslated, _gloffset_Translated }, - { "glTranslatef", (GLvoid *) glTranslatef, _gloffset_Translatef }, - { "glViewport", (GLvoid *) glViewport, _gloffset_Viewport }, - /* 1.1 */ - { "glArrayElement", (GLvoid *) glArrayElement, _gloffset_ArrayElement }, - { "glColorPointer", (GLvoid *) glColorPointer, _gloffset_ColorPointer }, - { "glDisableClientState", (GLvoid *) glDisableClientState, _gloffset_DisableClientState }, - { "glDrawArrays", (GLvoid *) glDrawArrays, _gloffset_DrawArrays }, - { "glDrawElements", (GLvoid *) glDrawElements, _gloffset_DrawElements }, - { "glEdgeFlagPointer", (GLvoid *) glEdgeFlagPointer, _gloffset_EdgeFlagPointer }, - { "glEnableClientState", (GLvoid *) glEnableClientState, _gloffset_EnableClientState }, - { "glGetPointerv", (GLvoid *) glGetPointerv, _gloffset_GetPointerv }, - { "glIndexPointer", (GLvoid *) glIndexPointer, _gloffset_IndexPointer }, - { "glInterleavedArrays", (GLvoid *) glInterleavedArrays, _gloffset_InterleavedArrays }, - { "glNormalPointer", (GLvoid *) glNormalPointer, _gloffset_NormalPointer }, - { "glTexCoordPointer", (GLvoid *) glTexCoordPointer, _gloffset_TexCoordPointer }, - { "glVertexPointer", (GLvoid *) glVertexPointer, _gloffset_VertexPointer }, - { "glPolygonOffset", (GLvoid *) glPolygonOffset, _gloffset_PolygonOffset }, - { "glCopyTexImage1D", (GLvoid *) glCopyTexImage1D, _gloffset_CopyTexImage1D }, - { "glCopyTexImage2D", (GLvoid *) glCopyTexImage2D, _gloffset_CopyTexImage2D }, - { "glCopyTexSubImage1D", (GLvoid *) glCopyTexSubImage1D, _gloffset_CopyTexSubImage1D }, - { "glCopyTexSubImage2D", (GLvoid *) glCopyTexSubImage2D, _gloffset_CopyTexSubImage2D }, - { "glTexSubImage1D", (GLvoid *) glTexSubImage1D, _gloffset_TexSubImage1D }, - { "glTexSubImage2D", (GLvoid *) glTexSubImage2D, _gloffset_TexSubImage2D }, - { "glAreTexturesResident", (GLvoid *) glAreTexturesResident, _gloffset_AreTexturesResident }, - { "glBindTexture", (GLvoid *) glBindTexture, _gloffset_BindTexture }, - { "glDeleteTextures", (GLvoid *) glDeleteTextures, _gloffset_DeleteTextures }, - { "glGenTextures", (GLvoid *) glGenTextures, _gloffset_GenTextures }, - { "glIsTexture", (GLvoid *) glIsTexture, _gloffset_IsTexture }, - { "glPrioritizeTextures", (GLvoid *) glPrioritizeTextures, _gloffset_PrioritizeTextures }, - { "glIndexub", (GLvoid *) glIndexub, _gloffset_Indexub }, - { "glIndexubv", (GLvoid *) glIndexubv, _gloffset_Indexubv }, - { "glPopClientAttrib", (GLvoid *) glPopClientAttrib, _gloffset_PopClientAttrib }, - { "glPushClientAttrib", (GLvoid *) glPushClientAttrib, _gloffset_PushClientAttrib }, - /* 1.2 */ -#ifdef GL_VERSION_1_2 -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glBlendColor", (GLvoid *) NAME(glBlendColor), _gloffset_BlendColor }, - { "glBlendEquation", (GLvoid *) NAME(glBlendEquation), _gloffset_BlendEquation }, - { "glDrawRangeElements", (GLvoid *) NAME(glDrawRangeElements), _gloffset_DrawRangeElements }, - { "glColorTable", (GLvoid *) NAME(glColorTable), _gloffset_ColorTable }, - { "glColorTableParameterfv", (GLvoid *) NAME(glColorTableParameterfv), _gloffset_ColorTableParameterfv }, - { "glColorTableParameteriv", (GLvoid *) NAME(glColorTableParameteriv), _gloffset_ColorTableParameteriv }, - { "glCopyColorTable", (GLvoid *) NAME(glCopyColorTable), _gloffset_CopyColorTable }, - { "glGetColorTable", (GLvoid *) NAME(glGetColorTable), _gloffset_GetColorTable }, - { "glGetColorTableParameterfv", (GLvoid *) NAME(glGetColorTableParameterfv), _gloffset_GetColorTableParameterfv }, - { "glGetColorTableParameteriv", (GLvoid *) NAME(glGetColorTableParameteriv), _gloffset_GetColorTableParameteriv }, - { "glColorSubTable", (GLvoid *) NAME(glColorSubTable), _gloffset_ColorSubTable }, - { "glCopyColorSubTable", (GLvoid *) NAME(glCopyColorSubTable), _gloffset_CopyColorSubTable }, - { "glConvolutionFilter1D", (GLvoid *) NAME(glConvolutionFilter1D), _gloffset_ConvolutionFilter1D }, - { "glConvolutionFilter2D", (GLvoid *) NAME(glConvolutionFilter2D), _gloffset_ConvolutionFilter2D }, - { "glConvolutionParameterf", (GLvoid *) NAME(glConvolutionParameterf), _gloffset_ConvolutionParameterf }, - { "glConvolutionParameterfv", (GLvoid *) NAME(glConvolutionParameterfv), _gloffset_ConvolutionParameterfv }, - { "glConvolutionParameteri", (GLvoid *) NAME(glConvolutionParameteri), _gloffset_ConvolutionParameteri }, - { "glConvolutionParameteriv", (GLvoid *) NAME(glConvolutionParameteriv), _gloffset_ConvolutionParameteriv }, - { "glCopyConvolutionFilter1D", (GLvoid *) NAME(glCopyConvolutionFilter1D), _gloffset_CopyConvolutionFilter1D }, - { "glCopyConvolutionFilter2D", (GLvoid *) NAME(glCopyConvolutionFilter2D), _gloffset_CopyConvolutionFilter2D }, - { "glGetConvolutionFilter", (GLvoid *) NAME(glGetConvolutionFilter), _gloffset_GetConvolutionFilter }, - { "glGetConvolutionParameterfv", (GLvoid *) NAME(glGetConvolutionParameterfv), _gloffset_GetConvolutionParameterfv }, - { "glGetConvolutionParameteriv", (GLvoid *) NAME(glGetConvolutionParameteriv), _gloffset_GetConvolutionParameteriv }, - { "glGetSeparableFilter", (GLvoid *) NAME(glGetSeparableFilter), _gloffset_GetSeparableFilter }, - { "glSeparableFilter2D", (GLvoid *) NAME(glSeparableFilter2D), _gloffset_SeparableFilter2D }, - { "glGetHistogram", (GLvoid *) NAME(glGetHistogram), _gloffset_GetHistogram }, - { "glGetHistogramParameterfv", (GLvoid *) NAME(glGetHistogramParameterfv), _gloffset_GetHistogramParameterfv }, - { "glGetHistogramParameteriv", (GLvoid *) NAME(glGetHistogramParameteriv), _gloffset_GetHistogramParameteriv }, - { "glGetMinmax", (GLvoid *) NAME(glGetMinmax), _gloffset_GetMinmax }, - { "glGetMinmaxParameterfv", (GLvoid *) NAME(glGetMinmaxParameterfv), _gloffset_GetMinmaxParameterfv }, - { "glGetMinmaxParameteriv", (GLvoid *) NAME(glGetMinmaxParameteriv), _gloffset_GetMinmaxParameteriv }, - { "glHistogram", (GLvoid *) NAME(glHistogram), _gloffset_Histogram }, - { "glMinmax", (GLvoid *) NAME(glMinmax), _gloffset_Minmax }, - { "glResetHistogram", (GLvoid *) NAME(glResetHistogram), _gloffset_ResetHistogram }, - { "glResetMinmax", (GLvoid *) NAME(glResetMinmax), _gloffset_ResetMinmax }, - { "glTexImage3D", (GLvoid *) NAME(glTexImage3D), _gloffset_TexImage3D }, - { "glTexSubImage3D", (GLvoid *) NAME(glTexSubImage3D), _gloffset_TexSubImage3D }, - { "glCopyTexSubImage3D", (GLvoid *) NAME(glCopyTexSubImage3D), _gloffset_CopyTexSubImage3D }, -#undef NAME - - /* GL_ARB_multitexture */ -#ifdef GL_ARB_multitexture -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glActiveTextureARB", (GLvoid *) NAME(glActiveTextureARB), _gloffset_ActiveTextureARB }, - { "glClientActiveTextureARB", (GLvoid *) NAME(glClientActiveTextureARB), _gloffset_ClientActiveTextureARB }, - { "glMultiTexCoord1dARB", (GLvoid *) NAME(glMultiTexCoord1dARB), _gloffset_MultiTexCoord1dARB }, - { "glMultiTexCoord1dvARB", (GLvoid *) NAME(glMultiTexCoord1dvARB), _gloffset_MultiTexCoord1dvARB }, - { "glMultiTexCoord1fARB", (GLvoid *) NAME(glMultiTexCoord1fARB), _gloffset_MultiTexCoord1fARB }, - { "glMultiTexCoord1fvARB", (GLvoid *) NAME(glMultiTexCoord1fvARB), _gloffset_MultiTexCoord1fvARB }, - { "glMultiTexCoord1iARB", (GLvoid *) NAME(glMultiTexCoord1iARB), _gloffset_MultiTexCoord1iARB }, - { "glMultiTexCoord1ivARB", (GLvoid *) NAME(glMultiTexCoord1ivARB), _gloffset_MultiTexCoord1ivARB }, - { "glMultiTexCoord1sARB", (GLvoid *) NAME(glMultiTexCoord1sARB), _gloffset_MultiTexCoord1sARB }, - { "glMultiTexCoord1svARB", (GLvoid *) NAME(glMultiTexCoord1svARB), _gloffset_MultiTexCoord1svARB }, - { "glMultiTexCoord2dARB", (GLvoid *) NAME(glMultiTexCoord2dARB), _gloffset_MultiTexCoord2dARB }, - { "glMultiTexCoord2dvARB", (GLvoid *) NAME(glMultiTexCoord2dvARB), _gloffset_MultiTexCoord2dvARB }, - { "glMultiTexCoord2fARB", (GLvoid *) NAME(glMultiTexCoord2fARB), _gloffset_MultiTexCoord2fARB }, - { "glMultiTexCoord2fvARB", (GLvoid *) NAME(glMultiTexCoord2fvARB), _gloffset_MultiTexCoord2fvARB }, - { "glMultiTexCoord2iARB", (GLvoid *) NAME(glMultiTexCoord2iARB), _gloffset_MultiTexCoord2iARB }, - { "glMultiTexCoord2ivARB", (GLvoid *) NAME(glMultiTexCoord2ivARB), _gloffset_MultiTexCoord2ivARB }, - { "glMultiTexCoord2sARB", (GLvoid *) NAME(glMultiTexCoord2sARB), _gloffset_MultiTexCoord2sARB }, - { "glMultiTexCoord2svARB", (GLvoid *) NAME(glMultiTexCoord2svARB), _gloffset_MultiTexCoord2svARB }, - { "glMultiTexCoord3dARB", (GLvoid *) NAME(glMultiTexCoord3dARB), _gloffset_MultiTexCoord3dARB }, - { "glMultiTexCoord3dvARB", (GLvoid *) NAME(glMultiTexCoord3dvARB), _gloffset_MultiTexCoord3dvARB }, - { "glMultiTexCoord3fARB", (GLvoid *) NAME(glMultiTexCoord3fARB), _gloffset_MultiTexCoord3fARB }, - { "glMultiTexCoord3fvARB", (GLvoid *) NAME(glMultiTexCoord3fvARB), _gloffset_MultiTexCoord3fvARB }, - { "glMultiTexCoord3iARB", (GLvoid *) NAME(glMultiTexCoord3iARB), _gloffset_MultiTexCoord3iARB }, - { "glMultiTexCoord3ivARB", (GLvoid *) NAME(glMultiTexCoord3ivARB), _gloffset_MultiTexCoord3ivARB }, - { "glMultiTexCoord3sARB", (GLvoid *) NAME(glMultiTexCoord3sARB), _gloffset_MultiTexCoord3sARB }, - { "glMultiTexCoord3svARB", (GLvoid *) NAME(glMultiTexCoord3svARB), _gloffset_MultiTexCoord3svARB }, - { "glMultiTexCoord4dARB", (GLvoid *) NAME(glMultiTexCoord4dARB), _gloffset_MultiTexCoord4dARB }, - { "glMultiTexCoord4dvARB", (GLvoid *) NAME(glMultiTexCoord4dvARB), _gloffset_MultiTexCoord4dvARB }, - { "glMultiTexCoord4fARB", (GLvoid *) NAME(glMultiTexCoord4fARB), _gloffset_MultiTexCoord4fARB }, - { "glMultiTexCoord4fvARB", (GLvoid *) NAME(glMultiTexCoord4fvARB), _gloffset_MultiTexCoord4fvARB }, - { "glMultiTexCoord4iARB", (GLvoid *) NAME(glMultiTexCoord4iARB), _gloffset_MultiTexCoord4iARB }, - { "glMultiTexCoord4ivARB", (GLvoid *) NAME(glMultiTexCoord4ivARB), _gloffset_MultiTexCoord4ivARB }, - { "glMultiTexCoord4sARB", (GLvoid *) NAME(glMultiTexCoord4sARB), _gloffset_MultiTexCoord4sARB }, - { "glMultiTexCoord4svARB", (GLvoid *) NAME(glMultiTexCoord4svARB), _gloffset_MultiTexCoord4svARB }, -#undef NAME - - /* GL_ARB_transpose_matrix */ -#ifdef GL_ARB_transpose_matrix -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glLoadTransposeMatrixdARB", (GLvoid *) NAME(glLoadTransposeMatrixdARB), _gloffset_LoadTransposeMatrixdARB }, - { "glLoadTransposeMatrixfARB", (GLvoid *) NAME(glLoadTransposeMatrixfARB), _gloffset_LoadTransposeMatrixfARB }, - { "glMultTransposeMatrixdARB", (GLvoid *) NAME(glMultTransposeMatrixdARB), _gloffset_MultTransposeMatrixdARB }, - { "glMultTransposeMatrixfARB", (GLvoid *) NAME(glMultTransposeMatrixfARB), _gloffset_MultTransposeMatrixfARB }, -#undef NAME - - /* GL_ARB_multisample */ -#ifdef GL_ARB_multisample -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glSampleCoverageARB", (GLvoid *) NAME(glSampleCoverageARB), _gloffset_SampleCoverageARB }, - { "glSamplePassARB", (GLvoid *) NAME(glSamplePassARB), _gloffset_SamplePassARB }, -#undef NAME - - /* 2. GL_EXT_blend_color */ -#ifdef GL_EXT_blend_color -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glBlendColorEXT", (GLvoid *) NAME(glBlendColorEXT), _gloffset_BlendColor }, -#undef NAME - - /* 3. GL_EXT_polygon_offset */ -#ifdef GL_EXT_polygon_offset -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glPolygonOffsetEXT", (GLvoid *) NAME(glPolygonOffsetEXT), _gloffset_PolygonOffsetEXT }, -#undef NAME - - /* 6. GL_EXT_texture3D */ -#ifdef GL_EXT_texture3D -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glCopyTexSubImage3DEXT", (GLvoid *) NAME(glCopyTexSubImage3DEXT), _gloffset_CopyTexSubImage3D }, - { "glTexImage3DEXT", (GLvoid *) NAME(glTexImage3DEXT), _gloffset_TexImage3D }, - { "glTexSubImage3DEXT", (GLvoid *) NAME(glTexSubImage3DEXT), _gloffset_TexSubImage3D }, -#undef NAME - - /* 7. GL_SGI_texture_filter4 */ -#ifdef GL_SGI_texture_filter4 -#define NAME(X) X +#if defined(GLX_USE_TLS) + _glthread_SetTSD(&_gl_DispatchTSD, (void *) override); + _glapi_tls_Dispatch = override; +#elif defined(THREADS) + _glthread_SetTSD(&_gl_DispatchTSD, (void *) override); + if ( ThreadSafe ) { + _glapi_Dispatch = (struct _glapi_table *) __glapi_threadsafe_table; + _glapi_DispatchTSD = NULL; + } + else { + _glapi_Dispatch = override; + _glapi_DispatchTSD = override; + } #else -#define NAME(X) NotImplemented + _glapi_Dispatch = override; #endif - { "glGetTexFilterFuncSGIS", (GLvoid *) NAME(glGetTexFilterFuncSGIS), _gloffset_GetTexFilterFuncSGIS }, - { "glTexFilterFuncSGIS", (GLvoid *) NAME(glTexFilterFuncSGIS), _gloffset_TexFilterFuncSGIS }, -#undef NAME + return 1; +} - /* 9. GL_EXT_subtexture */ -#ifdef GL_EXT_subtexture -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glTexSubImage1DEXT", (GLvoid *) NAME(glTexSubImage1DEXT), _gloffset_TexSubImage1D }, - { "glTexSubImage2DEXT", (GLvoid *) NAME(glTexSubImage2DEXT), _gloffset_TexSubImage2D }, -#undef NAME - /* 10. GL_EXT_copy_texture */ -#ifdef GL_EXT_copy_texture -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glCopyTexImage1DEXT", (GLvoid *) NAME(glCopyTexImage1DEXT), _gloffset_CopyTexImage1D }, - { "glCopyTexImage2DEXT", (GLvoid *) NAME(glCopyTexImage2DEXT), _gloffset_CopyTexImage2D }, - { "glCopyTexSubImage1DEXT", (GLvoid *) NAME(glCopyTexSubImage1DEXT), _gloffset_CopyTexSubImage1D }, - { "glCopyTexSubImage2DEXT", (GLvoid *) NAME(glCopyTexSubImage2DEXT), _gloffset_CopyTexSubImage2D }, -#undef NAME - - /* 11. GL_EXT_histogram */ -#ifdef GL_EXT_histogram -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glGetHistogramEXT", (GLvoid *) NAME(glGetHistogramEXT), _gloffset_GetHistogramEXT }, - { "glGetHistogramParameterfvEXT", (GLvoid *) NAME(glGetHistogramParameterfvEXT), _gloffset_GetHistogramParameterfvEXT }, - { "glGetHistogramParameterivEXT", (GLvoid *) NAME(glGetHistogramParameterivEXT), _gloffset_GetHistogramParameterivEXT }, - { "glGetMinmaxEXT", (GLvoid *) NAME(glGetMinmaxEXT), _gloffset_GetMinmaxEXT }, - { "glGetMinmaxParameterfvEXT", (GLvoid *) NAME(glGetMinmaxParameterfvEXT), _gloffset_GetMinmaxParameterfvEXT }, - { "glGetMinmaxParameterivEXT", (GLvoid *) NAME(glGetMinmaxParameterivEXT), _gloffset_GetMinmaxParameterivEXT }, - { "glHistogramEXT", (GLvoid *) NAME(glHistogramEXT), _gloffset_Histogram }, - { "glMinmaxEXT", (GLvoid *) NAME(glMinmaxEXT), _gloffset_Minmax }, - { "glResetHistogramEXT", (GLvoid *) NAME(glResetHistogramEXT), _gloffset_ResetHistogram }, - { "glResetMinmaxEXT", (GLvoid *) NAME(glResetMinmaxEXT), _gloffset_ResetMinmax }, -#undef NAME - - /* 12. GL_EXT_convolution */ -#ifdef GL_EXT_convolution -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glConvolutionFilter1DEXT", (GLvoid *) NAME(glConvolutionFilter1DEXT), _gloffset_ConvolutionFilter1D }, - { "glConvolutionFilter2DEXT", (GLvoid *) NAME(glConvolutionFilter2DEXT), _gloffset_ConvolutionFilter2D }, - { "glConvolutionParameterfEXT", (GLvoid *) NAME(glConvolutionParameterfEXT), _gloffset_ConvolutionParameterf }, - { "glConvolutionParameterfvEXT", (GLvoid *) NAME(glConvolutionParameterfvEXT), _gloffset_ConvolutionParameterfv }, - { "glConvolutionParameteriEXT", (GLvoid *) NAME(glConvolutionParameteriEXT), _gloffset_ConvolutionParameteri }, - { "glConvolutionParameterivEXT", (GLvoid *) NAME(glConvolutionParameterivEXT), _gloffset_ConvolutionParameteriv }, - { "glCopyConvolutionFilter1DEXT", (GLvoid *) NAME(glCopyConvolutionFilter1DEXT), _gloffset_CopyConvolutionFilter1D }, - { "glCopyConvolutionFilter2DEXT", (GLvoid *) NAME(glCopyConvolutionFilter2DEXT), _gloffset_CopyConvolutionFilter2D }, - { "glGetConvolutionFilterEXT", (GLvoid *) NAME(glGetConvolutionFilterEXT), _gloffset_GetConvolutionFilterEXT }, - { "glGetConvolutionParameterivEXT", (GLvoid *) NAME(glGetConvolutionParameterivEXT), _gloffset_GetConvolutionParameterivEXT }, - { "glGetConvolutionParameterfvEXT", (GLvoid *) NAME(glGetConvolutionParameterfvEXT), _gloffset_GetConvolutionParameterfvEXT }, - { "glGetSeparableFilterEXT", (GLvoid *) NAME(glGetSeparableFilterEXT), _gloffset_GetSeparableFilterEXT }, - { "glSeparableFilter2DEXT", (GLvoid *) NAME(glSeparableFilter2DEXT), _gloffset_SeparableFilter2D }, -#undef NAME - - /* 14. GL_SGI_color_table */ -#ifdef GL_SGI_color_table -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glColorTableSGI", (GLvoid *) NAME(glColorTableSGI), _gloffset_ColorTable }, - { "glColorTableParameterfvSGI", (GLvoid *) NAME(glColorTableParameterfvSGI), _gloffset_ColorTableParameterfv }, - { "glColorTableParameterivSGI", (GLvoid *) NAME(glColorTableParameterivSGI), _gloffset_ColorTableParameteriv }, - { "glCopyColorTableSGI", (GLvoid *) NAME(glCopyColorTableSGI), _gloffset_CopyColorTable }, - { "glGetColorTableSGI", (GLvoid *) NAME(glGetColorTableSGI), _gloffset_GetColorTableSGI }, - { "glGetColorTableParameterfvSGI", (GLvoid *) NAME(glGetColorTableParameterfvSGI), _gloffset_GetColorTableParameterfvSGI }, - { "glGetColorTableParameterivSGI", (GLvoid *) NAME(glGetColorTableParameterivSGI), _gloffset_GetColorTableParameterivSGI }, -#undef NAME - - /* 15. GL_SGIS_pixel_texture */ -#ifdef GL_SGIS_pixel_texture -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glPixelTexGenParameterfSGIS", (GLvoid *) NAME(glPixelTexGenParameterfSGIS), _gloffset_PixelTexGenParameterfSGIS }, - { "glPixelTexGenParameteriSGIS", (GLvoid *) NAME(glPixelTexGenParameteriSGIS), _gloffset_PixelTexGenParameteriSGIS }, - { "glGetPixelTexGenParameterfvSGIS", (GLvoid *) NAME(glGetPixelTexGenParameterfvSGIS), _gloffset_GetPixelTexGenParameterfvSGIS }, - { "glGetPixelTexGenParameterivSGIS", (GLvoid *) NAME(glGetPixelTexGenParameterivSGIS), _gloffset_GetPixelTexGenParameterivSGIS }, -#undef NAME - - /* 16. GL_SGIS_texture4D */ -#ifdef GL_SGIS_texture4D -#define NAME(X) X +PUBLIC void +_glapi_end_dispatch_override(int layer) +{ + struct _glapi_table *real = _glapi_get_dispatch(); + (void) layer; + DispatchOverride = GL_FALSE; + _glapi_set_dispatch(real); + /* the rest of this isn't needed, just play it safe */ +#if defined(GLX_USE_TLS) + _glapi_tls_RealDispatch = NULL; #else -#define NAME(X) NotImplemented +# if defined(THREADS) + _glthread_SetTSD(&RealDispatchTSD, NULL); +# endif + _glapi_RealDispatch = NULL; #endif - { "glTexImage4DSGIS", (GLvoid *) NAME(glTexImage4DSGIS), _gloffset_TexImage4DSGIS }, - { "glTexSubImage4DSGIS", (GLvoid *) NAME(glTexSubImage4DSGIS), _gloffset_TexSubImage4DSGIS }, -#undef NAME +} - /* 20. GL_EXT_texture_object */ -#ifdef GL_EXT_texture_object -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glAreTexturesResidentEXT", (GLvoid *) NAME(glAreTexturesResidentEXT), _gloffset_AreTexturesResidentEXT }, - { "glBindTextureEXT", (GLvoid *) NAME(glBindTextureEXT), _gloffset_BindTexture }, - { "glDeleteTexturesEXT", (GLvoid *) NAME(glDeleteTexturesEXT), _gloffset_DeleteTextures }, - { "glGenTexturesEXT", (GLvoid *) NAME(glGenTexturesEXT), _gloffset_GenTexturesEXT }, - { "glIsTextureEXT", (GLvoid *) NAME(glIsTextureEXT), _gloffset_IsTextureEXT }, - { "glPrioritizeTexturesEXT", (GLvoid *) NAME(glPrioritizeTexturesEXT), _gloffset_PrioritizeTextures }, -#undef NAME - - /* 21. GL_SGIS_detail_texture */ -#ifdef GL_SGIS_detail_texture -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glDetailTexFuncSGIS", (GLvoid *) NAME(glDetailTexFuncSGIS), _gloffset_DetailTexFuncSGIS }, - { "glGetDetailTexFuncSGIS", (GLvoid *) NAME(glGetDetailTexFuncSGIS), _gloffset_GetDetailTexFuncSGIS }, -#undef NAME - /* 22. GL_SGIS_sharpen_texture */ -#ifdef GL_SGIS_sharpen_texture -#define NAME(X) X +PUBLIC struct _glapi_table * +_glapi_get_override_dispatch(int layer) +{ + if (layer == 0) { + return _glapi_get_dispatch(); + } + else { + if (DispatchOverride) { +#if defined(GLX_USE_TLS) + return (struct _glapi_table *) _glapi_tls_Dispatch; +#elif defined(THREADS) + return (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD); #else -#define NAME(X) NotImplemented + return _glapi_Dispatch; #endif - { "glGetSharpenTexFuncSGIS", (GLvoid *) NAME(glGetSharpenTexFuncSGIS), _gloffset_GetSharpenTexFuncSGIS }, - { "glSharpenTexFuncSGIS", (GLvoid *) NAME(glSharpenTexFuncSGIS), _gloffset_SharpenTexFuncSGIS }, -#undef NAME + } + else { + return NULL; + } + } +} - /* 25. GL_SGIS_multisample */ -#ifdef GL_SGIS_multisample -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glSampleMaskSGIS", (GLvoid *) NAME(glSampleMaskSGIS), _gloffset_SampleMaskSGIS }, - { "glSamplePatternSGIS", (GLvoid *) NAME(glSamplePatternSGIS), _gloffset_SamplePatternSGIS }, -#undef NAME - /* 30. GL_EXT_vertex_array */ -#ifdef GL_EXT_vertex_array -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glArrayElementEXT", (GLvoid *) NAME(glArrayElementEXT), _gloffset_ArrayElement }, - { "glColorPointerEXT", (GLvoid *) NAME(glColorPointerEXT), _gloffset_ColorPointerEXT }, - { "glDrawArraysEXT", (GLvoid *) NAME(glDrawArraysEXT), _gloffset_DrawArrays }, - { "glEdgeFlagPointerEXT", (GLvoid *) NAME(glEdgeFlagPointerEXT), _gloffset_EdgeFlagPointerEXT }, - { "glGetPointervEXT", (GLvoid *) NAME(glGetPointervEXT), _gloffset_GetPointerv }, - { "glIndexPointerEXT", (GLvoid *) NAME(glIndexPointerEXT), _gloffset_IndexPointerEXT }, - { "glNormalPointerEXT", (GLvoid *) NAME(glNormalPointerEXT), _gloffset_NormalPointerEXT }, - { "glTexCoordPointerEXT", (GLvoid *) NAME(glTexCoordPointerEXT), _gloffset_TexCoordPointerEXT }, - { "glVertexPointerEXT", (GLvoid *) NAME(glVertexPointerEXT), _gloffset_VertexPointerEXT }, -#undef NAME - - /* 37. GL_EXT_blend_minmax */ -#ifdef GL_EXT_blend_minmax -#define NAME(X) X -#else -#define NAME(X) NotImplemented +#if !defined( USE_X86_ASM ) +#define NEED_FUNCTION_POINTER #endif - { "glBlendEquationEXT", (GLvoid *) NAME(glBlendEquationEXT), _gloffset_BlendEquation }, -#undef NAME - /* 52. GL_SGIX_sprite */ -#ifdef GL_SGIX_sprite -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glSpriteParameterfSGIX", (GLvoid *) NAME(glSpriteParameterfSGIX), _gloffset_SpriteParameterfSGIX }, - { "glSpriteParameterfvSGIX", (GLvoid *) NAME(glSpriteParameterfvSGIX), _gloffset_SpriteParameterfvSGIX }, - { "glSpriteParameteriSGIX", (GLvoid *) NAME(glSpriteParameteriSGIX), _gloffset_SpriteParameteriSGIX }, - { "glSpriteParameterivSGIX", (GLvoid *) NAME(glSpriteParameterivSGIX), _gloffset_SpriteParameterivSGIX }, -#undef NAME - - /* 54. GL_EXT_point_parameters */ -#ifdef GL_EXT_point_parameters -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glPointParameterfEXT", (GLvoid *) NAME(glPointParameterfEXT), _gloffset_PointParameterfEXT }, - { "glPointParameterfvEXT", (GLvoid *) NAME(glPointParameterfvEXT), _gloffset_PointParameterfvEXT }, -#undef NAME +/* The code in this file is auto-generated with Python */ +#include "glprocs.h" - /* 55. GL_SGIX_instruments */ -#ifdef GL_SGIX_instruments -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glInstrumentsBufferSGIX", (GLvoid *) NAME(glInstrumentsBufferSGIX), _gloffset_InstrumentsBufferSGIX }, - { "glStartInstrumentsSGIX", (GLvoid *) NAME(glStartInstrumentsSGIX), _gloffset_StartInstrumentsSGIX }, - { "glStopInstrumentsSGIX", (GLvoid *) NAME(glStopInstrumentsSGIX), _gloffset_StopInstrumentsSGIX }, - { "glReadInstrumentsSGIX", (GLvoid *) NAME(glReadInstrumentsSGIX), _gloffset_ReadInstrumentsSGIX }, - { "glPollInstrumentsSGIX", (GLvoid *) NAME(glPollInstrumentsSGIX), _gloffset_PollInstrumentsSGIX }, - { "glGetInstrumentsSGIX", (GLvoid *) NAME(glGetInstrumentsSGIX), _gloffset_GetInstrumentsSGIX }, -#undef NAME - - /* 57. GL_SGIX_framezoom */ -#ifdef GL_SGIX_framezoom -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glFrameZoomSGIX", (GLvoid *) NAME(glFrameZoomSGIX), _gloffset_FrameZoomSGIX }, -#undef NAME - /* 58. GL_SGIX_tag_sample_buffer */ -#ifdef GL_SGIX_tag_sample_buffer -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glTagSampleBufferSGIX", (GLvoid *) NAME(glTagSampleBufferSGIX), _gloffset_TagSampleBufferSGIX }, -#undef NAME +/** + * Search the table of static entrypoint functions for the named function + * and return the corresponding glprocs_table_t entry. + */ +static const glprocs_table_t * +find_entry( const char * n ) +{ + GLuint i; - /* 60. GL_SGIX_reference_plane */ -#ifdef GL_SGIX_reference_plane -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glReferencePlaneSGIX", (GLvoid *) NAME(glReferencePlaneSGIX), _gloffset_ReferencePlaneSGIX }, -#undef NAME + for (i = 0; static_functions[i].Name_offset >= 0; i++) { + const char * test_name; - /* 61. GL_SGIX_flush_raster */ -#ifdef GL_SGIX_flush_raster -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glFlushRasterSGIX", (GLvoid *) NAME(glFlushRasterSGIX), _gloffset_FlushRasterSGIX }, -#undef NAME + test_name = gl_string_table + static_functions[i].Name_offset; + if (strcmp(test_name, n) == 0) { + return & static_functions[i]; + } + } + return NULL; +} - /* 66. GL_HP_image_transform */ -#if 0 -#ifdef GL_HP_image_transform -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glGetImageTransformParameterfvHP", (GLvoid *) NAME(glGetImageTransformParameterfvHP), _gloffset_GetImageTransformParameterfvHP }, - { "glGetImageTransformParameterivHP", (GLvoid *) NAME(glGetImageTransformParameterivHP), _gloffset_GetImageTransformParameterivHP }, - { "glImageTransformParameterfHP", (GLvoid *) NAME(glImageTransformParameterfHP), _gloffset_ImageTransformParameterfHP }, - { "glImageTransformParameterfvHP", (GLvoid *) NAME(glImageTransformParameterfvHP), _gloffset_ImageTransformParameterfvHP }, - { "glImageTransformParameteriHP", (GLvoid *) NAME(glImageTransformParameteriHP), _gloffset_ImageTransformParameteriHP }, - { "glImageTransformParameterivHP", (GLvoid *) NAME(glImageTransformParameterivHP), _gloffset_ImageTransformParameterivHP }, -#undef NAME -#endif - /* 74. GL_EXT_color_subtable */ -#ifdef GL_EXT_color_subtable -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glColorSubTableEXT", (GLvoid *) NAME(glColorSubTableEXT), _gloffset_ColorSubTable }, - { "glCopyColorSubTableEXT", (GLvoid *) NAME(glCopyColorSubTableEXT), _gloffset_CopyColorSubTable }, -#undef NAME +/** + * Return dispatch table offset of the named static (built-in) function. + * Return -1 if function not found. + */ +static GLint +get_static_proc_offset(const char *funcName) +{ + const glprocs_table_t * const f = find_entry( funcName ); - /* 77. GL_PGI_misc_hints */ -#ifdef GL_PGI_misc_hints -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glHintPGI", (GLvoid *) NAME(glHintPGI), _gloffset_HintPGI }, -#undef NAME + if ( f != NULL ) { + return f->Offset; + } + return -1; +} - /* 78. GL_EXT_paletted_texture */ -#ifdef GL_EXT_paletted_texture -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glColorTableEXT", (GLvoid *) NAME(glColorTableEXT), _gloffset_ColorTable }, - { "glGetColorTableEXT", (GLvoid *) NAME(glGetColorTableEXT), _gloffset_GetColorTable }, - { "glGetColorTableParameterfvEXT", (GLvoid *) NAME(glGetColorTableParameterfvEXT), _gloffset_GetColorTableParameterfv }, - { "glGetColorTableParameterivEXT", (GLvoid *) NAME(glGetColorTableParameterivEXT), _gloffset_GetColorTableParameteriv }, -#undef NAME - - /* 80. GL_SGIX_list_priority */ -#ifdef GL_SGIX_list_priority -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glGetListParameterfvSGIX", (GLvoid *) NAME(glGetListParameterfvSGIX), _gloffset_GetListParameterfvSGIX }, - { "glGetListParameterivSGIX", (GLvoid *) NAME(glGetListParameterivSGIX), _gloffset_GetListParameterivSGIX }, - { "glListParameterfSGIX", (GLvoid *) NAME(glListParameterfSGIX), _gloffset_ListParameterfSGIX }, - { "glListParameterfvSGIX", (GLvoid *) NAME(glListParameterfvSGIX), _gloffset_ListParameterfvSGIX }, - { "glListParameteriSGIX", (GLvoid *) NAME(glListParameteriSGIX), _gloffset_ListParameteriSGIX }, - { "glListParameterivSGIX", (GLvoid *) NAME(glListParameterivSGIX), _gloffset_ListParameterivSGIX }, -#undef NAME - - /* 94. GL_EXT_index_material */ -#ifdef GL_EXT_index_material -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glIndexMaterialEXT", (GLvoid *) NAME(glIndexMaterialEXT), _gloffset_IndexMaterialEXT }, -#undef NAME - /* 95. GL_EXT_index_func */ -#ifdef GL_EXT_index_func -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glIndexFuncEXT", (GLvoid *) NAME(glIndexFuncEXT), _gloffset_IndexFuncEXT }, -#undef NAME +#ifdef USE_X86_ASM - /* 97. GL_EXT_compiled_vertex_array */ -#ifdef GL_EXT_compiled_vertex_array -#define NAME(X) X +#if defined( GLX_USE_TLS ) +extern GLubyte gl_dispatch_functions_start[]; +extern GLubyte gl_dispatch_functions_end[]; #else -#define NAME(X) NotImplemented +extern const GLubyte gl_dispatch_functions_start[]; #endif - { "glLockArraysEXT", (GLvoid *) NAME(glLockArraysEXT), _gloffset_LockArraysEXT }, - { "glUnlockArraysEXT", (GLvoid *) NAME(glUnlockArraysEXT), _gloffset_UnlockArraysEXT }, -#undef NAME - /* 98. GL_EXT_cull_vertex */ -#ifdef GL_EXT_cull_vertex -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glCullParameterfvEXT", (GLvoid *) NAME(glCullParameterfvEXT), _gloffset_CullParameterfvEXT }, - { "glCullParameterdvEXT", (GLvoid *) NAME(glCullParameterdvEXT), _gloffset_CullParameterdvEXT }, -#undef NAME +# if defined(THREADS) && !defined(GLX_USE_TLS) +# define X86_DISPATCH_FUNCTION_SIZE 32 +# else +# define X86_DISPATCH_FUNCTION_SIZE 16 +# endif - /* 102. GL_SGIX_fragment_lighting */ -#ifdef GL_SGIX_fragment_lighting -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glFragmentColorMaterialSGIX", (GLvoid *) NAME(glFragmentColorMaterialSGIX), _gloffset_FragmentColorMaterialSGIX }, - { "glFragmentLightfSGIX", (GLvoid *) NAME(glFragmentLightfSGIX), _gloffset_FragmentLightfSGIX }, - { "glFragmentLightfvSGIX", (GLvoid *) NAME(glFragmentLightfvSGIX), _gloffset_FragmentLightfvSGIX }, - { "glFragmentLightiSGIX", (GLvoid *) NAME(glFragmentLightiSGIX), _gloffset_FragmentLightiSGIX }, - { "glFragmentLightivSGIX", (GLvoid *) NAME(glFragmentLightivSGIX), _gloffset_FragmentLightivSGIX }, - { "glFragmentLightModelfSGIX", (GLvoid *) NAME(glFragmentLightModelfSGIX), _gloffset_FragmentLightModelfSGIX }, - { "glFragmentLightModelfvSGIX", (GLvoid *) NAME(glFragmentLightModelfvSGIX), _gloffset_FragmentLightModelfvSGIX }, - { "glFragmentLightModeliSGIX", (GLvoid *) NAME(glFragmentLightModeliSGIX), _gloffset_FragmentLightModeliSGIX }, - { "glFragmentLightModelivSGIX", (GLvoid *) NAME(glFragmentLightModelivSGIX), _gloffset_FragmentLightModelivSGIX }, - { "glFragmentMaterialfSGIX", (GLvoid *) NAME(glFragmentMaterialfSGIX), _gloffset_FragmentMaterialfSGIX }, - { "glFragmentMaterialfvSGIX", (GLvoid *) NAME(glFragmentMaterialfvSGIX), _gloffset_FragmentMaterialfvSGIX }, - { "glFragmentMaterialiSGIX", (GLvoid *) NAME(glFragmentMaterialiSGIX), _gloffset_FragmentMaterialiSGIX }, - { "glFragmentMaterialivSGIX", (GLvoid *) NAME(glFragmentMaterialivSGIX), _gloffset_FragmentMaterialivSGIX }, - { "glGetFragmentLightfvSGIX", (GLvoid *) NAME(glGetFragmentLightfvSGIX), _gloffset_GetFragmentLightfvSGIX }, - { "glGetFragmentLightivSGIX", (GLvoid *) NAME(glGetFragmentLightivSGIX), _gloffset_GetFragmentLightivSGIX }, - { "glGetFragmentMaterialfvSGIX", (GLvoid *) NAME(glGetFragmentMaterialfvSGIX), _gloffset_GetFragmentMaterialfvSGIX }, - { "glGetFragmentMaterialivSGIX", (GLvoid *) NAME(glGetFragmentMaterialivSGIX), _gloffset_GetFragmentMaterialivSGIX }, - { "glLightEnviSGIX", (GLvoid *) NAME(glLightEnviSGIX), _gloffset_LightEnviSGIX }, -#undef NAME - - /* 149. GL_EXT_fog_coord */ -#ifdef GL_EXT_fog_coord -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glFogCoordfEXT", (GLvoid *) NAME(glFogCoordfEXT), _gloffset_FogCoordfEXT }, - { "glFogCoordfvEXT", (GLvoid *) NAME(glFogCoordfvEXT), _gloffset_FogCoordfvEXT }, - { "glFogCoorddEXT", (GLvoid *) NAME(glFogCoorddEXT), _gloffset_FogCoorddEXT }, - { "glFogCoorddEXT", (GLvoid *) NAME(glFogCoorddEXT), _gloffset_FogCoorddEXT }, - { "glFogCoordPointerEXT", (GLvoid *) NAME(glFogCoordPointerEXT), _gloffset_FogCoordPointerEXT }, -#undef NAME - - /* 173. GL_EXT/INGR_blend_func_separate */ -#ifdef GL_EXT_blend_func_separate -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glBlendFuncSeparateEXT", (GLvoid *) NAME(glBlendFuncSeparateEXT), _gloffset_BlendFuncSeparateEXT }, - { "glBlendFuncSeparateINGR", (GLvoid *) NAME(glBlendFuncSeparateEXT), _gloffset_BlendFuncSeparateEXT }, -#undef NAME - /* 188. GL_EXT_vertex_weighting */ -#ifdef GL_EXT_vertex_weighting -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glVertexWeightfEXT", (GLvoid *) NAME(glVertexWeightfEXT), _gloffset_VertexWeightfEXT }, - { "glVertexWeightfvEXT", (GLvoid *) NAME(glVertexWeightfvEXT), _gloffset_VertexWeightfvEXT }, - { "glVertexWeightPointerEXT", (GLvoid *) NAME(glVertexWeightPointerEXT), _gloffset_VertexWeightPointerEXT }, -#undef NAME - - /* 190. GL_NV_vertex_array_range */ -#ifdef GL_NV_vertex_array_range -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glFlushVertexArrayRangeNV", (GLvoid *) NAME(glFlushVertexArrayRangeNV), _gloffset_FlushVertexArrayRangeNV }, - { "glVertexArrayRangeNV", (GLvoid *) NAME(glVertexArrayRangeNV), _gloffset_VertexArrayRangeNV }, -#undef NAME +/** + * Return dispatch function address the named static (built-in) function. + * Return NULL if function not found. + */ +static const _glapi_proc +get_static_proc_address(const char *funcName) +{ + const glprocs_table_t * const f = find_entry( funcName ); - /* 191. GL_NV_register_combiners */ -#ifdef GL_NV_register_combiners -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glCombinerParameterfvNV", (GLvoid *) NAME(glCombinerParameterfvNV), _gloffset_CombinerParameterfvNV }, - { "glCombinerParameterfNV", (GLvoid *) NAME(glCombinerParameterfNV), _gloffset_CombinerParameterfNV }, - { "glCombinerParameterivNV", (GLvoid *) NAME(glCombinerParameterivNV), _gloffset_CombinerParameterivNV }, - { "glCombinerParameteriNV", (GLvoid *) NAME(glCombinerParameteriNV), _gloffset_CombinerParameteriNV }, - { "glCombinerInputNV", (GLvoid *) NAME(glCombinerInputNV), _gloffset_CombinerInputNV }, - { "glCombinerOutputNV", (GLvoid *) NAME(glCombinerOutputNV), _gloffset_CombinerOutputNV }, - { "glFinalCombinerInputNV", (GLvoid *) NAME(glFinalCombinerInputNV), _gloffset_FinalCombinerInputNV }, - { "glGetCombinerInputParameterfvNV", (GLvoid *) NAME(glGetCombinerInputParameterfvNV), _gloffset_GetCombinerInputParameterfvNV }, - { "glGetCombinerInputParameterivNV", (GLvoid *) NAME(glGetCombinerInputParameterivNV), _gloffset_GetCombinerInputParameterivNV }, - { "glGetCombinerOutputParameterfvNV", (GLvoid *) NAME(glGetCombinerOutputParameterfvNV), _gloffset_GetCombinerOutputParameterfvNV }, - { "glGetCombinerOutputParameterivNV", (GLvoid *) NAME(glGetCombinerOutputParameterivNV), _gloffset_GetCombinerOutputParameterivNV }, - { "glGetFinalCombinerInputParameterfvNV", (GLvoid *) NAME(glGetFinalCombinerInputParameterfvNV), _gloffset_GetFinalCombinerInputParameterfvNV }, - { "glGetFinalCombinerInputParameterivNV", (GLvoid *) NAME(glGetFinalCombinerInputParameterivNV), _gloffset_GetFinalCombinerInputParameterivNV }, -#undef NAME - - /* 196. GL_MESA_resize_buffers */ -#ifdef MESA_resize_buffers -#define NAME(X) X -#else -#define NAME(X) NotImplemented -#endif - { "glResizeBuffersMESA", (GLvoid *) NAME(glResizeBuffersMESA), _gloffset_ResizeBuffersMESA }, -#undef NAME + if ( f != NULL ) { + return (_glapi_proc) (gl_dispatch_functions_start + + (X86_DISPATCH_FUNCTION_SIZE * f->Offset)); + } + else { + return NULL; + } +} - /* 197. GL_MESA_window_pos */ -#ifdef MESA_window_pos -#define NAME(X) X #else -#define NAME(X) NotImplemented -#endif - { "glWindowPos4fMESA", (GLvoid *) NAME(glWindowPos4fMESA), _gloffset_WindowPos4fMESA }, -#undef NAME - { NULL, NULL } /* end of list marker */ -}; +/** + * Return pointer to the named static (built-in) function. + * \return NULL if function not found. + */ +static const _glapi_proc +get_static_proc_address(const char *funcName) +{ + const glprocs_table_t * const f = find_entry( funcName ); + return ( f != NULL ) ? f->Address : NULL; +} +#endif /* USE_X86_ASM */ -/* - * Return dispatch table offset of the named static (built-in) function. - * Return -1 if function not found. +/** + * Return the name of the function at the given offset in the dispatch + * table. For debugging only. */ -static GLint -get_static_proc_offset(const char *funcName) +static const char * +get_static_proc_name( GLuint offset ) { GLuint i; - for (i = 0; static_functions[i].Name; i++) { - if (strcmp(static_functions[i].Name, funcName) == 0) { - return static_functions[i].Offset; + + for (i = 0; static_functions[i].Name_offset >= 0; i++) { + if (static_functions[i].Offset == offset) { + return gl_string_table + static_functions[i].Name_offset; } } - return -1; + return NULL; } + +/********************************************************************** + * Extension function management. + */ + /* - * Return dispatch function address the named static (built-in) function. - * Return NULL if function not found. + * Number of extension functions which we can dynamically add at runtime. */ -static GLvoid * -get_static_proc_address(const char *funcName) -{ - GLint i = get_static_proc_offset(funcName); - if (i >= 0) - return static_functions[i].Address; - else - return NULL; -} +#define MAX_EXTENSION_FUNCS 300 +/* + * The dispatch table size (number of entries) is the size of the + * _glapi_table struct plus the number of dynamic entries we can add. + * The extra slots can be filled in by DRI drivers that register new extension + * functions. + */ +#define DISPATCH_TABLE_SIZE (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS) -/********************************************************************** - * Extension function management. + +/** + * Track information about a function added to the GL API. */ +struct _glapi_function { + /** + * Name of the function. + */ + const char * name; -#define MAX_EXTENSION_FUNCS 1000 + /** + * Text string that describes the types of the parameters passed to the + * named function. Parameter types are converted to characters using the + * following rules: + * - 'i' for \c GLint, \c GLuint, and \c GLenum + * - 'p' for any pointer type + * - 'f' for \c GLfloat and \c GLclampf + * - 'd' for \c GLdouble and \c GLclampd + */ + const char * parameter_signature; -static struct name_address_offset ExtEntryTable[MAX_EXTENSION_FUNCS]; -static GLuint NumExtEntryPoints = 0; + /** + * Offset in the dispatch table where the pointer to the real function is + * located. If the driver has not requested that the named function be + * added to the dispatch table, this will have the value ~0. + */ + unsigned dispatch_offset; + + + /** + * Pointer to the dispatch stub for the named function. + * + * \todo + * The semantic of this field should be changed slightly. Currently, it + * is always expected to be non-\c NULL. However, it would be better to + * only allocate the entry-point stub when the application requests the + * function via \c glXGetProcAddress. This would save memory for all the + * functions that the driver exports but that the application never wants + * to call. + */ + _glapi_proc dispatch_stub; +}; -/* +static struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS]; +static GLuint NumExtEntryPoints = 0; + +#ifdef USE_SPARC_ASM +extern void __glapi_sparc_icache_flush(unsigned int *); +#endif + +/** * Generate a dispatch function (entrypoint) which jumps through * the given slot number (offset) in the current dispatch table. * We need assembly language in order to accomplish this. */ -static void * +static _glapi_proc generate_entrypoint(GLuint functionOffset) { #if defined(USE_X86_ASM) - /* - * This x86 code contributed by Josh Vanderhoof. - * - * 0: a1 10 32 54 76 movl __glapi_Dispatch,%eax - * 00 01 02 03 04 - * 5: 85 c0 testl %eax,%eax - * 05 06 - * 7: 74 06 je f - * 07 08 - * 9: ff a0 10 32 54 76 jmp *0x76543210(%eax) - * 09 0a 0b 0c 0d 0e - * f: e8 fc ff ff ff call __glapi_get_dispatch - * 0f 10 11 12 13 - * 14: ff a0 10 32 54 76 jmp *0x76543210(%eax) - * 14 15 16 17 18 19 + /* 32 is chosen as something of a magic offset. For x86, the dispatch + * at offset 32 is the first one where the offset in the + * "jmp OFFSET*4(%eax)" can't be encoded in a single byte. */ - static const unsigned char temp[] = { - 0xa1, 0x00, 0x00, 0x00, 0x00, - 0x85, 0xc0, - 0x74, 0x06, - 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00, - 0xe8, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00 + const GLubyte * const template_func = gl_dispatch_functions_start + + (X86_DISPATCH_FUNCTION_SIZE * 32); + GLubyte * const code = (GLubyte *) malloc( X86_DISPATCH_FUNCTION_SIZE ); + + + if ( code != NULL ) { + (void) memcpy( code, template_func, X86_DISPATCH_FUNCTION_SIZE ); + fill_in_entrypoint_offset( (_glapi_proc) code, functionOffset ); + } + + return (_glapi_proc) code; +#elif defined(USE_SPARC_ASM) + +#ifdef __arch64__ + static const unsigned int insn_template[] = { + 0x05000000, /* sethi %uhi(_glapi_Dispatch), %g2 */ + 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */ + 0x8410a000, /* or %g2, %ulo(_glapi_Dispatch), %g2 */ + 0x82106000, /* or %g1, %lo(_glapi_Dispatch), %g1 */ + 0x8528b020, /* sllx %g2, 32, %g2 */ + 0xc2584002, /* ldx [%g1 + %g2], %g1 */ + 0x05000000, /* sethi %hi(8 * glapioffset), %g2 */ + 0x8410a000, /* or %g2, %lo(8 * glapioffset), %g2 */ + 0xc6584002, /* ldx [%g1 + %g2], %g3 */ + 0x81c0c000, /* jmpl %g3, %g0 */ + 0x01000000 /* nop */ + }; +#else + static const unsigned int insn_template[] = { + 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */ + 0xc2006000, /* ld [%g1 + %lo(_glapi_Dispatch)], %g1 */ + 0xc6006000, /* ld [%g1 + %lo(4*glapioffset)], %g3 */ + 0x81c0c000, /* jmpl %g3, %g0 */ + 0x01000000 /* nop */ }; - unsigned char *code = malloc(sizeof(temp)); - unsigned int next_insn; +#endif + unsigned int *code = (unsigned int *) malloc(sizeof(insn_template)); + unsigned long glapi_addr = (unsigned long) &_glapi_Dispatch; if (code) { - memcpy(code, temp, sizeof(temp)); - - *(unsigned int *)(code + 0x01) = (unsigned int)&_glapi_Dispatch; - *(unsigned int *)(code + 0x0b) = (unsigned int)functionOffset * 4; - next_insn = (unsigned int)(code + 0x14); - *(unsigned int *)(code + 0x10) = (unsigned int)_glapi_get_dispatch - next_insn; - *(unsigned int *)(code + 0x16) = (unsigned int)functionOffset * 4; + memcpy(code, insn_template, sizeof(insn_template)); + +#ifdef __arch64__ + code[0] |= (glapi_addr >> (32 + 10)); + code[1] |= ((glapi_addr & 0xffffffff) >> 10); + __glapi_sparc_icache_flush(&code[0]); + code[2] |= ((glapi_addr >> 32) & ((1 << 10) - 1)); + code[3] |= (glapi_addr & ((1 << 10) - 1)); + __glapi_sparc_icache_flush(&code[2]); + code[6] |= ((functionOffset * 8) >> 10); + code[7] |= ((functionOffset * 8) & ((1 << 10) - 1)); + __glapi_sparc_icache_flush(&code[6]); +#else + code[0] |= (glapi_addr >> 10); + code[1] |= (glapi_addr & ((1 << 10) - 1)); + __glapi_sparc_icache_flush(&code[0]); + code[2] |= (functionOffset * 4); + __glapi_sparc_icache_flush(&code[2]); +#endif } - return code; + return (_glapi_proc) code; #else + (void) functionOffset; return NULL; -#endif +#endif /* USE_*_ASM */ } - -/* - * Add a new extension function entrypoint. - * Return: GL_TRUE = success or GL_FALSE = failure +/** + * This function inserts a new dispatch offset into the assembly language + * stub that was generated with the preceeding function. */ -GLboolean -_glapi_add_entrypoint(const char *funcName, GLuint offset) +static void +fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) { - /* Make sure we don't try to add a new entrypoint after someone - * has already called _glapi_get_dispatch_table_size()! If that's - * happened the caller's information will now be out of date. - */ - assert(!GetSizeCalled); +#if defined(USE_X86_ASM) + GLubyte * const code = (GLubyte *) entrypoint; + + +#if X86_DISPATCH_FUNCTION_SIZE == 32 + *((unsigned int *)(code + 11)) = 4 * offset; + *((unsigned int *)(code + 22)) = 4 * offset; +#elif X86_DISPATCH_FUNCTION_SIZE == 16 && defined( GLX_USE_TLS ) + *((unsigned int *)(code + 8)) = 4 * offset; +#elif X86_DISPATCH_FUNCTION_SIZE == 16 + *((unsigned int *)(code + 7)) = 4 * offset; +#else +# error Invalid X86_DISPATCH_FUNCTION_SIZE! +#endif - /* first check if the named function is already statically present */ - { - GLint index = get_static_proc_offset(funcName); - if (index >= 0) { - return (GLboolean) (index == offset); /* bad offset! */ - } - } +#elif defined(USE_SPARC_ASM) + + /* XXX this hasn't been tested! */ + unsigned int *code = (unsigned int *) entrypoint; +#ifdef __arch64__ + code[6] = 0x05000000; /* sethi %hi(8 * glapioffset), %g2 */ + code[7] = 0x8410a000; /* or %g2, %lo(8 * glapioffset), %g2 */ + code[6] |= ((offset * 8) >> 10); + code[7] |= ((offset * 8) & ((1 << 10) - 1)); + __glapi_sparc_icache_flush(&code[6]); +#else /* __arch64__ */ + code[2] = 0xc6006000; /* ld [%g1 + %lo(4*glapioffset)], %g3 */ + code[2] |= (offset * 4); + __glapi_sparc_icache_flush(&code[2]); +#endif /* __arch64__ */ - { - /* make sure this offset/name pair is legal */ - const char *name = _glapi_get_proc_name(offset); - if (name && strcmp(name, funcName) != 0) - return GL_FALSE; /* bad name! */ - } +#else - { - /* be sure index and name match known data */ - GLuint i; - for (i = 0; i < NumExtEntryPoints; i++) { - if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { - /* function already registered with api */ - if (ExtEntryTable[i].Offset == offset) { - return GL_TRUE; /* offsets match */ - } - else { - return GL_FALSE; /* bad offset! */ - } - } - } + /* an unimplemented architecture */ + (void) entrypoint; + (void) offset; - /* make sure we have space */ - if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS) { - return GL_FALSE; - } - else { - void *entrypoint = generate_entrypoint(offset); - if (!entrypoint) - return GL_FALSE; +#endif /* USE_*_ASM */ +} - ExtEntryTable[NumExtEntryPoints].Name = mesaStrdup(funcName); - ExtEntryTable[NumExtEntryPoints].Offset = offset; - ExtEntryTable[NumExtEntryPoints].Address = entrypoint; - NumExtEntryPoints++; - if (offset > MaxDispatchOffset) - MaxDispatchOffset = offset; +/** + * Generate new entrypoint + * + * Use a temporary dispatch offset of ~0 (i.e. -1). Later, when the driver + * calls \c _glapi_add_dispatch we'll put in the proper offset. If that + * never happens, and the user calls this function, he'll segfault. That's + * what you get when you try calling a GL function that doesn't really exist. + * + * \param funcName Name of the function to create an entry-point for. + * + * \sa _glapi_add_entrypoint + */ - return GL_TRUE; /* success */ +static struct _glapi_function * +add_function_name( const char * funcName ) +{ + struct _glapi_function * entry = NULL; + + if (NumExtEntryPoints < MAX_EXTENSION_FUNCS) { + _glapi_proc entrypoint = generate_entrypoint(~0); + if (entrypoint != NULL) { + entry = & ExtEntryTable[NumExtEntryPoints]; + + ExtEntryTable[NumExtEntryPoints].name = str_dup(funcName); + ExtEntryTable[NumExtEntryPoints].parameter_signature = NULL; + ExtEntryTable[NumExtEntryPoints].dispatch_offset = ~0; + ExtEntryTable[NumExtEntryPoints].dispatch_stub = entrypoint; + NumExtEntryPoints++; } } - /* should never get here, but play it safe */ - return GL_FALSE; + return entry; } - -#if 0000 /* prototype code for dynamic extension slot allocation */ - -static int NextFreeOffset = 409; /*XXX*/ -#define MAX_DISPATCH_TABLE_SIZE 1000 - -/* - * Dynamically allocate a dispatch slot for an extension entrypoint - * and generate the assembly language dispatch stub. - * Return the dispatch offset for the function or -1 if no room or error. +/** + * Fill-in the dispatch stub for the named function. + * + * This function is intended to be called by a hardware driver. When called, + * a dispatch stub may be created created for the function. A pointer to this + * dispatch function will be returned by glXGetProcAddress. + * + * \param function_names Array of pointers to function names that should + * share a common dispatch offset. + * \param parameter_signature String representing the types of the parameters + * passed to the named function. Parameter types + * are converted to characters using the following + * rules: + * - 'i' for \c GLint, \c GLuint, and \c GLenum + * - 'p' for any pointer type + * - 'f' for \c GLfloat and \c GLclampf + * - 'd' for \c GLdouble and \c GLclampd + * + * \returns + * The offset in the dispatch table of the named function. A pointer to the + * driver's implementation of the named function should be stored at + * \c dispatch_table[\c offset]. + * + * \sa glXGetProcAddress + * + * \warning + * This function can only handle up to 8 names at a time. As far as I know, + * the maximum number of names ever associated with an existing GL function is + * 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT, + * \c glPointParameterfARB, and \c glPointParameterf), so this should not be + * too painful of a limitation. + * + * \todo + * Determine whether or not \c parameter_signature should be allowed to be + * \c NULL. It doesn't seem like much of a hardship for drivers to have to + * pass in an empty string. + * + * \todo + * Determine if code should be added to reject function names that start with + * 'glX'. + * + * \bug + * Add code to compare \c parameter_signature with the parameter signature of + * a static function. In order to do that, we need to find a way to \b get + * the parameter signature of a static function. */ -GLint -_glapi_add_entrypoint2(const char *funcName) + +PUBLIC int +_glapi_add_dispatch( const char * const * function_names, + const char * parameter_signature ) { - int offset; - - /* first see if extension func is already known */ - offset = _glapi_get_proc_offset(funcName); - if (offset >= 0) - return offset; - - if (NumExtEntryPoints < MAX_EXTENSION_FUNCS - && NextFreeOffset < MAX_DISPATCH_TABLE_SIZE) { - void *entryPoint; - offset = NextFreeOffset; - entryPoint = generate_entrypoint(offset); - if (entryPoint) { - NextFreeOffset++; - ExtEntryTable[NumExtEntryPoints].Name = mesaStrdup(funcName); - ExtEntryTable[NumExtEntryPoints].Offset = offset; - ExtEntryTable[NumExtEntryPoints].Address = entryPoint; - NumExtEntryPoints++; - return offset; + static int next_dynamic_offset = _gloffset_FIRST_DYNAMIC; + const char * const real_sig = (parameter_signature != NULL) + ? parameter_signature : ""; + struct _glapi_function * entry[8]; + GLboolean is_static[8]; + unsigned i; + unsigned j; + int offset = ~0; + int new_offset; + + + (void) memset( is_static, 0, sizeof( is_static ) ); + (void) memset( entry, 0, sizeof( entry ) ); + + for ( i = 0 ; function_names[i] != NULL ; i++ ) { + /* Do some trivial validation on the name of the function. + */ + +#ifdef MANGLE + if (!function_names[i] || function_names[i][0] != 'm' || function_names[i][1] != 'g' || function_names[i][2] != 'l') + return GL_FALSE; +#else + if (!function_names[i] || function_names[i][0] != 'g' || function_names[i][1] != 'l') + return GL_FALSE; +#endif + + + /* Determine if the named function already exists. If the function does + * exist, it must have the same parameter signature as the function + * being added. + */ + + new_offset = get_static_proc_offset(function_names[i]); + if (new_offset >= 0) { + /* FIXME: Make sure the parameter signatures match! How do we get + * FIXME: the parameter signature for static functions? + */ + + if ( (offset != ~0) && (new_offset != offset) ) { + return -1; + } + + is_static[i] = GL_TRUE; + offset = new_offset; + } + + + for ( j = 0 ; j < NumExtEntryPoints ; j++ ) { + if (strcmp(ExtEntryTable[j].name, function_names[i]) == 0) { + /* The offset may be ~0 if the function name was added by + * glXGetProcAddress but never filled in by the driver. + */ + + if (ExtEntryTable[j].dispatch_offset != ~0) { + if (strcmp(real_sig, ExtEntryTable[j].parameter_signature) + != 0) { + return -1; + } + + if ( (offset != ~0) && (ExtEntryTable[j].dispatch_offset != offset) ) { + return -1; + } + + offset = ExtEntryTable[j].dispatch_offset; + } + + entry[i] = & ExtEntryTable[j]; + break; + } } } - return -1; -} -#endif + if (offset == ~0) { + offset = next_dynamic_offset; + next_dynamic_offset++; + } -/* + for ( i = 0 ; function_names[i] != NULL ; i++ ) { + if (! is_static[i] ) { + if (entry[i] == NULL) { + entry[i] = add_function_name( function_names[i] ); + if (entry[i] == NULL) { + /* FIXME: Possible memory leak here. + */ + return -1; + } + } + + + entry[i]->parameter_signature = str_dup(real_sig); + fill_in_entrypoint_offset(entry[i]->dispatch_stub, offset); + entry[i]->dispatch_offset = offset; + } + } + + return offset; +} + + +/** * Return offset of entrypoint for named function within dispatch table. */ -GLint +PUBLIC GLint _glapi_get_proc_offset(const char *funcName) { /* search extension functions first */ - GLint i; + GLuint i; for (i = 0; i < NumExtEntryPoints; i++) { - if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { - return ExtEntryTable[i].Offset; + if (strcmp(ExtEntryTable[i].name, funcName) == 0) { + return ExtEntryTable[i].dispatch_offset; } } @@ -1422,45 +1058,65 @@ _glapi_get_proc_offset(const char *funcName) -/* - * Return entrypoint for named function. +/** + * Return pointer to the named function. If the function name isn't found + * in the name of static functions, try generating a new API entrypoint on + * the fly with assembly language. */ -const GLvoid * +PUBLIC _glapi_proc _glapi_get_proc_address(const char *funcName) { + struct _glapi_function * entry; + GLuint i; + +#ifdef MANGLE + if (funcName[0] != 'm' || funcName[1] != 'g' || funcName[2] != 'l') + return NULL; +#else + if (funcName[0] != 'g' || funcName[1] != 'l') + return NULL; +#endif + /* search extension functions first */ - GLint i; for (i = 0; i < NumExtEntryPoints; i++) { - if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { - return ExtEntryTable[i].Address; + if (strcmp(ExtEntryTable[i].name, funcName) == 0) { + return ExtEntryTable[i].dispatch_stub; } } /* search static functions */ - return get_static_proc_address(funcName); -} + { + const _glapi_proc func = get_static_proc_address(funcName); + if (func) + return func; + } + entry = add_function_name(funcName); + return (entry == NULL) ? NULL : entry->dispatch_stub; +} -/* +/** * Return the name of the function at the given dispatch offset. * This is only intended for debugging. */ -const char * +PUBLIC const char * _glapi_get_proc_name(GLuint offset) { - const GLuint n = sizeof(static_functions) / sizeof(struct name_address_offset); GLuint i; - for (i = 0; i < n; i++) { - if (static_functions[i].Offset == offset) - return static_functions[i].Name; + const char * n; + + /* search built-in functions */ + n = get_static_proc_name(offset); + if ( n != NULL ) { + return n; } /* search added extension functions */ for (i = 0; i < NumExtEntryPoints; i++) { - if (ExtEntryTable[i].Offset == offset) { - return ExtEntryTable[i].Name; + if (ExtEntryTable[i].dispatch_offset == offset) { + return ExtEntryTable[i].name; } } return NULL; @@ -1468,13 +1124,37 @@ _glapi_get_proc_name(GLuint offset) -/* +/** + * Return size of dispatch table struct as number of functions (or + * slots). + */ +PUBLIC GLuint +_glapi_get_dispatch_table_size(void) +{ + return DISPATCH_TABLE_SIZE; +} + + + +/** + * Get API dispatcher version string. + */ +PUBLIC const char * +_glapi_get_version(void) +{ + return "20021001"; /* YYYYMMDD */ +} + + + +/** * Make sure there are no NULL pointers in the given dispatch table. - * Intented for debugging purposes. + * Intended for debugging purposes. */ -void +PUBLIC void _glapi_check_table(const struct _glapi_table *table) { +#ifdef DEBUG const GLuint entries = _glapi_get_dispatch_table_size(); const void **tab = (const void **) table; GLuint i; @@ -1482,7 +1162,6 @@ _glapi_check_table(const struct _glapi_table *table) assert(tab[i]); } -#ifdef DEBUG /* Do some spot checks to be sure that the dispatch table * slots are assigned correctly. */ @@ -1528,9 +1207,53 @@ _glapi_check_table(const struct _glapi_table *table) assert(istextureOffset == _gloffset_IsTextureEXT); assert(istextureOffset == offset); } + { + GLuint secondaryColor3fOffset = _glapi_get_proc_offset("glSecondaryColor3fEXT"); + char *secondaryColor3fFunc = (char*) &table->SecondaryColor3fEXT; + GLuint offset = (secondaryColor3fFunc - (char *) table) / sizeof(void *); + assert(secondaryColor3fOffset == _gloffset_SecondaryColor3fEXT); + assert(secondaryColor3fOffset == offset); + assert(_glapi_get_proc_address("glSecondaryColor3fEXT") == (_glapi_proc) &glSecondaryColor3fEXT); + } + { + GLuint pointParameterivOffset = _glapi_get_proc_offset("glPointParameterivNV"); + char *pointParameterivFunc = (char*) &table->PointParameterivNV; + GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *); + assert(pointParameterivOffset == _gloffset_PointParameterivNV); + assert(pointParameterivOffset == offset); + assert(_glapi_get_proc_address("glPointParameterivNV") == (_glapi_proc) &glPointParameterivNV); + } + { + GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV"); + char *setFenceFunc = (char*) &table->SetFenceNV; + GLuint offset = (setFenceFunc - (char *) table) / sizeof(void *); + assert(setFenceOffset == _gloffset_SetFenceNV); + assert(setFenceOffset == offset); + assert(_glapi_get_proc_address("glSetFenceNV") == (_glapi_proc) &glSetFenceNV); + } +#else + (void) table; #endif } +/** + * Perform platform-specific GL API entry-point fixups. + * + * + */ +static void +init_glapi_relocs( void ) +{ +#if defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) + extern void * _x86_get_dispatch(void); + const GLubyte * const get_disp = (const GLubyte *) _x86_get_dispatch; + GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start; + while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) { + (void) memcpy( curr_func, get_disp, 6 ); + curr_func += X86_DISPATCH_FUNCTION_SIZE; + } +#endif /* defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) */ +}