diff options
author | marha <marha@users.sourceforge.net> | 2011-03-10 09:49:29 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-03-10 09:49:29 +0000 |
commit | f81bb3160c5f39d8f7ad329e99865af88f02b96a (patch) | |
tree | e12e90b1707bed3f4fdd6a3901f4cbcbe76d0b34 /xorg-server/glx | |
parent | 8c74e7257ed453143c53086f884f6c6ff585379a (diff) | |
download | vcxsrv-f81bb3160c5f39d8f7ad329e99865af88f02b96a.tar.gz vcxsrv-f81bb3160c5f39d8f7ad329e99865af88f02b96a.tar.bz2 vcxsrv-f81bb3160c5f39d8f7ad329e99865af88f02b96a.zip |
xserver mesa git update 10 Mar 2011
Diffstat (limited to 'xorg-server/glx')
-rw-r--r-- | xorg-server/glx/glapi.c | 205 | ||||
-rw-r--r-- | xorg-server/glx/glapi.h | 22 | ||||
-rw-r--r-- | xorg-server/glx/glthread.c | 162 | ||||
-rw-r--r-- | xorg-server/glx/glthread.h | 69 |
4 files changed, 5 insertions, 453 deletions
diff --git a/xorg-server/glx/glapi.c b/xorg-server/glx/glapi.c index d6a568e88..209ae50c0 100644 --- a/xorg-server/glx/glapi.c +++ b/xorg-server/glx/glapi.c @@ -175,12 +175,6 @@ static GLint NoOpUnused(void) * static dispatch functions access these variables via \c _glapi_get_dispatch * and \c _glapi_get_context. * - * There is a race condition in setting \c _glapi_Dispatch 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. - * * In the TLS case, the variables \c _glapi_Dispatch and \c _glapi_Context are * hardcoded to \c NULL. Instead the TLS variables \c _glapi_tls_Dispatch and * \c _glapi_tls_Context are used. Having \c _glapi_Dispatch and @@ -204,7 +198,6 @@ PUBLIC const void *_glapi_Context = NULL; #if defined(THREADS) -static GLboolean ThreadSafe = GL_FALSE; /**< In thread-safe mode? */ _glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */ static _glthread_TSD ContextTSD; /**< Per-thread context pointer */ @@ -243,37 +236,14 @@ str_dup(const char *str) } - -/** - * We should call this periodically from a function such as glXMakeCurrent - * in order to test if multiple threads are being used. +/* + * xserver's gl is not multithreaded, we promise. */ PUBLIC void _glapi_check_multithread(void) { -#if defined(THREADS) && !defined(GLX_USE_TLS) - if (!ThreadSafe) { - static unsigned long knownID; - static GLboolean firstCall = GL_TRUE; - if (firstCall) { - knownID = _glthread_GetID(); - firstCall = GL_FALSE; - } - else if (knownID != _glthread_GetID()) { - ThreadSafe = GL_TRUE; - _glapi_set_dispatch(NULL); - _glapi_set_context(NULL); - } - } - else if (!_glapi_get_dispatch()) { - /* make sure that this thread's dispatch pointer isn't 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 @@ -287,7 +257,7 @@ _glapi_set_context(void *context) _glapi_tls_Context = context; #elif defined(THREADS) _glthread_SetTSD(&ContextTSD, context); - _glapi_Context = (ThreadSafe) ? NULL : context; + _glapi_Context = context; #else _glapi_Context = context; #endif @@ -305,13 +275,6 @@ _glapi_get_context(void) { #if defined(GLX_USE_TLS) return _glapi_tls_Context; -#elif defined(THREADS) - if (ThreadSafe) { - return _glthread_GetTSD(&ContextTSD); - } - else { - return _glapi_Context; - } #else return _glapi_Context; #endif @@ -336,17 +299,12 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) /* use the no-op functions */ dispatch = (struct _glapi_table *) __glapi_noop_table; } -#ifdef DEBUG - else { - _glapi_check_table(dispatch); - } -#endif #if defined(GLX_USE_TLS) _glapi_tls_Dispatch = dispatch; #elif defined(THREADS) _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch); - _glapi_Dispatch = (ThreadSafe) ? NULL : dispatch; + _glapi_Dispatch = dispatch; #else /*THREADS*/ _glapi_Dispatch = dispatch; #endif /*THREADS*/ @@ -363,10 +321,6 @@ _glapi_get_dispatch(void) struct _glapi_table * api; #if defined(GLX_USE_TLS) api = _glapi_tls_Dispatch; -#elif defined(THREADS) - api = (ThreadSafe) - ? (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD) - : _glapi_Dispatch; #else api = _glapi_Dispatch; #endif @@ -472,26 +426,6 @@ get_static_proc_address(const char *funcName) #endif /* !defined(XFree86Server) && !defined(XGLServer) */ - - -/** - * Return the name of the function at the given offset in the dispatch - * table. For debugging only. - */ -static const char * -get_static_proc_name( GLuint offset ) -{ - GLuint i; - 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 NULL; -} - - - /********************************************************************** * Extension function management. */ @@ -867,26 +801,6 @@ _glapi_add_dispatch( const char * const * function_names, return offset; } - -/** - * Return offset of entrypoint for named function within dispatch table. - */ -PUBLIC GLint -_glapi_get_proc_offset(const char *funcName) -{ - /* search extension functions first */ - GLuint i; - for (i = 0; i < NumExtEntryPoints; i++) { - if (strcmp(ExtEntryTable[i].name, funcName) == 0) { - return ExtEntryTable[i].dispatch_offset; - } - } - /* search static functions */ - return get_static_proc_offset(funcName); -} - - - /** * 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 @@ -926,35 +840,6 @@ _glapi_get_proc_address(const char *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 * -_glapi_get_proc_name(GLuint offset) -{ - GLuint i; - 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].dispatch_offset == offset) { - return ExtEntryTable[i].name; - } - } - return NULL; -} - - - /** * Return size of dispatch table struct as number of functions (or * slots). @@ -965,88 +850,6 @@ _glapi_get_dispatch_table_size(void) return DISPATCH_TABLE_SIZE; } - - -/** - * Make sure there are no NULL pointers in the given dispatch table. - * Intended for debugging purposes. - */ -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; - for (i = 1; i < entries; i++) { - assert(tab[i]); - } - - /* Do some spot checks to be sure that the dispatch table - * slots are assigned correctly. - */ - { - GLuint BeginOffset = _glapi_get_proc_offset("glBegin"); - char *BeginFunc = (char*) &table->Begin; - GLuint offset = (BeginFunc - (char *) table) / sizeof(void *); - assert(BeginOffset == _gloffset_Begin); - assert(BeginOffset == offset); - } - { - GLuint viewportOffset = _glapi_get_proc_offset("glViewport"); - char *viewportFunc = (char*) &table->Viewport; - GLuint offset = (viewportFunc - (char *) table) / sizeof(void *); - assert(viewportOffset == _gloffset_Viewport); - assert(viewportOffset == offset); - } - { - GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer"); - char *VertexPointerFunc = (char*) &table->VertexPointer; - GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *); - assert(VertexPointerOffset == _gloffset_VertexPointer); - assert(VertexPointerOffset == offset); - } - { - GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax"); - char *ResetMinMaxFunc = (char*) &table->ResetMinmax; - GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *); - assert(ResetMinMaxOffset == _gloffset_ResetMinmax); - assert(ResetMinMaxOffset == offset); - } - { - GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor"); - char *blendColorFunc = (char*) &table->BlendColor; - GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *); - assert(blendColorOffset == _gloffset_BlendColor); - assert(blendColorOffset == 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); - } - { - 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); - } - { - 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); - } -#else - (void) table; -#endif -} - - #if defined(PTHREADS) || defined(GLX_USE_TLS) /** * Perform platform-specific GL API entry-point fixups. diff --git a/xorg-server/glx/glapi.h b/xorg-server/glx/glapi.h index 8f2cf6621..80b53aa92 100644 --- a/xorg-server/glx/glapi.h +++ b/xorg-server/glx/glapi.h @@ -115,57 +115,35 @@ _glapi_set_warning_func(_glapi_warning_func func); extern void _glapi_check_multithread(void); - extern void _glapi_set_context(void *context); - extern void * _glapi_get_context(void); - extern void _glapi_set_dispatch(struct _glapi_table *dispatch); - extern struct _glapi_table * _glapi_get_dispatch(void); - extern int _glapi_begin_dispatch_override(struct _glapi_table *override); - extern void _glapi_end_dispatch_override(int layer); - struct _glapi_table * _glapi_get_override_dispatch(int layer); - extern GLuint _glapi_get_dispatch_table_size(void); - -extern void -_glapi_check_table(const struct _glapi_table *table); - - extern int _glapi_add_dispatch( const char * const * function_names, const char * parameter_signature ); -extern GLint -_glapi_get_proc_offset(const char *funcName); - - extern _glapi_proc _glapi_get_proc_address(const char *funcName); - -extern const char * -_glapi_get_proc_name(GLuint offset); - - #endif diff --git a/xorg-server/glx/glthread.c b/xorg-server/glx/glthread.c index 8b9f61885..5da7e433c 100644 --- a/xorg-server/glx/glthread.c +++ b/xorg-server/glx/glthread.c @@ -114,76 +114,6 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) #endif /* PTHREADS */ - - -/* - * Solaris/Unix International Threads -- Use only if POSIX threads - * aren't available on your Unix platform. Solaris 2.[34] are examples - * of platforms where this is the case. Be sure to use -mt and/or - * -D_REENTRANT when compiling. - */ -#ifdef SOLARIS_THREADS -#define USE_LOCK_FOR_KEY /* undef this to try a version without - lock for the global key... */ - -_X_EXPORT unsigned long -_glthread_GetID(void) -{ - OsAbort(); /* XXX not implemented yet */ - return (unsigned long) 0; -} - - -void -_glthread_InitTSD(_glthread_TSD *tsd) -{ - if ((errno = mutex_init(&tsd->keylock, 0, NULL)) != 0 || - (errno = thr_keycreate(&(tsd->key), free)) != 0) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd->initMagic = INIT_MAGIC; -} - - -void * -_glthread_GetTSD(_glthread_TSD *tsd) -{ - void* ret; - if (tsd->initMagic != INIT_MAGIC) { - _glthread_InitTSD(tsd); - } -#ifdef USE_LOCK_FOR_KEY - mutex_lock(&tsd->keylock); - thr_getspecific(tsd->key, &ret); - mutex_unlock(&tsd->keylock); -#else - if ((errno = thr_getspecific(tsd->key, &ret)) != 0) { - perror(GET_TSD_ERROR); - exit(-1); - } -#endif - return ret; -} - - -void -_glthread_SetTSD(_glthread_TSD *tsd, void *ptr) -{ - if (tsd->initMagic != INIT_MAGIC) { - _glthread_InitTSD(tsd); - } - if ((errno = thr_setspecific(tsd->key, ptr)) != 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - -#undef USE_LOCK_FOR_KEY -#endif /* SOLARIS_THREADS */ - - - /* * Win32 Threads. The only available option for Windows 95/NT. * Be sure that you compile using the Multithreaded runtime, otherwise @@ -249,100 +179,8 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) #endif /* WIN32_THREADS */ - - -/* - * XFree86 has its own thread wrapper, Xthreads.h - * We wrap it again for GL. - */ -#ifdef USE_XTHREADS - -_X_EXPORT unsigned long -_glthread_GetID(void) -{ - return (unsigned long) xthread_self(); -} - - -void -_glthread_InitTSD(_glthread_TSD *tsd) -{ - if (xthread_key_create(&tsd->key, NULL) != 0) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd->initMagic = INIT_MAGIC; -} - - -void * -_glthread_GetTSD(_glthread_TSD *tsd) -{ - void *ptr; - if (tsd->initMagic != INIT_MAGIC) { - _glthread_InitTSD(tsd); - } - xthread_get_specific(tsd->key, &ptr); - return ptr; -} - - -void -_glthread_SetTSD(_glthread_TSD *tsd, void *ptr) -{ - if (tsd->initMagic != INIT_MAGIC) { - _glthread_InitTSD(tsd); - } - xthread_set_specific(tsd->key, ptr); -} - -#endif /* XTHREAD */ - - - -/* - * BeOS threads - */ -#ifdef BEOS_THREADS - -unsigned long -_glthread_GetID(void) -{ - return (unsigned long) find_thread(NULL); -} - -void -_glthread_InitTSD(_glthread_TSD *tsd) -{ - tsd->key = tls_allocate(); - tsd->initMagic = INIT_MAGIC; -} - -void * -_glthread_GetTSD(_glthread_TSD *tsd) -{ - if (tsd->initMagic != (int) INIT_MAGIC) { - _glthread_InitTSD(tsd); - } - return tls_get(tsd->key); -} - -void -_glthread_SetTSD(_glthread_TSD *tsd, void *ptr) -{ - if (tsd->initMagic != (int) INIT_MAGIC) { - _glthread_InitTSD(tsd); - } - tls_set(tsd->key, ptr); -} - -#endif /* BEOS_THREADS */ - - - #else /* THREADS */ - /* * no-op functions */ diff --git a/xorg-server/glx/glthread.h b/xorg-server/glx/glthread.h index e2765cebb..28793fcc7 100644 --- a/xorg-server/glx/glthread.h +++ b/xorg-server/glx/glthread.h @@ -68,10 +68,7 @@ #define _glapi_Dispatch _mglapi_Dispatch #endif - - -#if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\ - defined(WIN32_THREADS) || defined(USE_XTHREADS) || defined(BEOS_THREADS)) \ +#if (defined(PTHREADS) || defined(WIN32_THREADS)) \ && !defined(THREADS) # define THREADS #endif @@ -127,27 +124,6 @@ typedef pthread_mutex_t _glthread_Mutex; * Be sure to compile with -mt on the Solaris compilers, or * use -D_REENTRANT if using gcc. */ -#ifdef SOLARIS_THREADS -#include <thread.h> - -typedef struct { - thread_key_t key; - mutex_t keylock; - int initMagic; -} _glthread_TSD; - -typedef thread_t _glthread_Thread; - -typedef mutex_t _glthread_Mutex; - -/* XXX need to really implement mutex-related macros */ -#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0 -#define _glthread_INIT_MUTEX(name) (void) name -#define _glthread_DESTROY_MUTEX(name) (void) name -#define _glthread_LOCK_MUTEX(name) (void) name -#define _glthread_UNLOCK_MUTEX(name) (void) name - -#endif /* SOLARIS_THREADS */ @@ -177,49 +153,6 @@ typedef CRITICAL_SECTION _glthread_Mutex; #endif /* WIN32_THREADS */ - - - -/* - * XFree86 has its own thread wrapper, Xthreads.h - * We wrap it again for GL. - */ -#ifdef USE_XTHREADS -#include <X11/Xthreads.h> - -typedef struct { - xthread_key_t key; - int initMagic; -} _glthread_TSD; - -typedef xthread_t _glthread_Thread; - -typedef xmutex_rec _glthread_Mutex; - -#ifdef XMUTEX_INITIALIZER -#define _glthread_DECLARE_STATIC_MUTEX(name) \ - static _glthread_Mutex name = XMUTEX_INITIALIZER -#else -#define _glthread_DECLARE_STATIC_MUTEX(name) \ - static _glthread_Mutex name -#endif - -#define _glthread_INIT_MUTEX(name) \ - xmutex_init(&(name)) - -#define _glthread_DESTROY_MUTEX(name) \ - xmutex_clear(&(name)) - -#define _glthread_LOCK_MUTEX(name) \ - (void) xmutex_lock(&(name)) - -#define _glthread_UNLOCK_MUTEX(name) \ - (void) xmutex_unlock(&(name)) - -#endif /* USE_XTHREADS */ - - - /* * BeOS threads. R5.x required. */ |