diff options
author | brianp <brianp> | 2000-02-12 23:09:21 +0000 |
---|---|---|
committer | brianp <brianp> | 2000-02-12 23:09:21 +0000 |
commit | 9232e84c16da284b2ce68e441004df381cec7e91 (patch) | |
tree | 34d9b5a50f95d08bbb27a542bd659dd002d88ad3 /xc/lib/GL/glx | |
parent | 40bd68454309639eebe1c2cee60a61f7fcff0520 (diff) |
Merged dispatch-0-0-2
Diffstat (limited to 'xc/lib/GL/glx')
-rw-r--r-- | xc/lib/GL/glx/Imakefile | 2 | ||||
-rw-r--r-- | xc/lib/GL/glx/glxclient.h | 5 | ||||
-rw-r--r-- | xc/lib/GL/glx/glxcmds.c | 96 | ||||
-rw-r--r-- | xc/lib/GL/glx/glxext.c | 62 | ||||
-rw-r--r-- | xc/lib/GL/glx/indirect_init.c | 26 |
5 files changed, 161 insertions, 30 deletions
diff --git a/xc/lib/GL/glx/Imakefile b/xc/lib/GL/glx/Imakefile index 21c837814..78c64de4d 100644 --- a/xc/lib/GL/glx/Imakefile +++ b/xc/lib/GL/glx/Imakefile @@ -16,6 +16,8 @@ XCOMM 1999. The developer of the Original Software is Silicon Graphics, Inc. XCOMM Those portions of the Subject Software created by Silicon Graphics, Inc. XCOMM are Copyright (c) 1991-9 Silicon Graphics, Inc. All Rights Reserved. +#include <Threads.tmpl> + #define DoNormalLib NormalLibGlx #define DoSharedLib SharedLibGlx #define DoExtraLib SharedLibGlx diff --git a/xc/lib/GL/glx/glxclient.h b/xc/lib/GL/glx/glxclient.h index 810570b90..6673e5cf9 100644 --- a/xc/lib/GL/glx/glxclient.h +++ b/xc/lib/GL/glx/glxclient.h @@ -544,9 +544,14 @@ extern __GLXdisplayPrivate *__glXInitialize(Display*); extern int __glXDebug; /* This is per-thread storage in an MT environment */ +#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS) +extern __GLXcontext *__glXGetCurrentContext(void); +extern void __glXSetCurrentContext(__GLXcontext *c); +#else extern __GLXcontext *__glXcurrentContext; #define __glXGetCurrentContext() __glXcurrentContext #define __glXSetCurrentContext(gc) __glXcurrentContext = gc +#endif /* diff --git a/xc/lib/GL/glx/glxcmds.c b/xc/lib/GL/glx/glxcmds.c index 51bd9b9e2..7ad820bf1 100644 --- a/xc/lib/GL/glx/glxcmds.c +++ b/xc/lib/GL/glx/glxcmds.c @@ -25,8 +25,7 @@ * * Authors: * Kevin E. Martin <kevin@precisioninsight.com> - * - * $PI: xc/lib/GL/glx/glxcmds.c,v 1.8 1999/06/10 04:39:13 martin Exp $ + * Brian Paul <brian@precisioninsight.com> */ #include "packsingle.h" @@ -34,6 +33,7 @@ #include <extutil.h> #include <Xext.h> #include <string.h> +#include "glapi.h" #ifdef GLX_DIRECT_RENDERING #include "indirect_init.h" #endif @@ -1487,3 +1487,95 @@ void glXFreeContextEXT(Display *dpy, GLXContext ctx) DestroyContext(dpy, ctx); } + +/* +** glXGetProcAddress support +*/ + + +struct name_address_pair { + const char *Name; + GLvoid *Address; +}; + +static struct name_address_pair GLX_functions[] = { + { "glXChooseVisual", (GLvoid *) glXChooseVisual }, + { "glXCopyContext", (GLvoid *) glXCopyContext }, + { "glXCreateContext", (GLvoid *) glXCreateContext }, + { "glXCreateGLXPixmap", (GLvoid *) glXCreateGLXPixmap }, + { "glXDestroyContext", (GLvoid *) glXDestroyContext }, + { "glXDestroyGLXPixmap", (GLvoid *) glXDestroyGLXPixmap }, + { "glXGetConfig", (GLvoid *) glXGetConfig }, + { "glXGetCurrentContext", (GLvoid *) glXGetCurrentContext }, + { "glXGetCurrentDrawable", (GLvoid *) glXGetCurrentDrawable }, + { "glXIsDirect", (GLvoid *) glXIsDirect }, + { "glXMakeCurrent", (GLvoid *) glXMakeCurrent }, + { "glXQueryExtension", (GLvoid *) glXQueryExtension }, + { "glXQueryVersion", (GLvoid *) glXQueryVersion }, + { "glXSwapBuffers", (GLvoid *) glXSwapBuffers }, + { "glXUseXFont", (GLvoid *) glXUseXFont }, + { "glXWaitGL", (GLvoid *) glXWaitGL }, + { "glXWaitX", (GLvoid *) glXWaitX }, + + { "glXGetClientString", (GLvoid *) glXGetClientString }, + { "glXQueryExtensionsString", (GLvoid *) glXQueryExtensionsString }, + { "glXQueryServerString", (GLvoid *) glXQueryServerString }, + + { "glXGetCurrentDisplay", (GLvoid *) glXGetCurrentDisplay }, + +#if 0 /* enable this when GLX 1.3 is implemented */ + { "glXChooseFBConfig", (GLvoid *) glXChooseFBConfig }, + { "glXCreateNewContext", (GLvoid *) glXCreateNewContext }, + { "glXCreatePbuffer", (GLvoid *) glXCreatePbuffer }, + { "glXCreatePixmap", (GLvoid *) glXCreatePixmap }, + { "glXCreateWindow", (GLvoid *) glXCreateWindow }, + { "glXDestroyPbuffer", (GLvoid *) glXDestroyPbuffer }, + { "glXDestroyPixmap", (GLvoid *) glXDestroyPixmap }, + { "glXDestroyWindow", (GLvoid *) glXDestroyWindow }, + { "glXGetCurrentReadDrawable", (GLvoid *) glXGetCurrentReadDrawable }, + { "glXGetFBConfigAttrib", (GLvoid *) glXGetFBConfigAttrib }, + { "glXGetSelectedEvent", (GLvoid *) glXGetSelectedEvent }, + { "glXGetVisualFromFBConfig", (GLvoid *) glXGetVisualFromFBConfig }, + { "glXMakeContextCurrent", (GLvoid *) glXMakeContextCurrent }, + { "glXQueryContext", (GLvoid *) glXQueryContext }, + { "glXQueryDrawable", (GLvoid *) glXQueryDrawable }, + { "glXSelectEvent", (GLvoid *) glXSelectEvent }, +#endif + + /* extension functions */ + { "glXGetContextIDEXT", (GLvoid *) glXGetContextIDEXT }, + { "glXGetCurrentDrawableEXT", (GLvoid *) glXGetCurrentDrawableEXT }, + { "glXImportContextEXT", (GLvoid *) glXImportContextEXT }, + { "glXFreeContextEXT", (GLvoid *) glXFreeContextEXT }, + { "glXQueryContextInfoEXT", (GLvoid *) glXQueryContextInfoEXT }, + { "glXGetProcAddressARB", (GLvoid *) glXGetProcAddressARB }, + + { NULL, NULL } /* end of list */ +}; + + +static const GLvoid * +get_glx_proc_address(const char *funcName) +{ + GLuint i; + for (i = 0; GLX_functions[i].Name; i++) { + if (strcmp(GLX_functions[i].Name, funcName) == 0) + return GLX_functions[i].Address; + } + return NULL; +} + + +void (*glXGetProcAddressARB(const GLubyte *procName))() +{ + typedef void (*gl_function)(); + gl_function f; + + f = (gl_function) get_glx_proc_address((const char *) procName); + if (f) { + return f; + } + + f = (gl_function) _glapi_get_proc_address((const char *) procName); + return f; +} diff --git a/xc/lib/GL/glx/glxext.c b/xc/lib/GL/glx/glxext.c index 49873ae73..c69c882fe 100644 --- a/xc/lib/GL/glx/glxext.c +++ b/xc/lib/GL/glx/glxext.c @@ -36,6 +36,9 @@ #include "indirect_init.h" #include "glapi.h" #include <assert.h> +#ifdef XTHREADS +#include "Xthreads.h" +#endif #endif #ifdef DEBUG @@ -72,8 +75,49 @@ static __GLapi *IndirectAPI = NULL; #endif +/* + * Current context management + */ + +#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS) + +/* thread safe */ +static GLboolean TSDinitialized = GL_FALSE; +static xthread_key_t ContextTSD; + +__GLXcontext *__glXGetCurrentContext(void) +{ + if (!TSDinitialized) { + xthread_key_create(&ContextTSD, NULL); + TSDinitialized = GL_TRUE; + return &dummyContext; + } + else { + void *p; + xthread_get_specific(ContextTSD, &p); + if (!p) + return &dummyContext; + else + return (__GLXcontext *) p; + } +} + +void __glXSetCurrentContext(__GLXcontext *c) +{ + if (!TSDinitialized) { + xthread_key_create(&ContextTSD, NULL); + TSDinitialized = GL_TRUE; + } + xthread_set_specific(ContextTSD, c); +} + +#else + +/* not thread safe */ __GLXcontext *__glXcurrentContext = &dummyContext; +#endif + /* ** You can set this cell to 1 to force the gl drawing stuff to be @@ -411,15 +455,6 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy) XEDataObject dataObj; int major, minor; -#ifdef GLX_DIRECT_RENDERING - /* - **Initialize the indirect GLX dispatch table. It'll never change and - ** can be used by all indirect contexts. - */ - if (!IndirectAPI) - IndirectAPI = __glXNewIndirectAPI(); -#endif - /* The one and only long long lock */ __glXLock(); @@ -505,6 +540,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy) __glXClientInfo(dpy, dpyPriv->majorOpcode); } __glXUnlock(); + return dpyPriv; } @@ -897,9 +933,15 @@ Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc) __glXSetCurrentContext(gc); #ifdef GLX_DIRECT_RENDERING if (!gc->isDirect) { - assert(IndirectAPI); + if (!IndirectAPI) + IndirectAPI = __glXNewIndirectAPI(); _glapi_set_dispatch(IndirectAPI); } +#else + /* if not direct rendering, always need indirect dispatch */ + if (!IndirectAPI) + IndirectAPI = __glXNewIndirectAPI(); + _glapi_set_dispatch(IndirectAPI); #endif gc->currentDpy = dpy; gc->currentDrawable = draw; diff --git a/xc/lib/GL/glx/indirect_init.c b/xc/lib/GL/glx/indirect_init.c index 99b6994c9..3e1d9f909 100644 --- a/xc/lib/GL/glx/indirect_init.c +++ b/xc/lib/GL/glx/indirect_init.c @@ -29,8 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> - * - * $PI: xc/lib/GL/glx/indirect_init.c,v 1.2 1999/04/05 05:24:32 martin Exp $ + * Brian Paul <brian@precisioninsight.com> */ #ifdef GLX_DIRECT_RENDERING @@ -49,21 +48,6 @@ static int NoOp(void) } -/* -** Initialize the given dispatch table to all no-op functions. -*/ -static void InitNoOpAPI(__GLapi *glAPI) -{ - const int entries = sizeof(__GLapi) / sizeof(void *); - int i; - void **dispatch = (void **) glAPI; - - for (i = 0; i < entries; i++) { - dispatch[i] = (void *) NoOp; - } -} - - __GLapi *__glXNewIndirectAPI(void) { __GLapi *glAPI; @@ -72,7 +56,13 @@ __GLapi *__glXNewIndirectAPI(void) glAPI = (__GLapi *) Xmalloc(entries * sizeof(void *)); /* first, set all entries to point to no-op functions */ - InitNoOpAPI(glAPI); + { + int i; + void **dispatch = (void **) glAPI; + for (i = 0; i < entries; i++) { + dispatch[i] = (void *) NoOp; + } + } /* now, initialize the entries we understand */ glAPI->Accum = __indirect_glAccum; |