X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglx%2Fglxcurrent.c;h=9c5d2af895639a380b536379352c1bb0a3a2fe5b;hb=0765a1dd0ec59646b6cca80b424be3ce094176d7;hp=7f47a42777115dc29a8e542cb08ea540c5acc49e;hpb=38591295cd4b68f89f257b20f476f98de3772a47;p=mesa.git diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index 7f47a427771..9c5d2af8956 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -36,8 +36,8 @@ #include #include "glxclient.h" - #include "glapi.h" +#include "glx_error.h" /* ** We setup some dummy structures here so that the API can be used @@ -67,7 +67,7 @@ struct glx_context dummyContext = { _X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER; -# if defined( GLX_USE_TLS ) +# if defined( USE_ELF_TLS ) /** * Per-thread GLX context pointer. @@ -132,7 +132,7 @@ __glXGetCurrentContext(void) return (v == NULL) ? &dummyContext : (struct glx_context *) v; } -# endif /* defined( GLX_USE_TLS ) */ +# endif /* defined( USE_ELF_TLS ) */ _X_HIDDEN void @@ -145,7 +145,7 @@ __glXSetCurrentContextNull(void) #endif } -_X_EXPORT GLXContext +_GLX_PUBLIC GLXContext glXGetCurrentContext(void) { struct glx_context *cx = __glXGetCurrentContext(); @@ -158,28 +158,13 @@ glXGetCurrentContext(void) } } -_X_EXPORT GLXDrawable +_GLX_PUBLIC GLXDrawable glXGetCurrentDrawable(void) { struct glx_context *gc = __glXGetCurrentContext(); return gc->currentDrawable; } -static void -__glXGenerateError(Display * dpy, XID resource, - BYTE errorCode, CARD16 minorCode) -{ - xError error; - - error.errorCode = errorCode; - error.resourceID = resource; - error.sequenceNumber = dpy->request; - error.type = X_Error; - error.majorCode = __glXSetupForCommand(dpy); - error.minorCode = minorCode; - _XError(dpy, &error); -} - /** * Make a particular context current. * @@ -209,6 +194,13 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, return True; } + /* can't have only one be 0 */ + if (!!draw != !!read) { + __glXUnlock(); + __glXSendError(dpy, BadMatch, None, X_GLXMakeContextCurrent, True); + return False; + } + if (oldGC != &dummyContext) { if (--oldGC->thread_refcount == 0) { oldGC->vtable->unbind(oldGC, gc); @@ -228,7 +220,8 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, if (gc->vtable->bind(gc, oldGC, draw, read) != Success) { __glXSetCurrentContextNull(); __glXUnlock(); - __glXGenerateError(dpy, None, GLXBadContext, X_GLXMakeContextCurrent); + __glXSendError(dpy, GLXBadContext, None, X_GLXMakeContextCurrent, + False); return GL_FALSE; } @@ -252,22 +245,34 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, __glXUnlock(); + /* The indirect vertex array state must to be initialised after we + * have setup the context, as it needs to query server attributes. + */ + if (gc && !gc->isDirect) { + __GLXattribute *state = gc->client_state_private; + if (state && state->array_state == NULL) { + glGetString(GL_EXTENSIONS); + glGetString(GL_VERSION); + __glXInitVertexArrayState(gc); + } + } + return GL_TRUE; } -_X_EXPORT Bool +_GLX_PUBLIC Bool glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc) { return MakeContextCurrent(dpy, draw, draw, gc); } -_X_EXPORT +_GLX_PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI, (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx), (dpy, d, r, ctx), MakeContextCurrent) -_X_EXPORT +_GLX_PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent, (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx), (dpy, d, r, ctx), MakeContextCurrent)