From c491e585e43d48a2aeec96ccc4008da6c443fb42 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 28 Jul 2010 15:33:09 -0400 Subject: glx: Move bind and unbind to context vtable --- src/glx/dri2_glx.c | 28 +++--- src/glx/dri_common.c | 27 ++++++ src/glx/dri_common.h | 3 + src/glx/dri_glx.c | 57 ++++++------ src/glx/drisw_glx.c | 32 ++++--- src/glx/glxclient.h | 25 ++---- src/glx/glxcmds.c | 28 +++--- src/glx/glxcurrent.c | 246 ++++++++++++++++----------------------------------- src/glx/glxext.c | 2 +- src/glx/indirect.c | 30 +++---- src/glx/singlepix.c | 2 +- 11 files changed, 205 insertions(+), 275 deletions(-) (limited to 'src/glx') diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 8ad0e339ed..e57d10f091 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -95,7 +95,6 @@ struct dri2_screen { struct dri2_context { struct glx_context base; - __GLXDRIcontext dri_vtable; __DRIcontext *driContext; }; @@ -133,20 +132,28 @@ dri2_destroy_context(struct glx_context *context) } static Bool -dri2BindContext(struct glx_context *context, - __GLXDRIdrawable *draw, __GLXDRIdrawable *read) +dri2_bind_context(struct glx_context *context, struct glx_context *old, + GLXDrawable draw, GLXDrawable read) { struct dri2_context *pcp = (struct dri2_context *) context; struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc; - struct dri2_drawable *pdr = (struct dri2_drawable *) draw; - struct dri2_drawable *prd = (struct dri2_drawable *) read; + struct dri2_drawable *pdraw, *pread; - return (*psc->core->bindContext) (pcp->driContext, - pdr->driDrawable, prd->driDrawable); + pdraw = (struct dri2_drawable *) driFetchDrawable(context, draw); + pread = (struct dri2_drawable *) driFetchDrawable(context, read); + + if (pdraw == NULL || pread == NULL) + return GLXBadDrawable; + + if ((*psc->core->bindContext) (pcp->driContext, + pdraw->driDrawable, pread->driDrawable)) + return Success; + + return GLXBadContext; } static void -dri2UnbindContext(struct glx_context *context) +dri2_unbind_context(struct glx_context *context, struct glx_context *new) { struct dri2_context *pcp = (struct dri2_context *) context; struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc; @@ -189,9 +196,6 @@ dri2_create_context(struct glx_screen *base, } pcp->base.vtable = &dri2_context_vtable; - pcp->base.driContext = &pcp->dri_vtable; - pcp->dri_vtable.bindContext = dri2BindContext; - pcp->dri_vtable.unbindContext = dri2UnbindContext; return &pcp->base; } @@ -684,6 +688,8 @@ dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) static const struct glx_context_vtable dri2_context_vtable = { dri2_destroy_context, + dri2_bind_context, + dri2_unbind_context, dri2_wait_gl, dri2_wait_x, DRI_glXUseXFont, diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index 812fb2eb08..a7fb4c6424 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -353,4 +353,31 @@ driDestroyConfigs(const __DRIconfig **configs) free(configs); } +_X_HIDDEN __GLXDRIdrawable * +driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable) +{ + struct glx_display *const priv = __glXInitialize(gc->psc->dpy); + __GLXDRIdrawable *pdraw; + struct glx_screen *psc; + + if (priv == NULL) + return NULL; + + psc = priv->screens[gc->screen]; + if (priv->drawHash == NULL) + return NULL; + + if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) + return pdraw; + + pdraw = psc->driScreen->createDrawable(psc, glxDrawable, + glxDrawable, gc->config); + if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) { + (*pdraw->destroyDrawable) (pdraw); + return NULL; + } + + return pdraw; +} + #endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h index 32d98ed3c1..846a905a88 100644 --- a/src/glx/dri_common.h +++ b/src/glx/dri_common.h @@ -52,6 +52,9 @@ extern struct glx_config *driConvertConfigs(const __DRIcoreExtension * core, extern void driDestroyConfigs(const __DRIconfig **configs); +extern __GLXDRIdrawable * +driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable); + extern const __DRIsystemTimeExtension systemTimeExtension; extern void InfoMessageF(const char *f, ...); diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c index 70281f663e..43a2aa495a 100644 --- a/src/glx/dri_glx.c +++ b/src/glx/dri_glx.c @@ -79,7 +79,6 @@ struct dri_screen struct dri_context { struct glx_context base; - __GLXDRIcontext dri_vtable; __DRIcontext *driContext; XID hwContextID; }; @@ -518,21 +517,29 @@ dri_destroy_context(struct glx_context * context) Xfree(pcp); } -static Bool -driBindContext(struct glx_context *context, - __GLXDRIdrawable *draw, __GLXDRIdrawable *read) +static int +dri_bind_context(struct glx_context *context, struct glx_context *old, + GLXDrawable draw, GLXDrawable read) { struct dri_context *pcp = (struct dri_context *) context; struct dri_screen *psc = (struct dri_screen *) pcp->base.psc; - struct dri_drawable *pdr = (struct dri_drawable *) draw; - struct dri_drawable *prd = (struct dri_drawable *) read; + struct dri_drawable *pdraw, *pread; + + pdraw = (struct dri_drawable *) driFetchDrawable(context, draw); + pread = (struct dri_drawable *) driFetchDrawable(context, read); + + if (pdraw == NULL || pread == NULL) + return GLXBadDrawable; - return (*psc->core->bindContext) (pcp->driContext, - pdr->driDrawable, prd->driDrawable); + if ((*psc->core->bindContext) (pcp->driContext, + pdraw->driDrawable, pread->driDrawable)) + return Success; + + return GLXBadContext; } static void -driUnbindContext(struct glx_context * context) +dri_unbind_context(struct glx_context *context, struct glx_context *new) { struct dri_context *pcp = (struct dri_context *) context; struct dri_screen *psc = (struct dri_screen *) pcp->base.psc; @@ -542,6 +549,8 @@ driUnbindContext(struct glx_context * context) static const struct glx_context_vtable dri_context_vtable = { dri_destroy_context, + dri_bind_context, + dri_unbind_context, NULL, NULL, DRI_glXUseXFont, @@ -564,7 +573,7 @@ dri_create_context(struct glx_screen *base, return NULL; if (shareList) { - pcp_shared = (struct dri_context *) shareList->driContext; + pcp_shared = (struct dri_context *) shareList; shared = pcp_shared->driContext; } @@ -596,9 +605,6 @@ dri_create_context(struct glx_screen *base, } pcp->base.vtable = &dri_context_vtable; - pcp->base.driContext = &pcp->dri_vtable; - pcp->dri_vtable.bindContext = driBindContext; - pcp->dri_vtable.unbindContext = driUnbindContext; return &pcp->base; } @@ -756,17 +762,12 @@ driWaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, static int driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval) { - struct glx_context *gc = __glXGetCurrentContext(); struct dri_drawable *pdp = (struct dri_drawable *) pdraw; - struct dri_screen *psc; - - if (gc->driContext) { - psc = (struct dri_screen *) pdraw->psc; + struct dri_screen *psc = (struct dri_screen *) pdraw->psc; - if (psc->swapControl != NULL && pdraw != NULL) { - psc->swapControl->setSwapInterval(pdp->driDrawable, interval); - return 0; - } + if (psc->swapControl != NULL && pdraw != NULL) { + psc->swapControl->setSwapInterval(pdp->driDrawable, interval); + return 0; } return GLX_BAD_CONTEXT; @@ -775,17 +776,11 @@ driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval) static int driGetSwapInterval(__GLXDRIdrawable *pdraw) { - struct glx_context *gc = __glXGetCurrentContext(); struct dri_drawable *pdp = (struct dri_drawable *) pdraw; - struct dri_screen *psc; - - if (gc != NULL && gc->driContext) { - psc = (struct dri_screen *) pdraw->psc; + struct dri_screen *psc = (struct dri_screen *) pdraw->psc; - if (psc->swapControl != NULL && pdraw != NULL) { - return psc->swapControl->getSwapInterval(pdp->driDrawable); - } - } + if (psc->swapControl != NULL && pdraw != NULL) + return psc->swapControl->getSwapInterval(pdp->driDrawable); return 0; } diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 070c9d612b..46c56066e6 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -36,7 +36,6 @@ struct drisw_display struct drisw_context { struct glx_context base; - __GLXDRIcontext dri_vtable; __DRIcontext *driContext; }; @@ -258,21 +257,29 @@ drisw_destroy_context(struct glx_context *context) Xfree(pcp); } -static Bool -driBindContext(struct glx_context * context, - __GLXDRIdrawable * draw, __GLXDRIdrawable * read) +static int +drisw_bind_context(struct glx_context *context, struct glx_context *old, + GLXDrawable draw, GLXDrawable read) { struct drisw_context *pcp = (struct drisw_context *) context; struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc; - struct drisw_drawable *pdr = (struct drisw_drawable *) draw; - struct drisw_drawable *prd = (struct drisw_drawable *) read; + struct drisw_drawable *pdraw, *pread; + + pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw); + pread = (struct drisw_drawable *) driFetchDrawable(context, read); + + if (pdraw == NULL || pread == NULL) + return GLXBadDrawable; + + if ((*psc->core->bindContext) (pcp->driContext, + pdraw->driDrawable, pread->driDrawable)) + return Success; - return (*psc->core->bindContext) (pcp->driContext, - pdr->driDrawable, prd->driDrawable); + return GLXBadContext; } static void -driUnbindContext(struct glx_context * context) +drisw_unbind_context(struct glx_context *context, struct glx_context *new) { struct drisw_context *pcp = (struct drisw_context *) context; struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc; @@ -282,6 +289,8 @@ driUnbindContext(struct glx_context * context) static const struct glx_context_vtable drisw_context_vtable = { drisw_destroy_context, + drisw_bind_context, + drisw_unbind_context, NULL, NULL, DRI_glXUseXFont, @@ -303,7 +312,7 @@ drisw_create_context(struct glx_screen *base, return NULL; if (shareList) { - pcp_shared = (struct drisw_context *) shareList->driContext; + pcp_shared = (struct drisw_context *) shareList; shared = pcp_shared->driContext; } @@ -326,9 +335,6 @@ drisw_create_context(struct glx_screen *base, } pcp->base.vtable = &drisw_context_vtable; - pcp->base.driContext = &pcp->dri_vtable; - pcp->dri_vtable.bindContext = driBindContext; - pcp->dri_vtable.unbindContext = driUnbindContext; return &pcp->base; } diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 4f5c02fc34..b13cc81b57 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -88,7 +88,6 @@ extern void DRI_glXUseXFont(struct glx_context *ctx, typedef struct __GLXDRIdisplayRec __GLXDRIdisplay; typedef struct __GLXDRIscreenRec __GLXDRIscreen; typedef struct __GLXDRIdrawableRec __GLXDRIdrawable; -typedef struct __GLXDRIcontextRec __GLXDRIcontext; #include "glxextensions.h" @@ -131,13 +130,6 @@ struct __GLXDRIscreenRec { int (*getSwapInterval)(__GLXDRIdrawable *pdraw); }; -struct __GLXDRIcontextRec -{ - Bool(*bindContext) (struct glx_context *context, __GLXDRIdrawable *pdraw, - __GLXDRIdrawable *pread); - void (*unbindContext) (struct glx_context *context); -}; - struct __GLXDRIdrawableRec { void (*destroyDrawable) (__GLXDRIdrawable * drawable); @@ -221,6 +213,9 @@ typedef struct __GLXattributeMachineRec struct glx_context_vtable { void (*destroy)(struct glx_context *ctx); + int (*bind)(struct glx_context *context, struct glx_context *old, + GLXDrawable draw, GLXDrawable read); + void (*unbind)(struct glx_context *context, struct glx_context *new); void (*wait_gl)(struct glx_context *ctx); void (*wait_x)(struct glx_context *ctx); void (*use_x_font)(struct glx_context *ctx, @@ -388,15 +383,6 @@ struct glx_context */ struct glx_config *config; -#ifdef GLX_DIRECT_RENDERING -#ifdef GLX_USE_APPLEGL - void *driContext; - Bool do_destroy; -#else - __GLXDRIcontext *driContext; -#endif -#endif - /** * The current read-drawable for this context. Will be None if this * context is not current to any drawable. @@ -790,5 +776,10 @@ GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable); extern struct glx_screen * indirect_create_screen(int screen, struct glx_display * priv); +extern int +indirect_bind_context(struct glx_context *gc, struct glx_context *old, + GLXDrawable draw, GLXDrawable read); +extern void +indirect_unbind_context(struct glx_context *gc, struct glx_context *new); #endif /* !__GLX_client_h__ */ diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index f2081fdd2c..717108e2fc 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -42,15 +42,12 @@ #include "apple_glx_context.h" #include "apple_glx.h" #include "glx_error.h" -#define GC_IS_DIRECT(gc) ((gc)->isDirect) #else #include #include #include "xf86dri.h" -#define GC_IS_DIRECT(gc) ((gc)->driContext != NULL) #endif #else -#define GC_IS_DIRECT(gc) (0) #endif #if defined(USE_XCB) @@ -424,6 +421,7 @@ glx_context_init(struct glx_context *gc, gc->psc = psc; gc->config = config; gc->isDirect = GL_TRUE; + gc->currentContextTag = -1; return GL_TRUE; } @@ -475,7 +473,7 @@ CreateContext(Display * dpy, int generic_id, req->visual = generic_id; req->screen = screen; req->shareList = shareList ? shareList->xid : None; - req->isDirect = GC_IS_DIRECT(gc); + req->isDirect = gc->isDirect; break; } @@ -491,7 +489,7 @@ CreateContext(Display * dpy, int generic_id, req->screen = screen; req->renderType = renderType; req->shareList = shareList ? shareList->xid : None; - req->isDirect = GC_IS_DIRECT(gc); + req->isDirect = gc->isDirect; break; } @@ -512,7 +510,7 @@ CreateContext(Display * dpy, int generic_id, req->screen = screen; req->renderType = renderType; req->shareList = shareList ? shareList->xid : None; - req->isDirect = GC_IS_DIRECT(gc); + req->isDirect = gc->isDirect; break; } @@ -836,7 +834,7 @@ glXCopyContext(Display * dpy, GLXContext source_user, } #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { /* NOT_DONE: This does not work yet */ } #endif @@ -929,7 +927,7 @@ glXIsDirect(Display * dpy, GLXContext gc_user) if (!gc) { return GL_FALSE; } - else if (GC_IS_DIRECT(gc)) { + else if (gc->isDirect) { return GL_TRUE; } #ifdef GLX_USE_APPLEGL /* TODO: indirect on darwin */ @@ -1962,7 +1960,7 @@ __glXSwapIntervalSGI(int interval) psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); #ifdef GLX_DIRECT_RENDERING - if (gc->driContext && psc->driScreen && psc->driScreen->setSwapInterval) { + if (gc->isDirect && psc->driScreen && psc->driScreen->setSwapInterval) { __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable); psc->driScreen->setSwapInterval(pdraw, interval); @@ -2004,7 +2002,7 @@ __glXSwapIntervalMESA(unsigned int interval) #ifdef GLX_DIRECT_RENDERING struct glx_context *gc = __glXGetCurrentContext(); - if (gc != NULL && gc->driContext) { + if (gc != NULL && gc->isDirect) { struct glx_screen *psc; psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); @@ -2026,7 +2024,7 @@ __glXGetSwapIntervalMESA(void) #ifdef GLX_DIRECT_RENDERING struct glx_context *gc = __glXGetCurrentContext(); - if (gc != NULL && gc->driContext) { + if (gc != NULL && gc->isDirect) { struct glx_screen *psc; psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); @@ -2060,7 +2058,7 @@ __glXGetVideoSyncSGI(unsigned int *count) return GLX_BAD_CONTEXT; #ifdef GLX_DIRECT_RENDERING - if (!gc->driContext) + if (!gc->isDirect) return GLX_BAD_CONTEXT; #endif @@ -2102,7 +2100,7 @@ __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) return GLX_BAD_CONTEXT; #ifdef GLX_DIRECT_RENDERING - if (!gc->driContext) + if (!gc->isDirect) return GLX_BAD_CONTEXT; #endif @@ -2423,7 +2421,7 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable, return -1; #ifdef GLX_DIRECT_RENDERING - if (!pdraw || !gc->driContext) + if (!pdraw || !gc->isDirect) return -1; #endif @@ -2721,6 +2719,8 @@ indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) static const struct glx_context_vtable indirect_context_vtable = { indirect_destroy_context, + indirect_bind_context, + indirect_unbind_context, indirect_wait_gl, indirect_wait_x, indirect_use_x_font, diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index c293af30c2..5955860494 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -283,37 +283,6 @@ SendMakeCurrentRequest(Display * dpy, CARD8 opcode, return ret; } - -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) -static __GLXDRIdrawable * -FetchDRIDrawable(Display * dpy, - GLXDrawable glxDrawable, struct glx_context *gc) -{ - struct glx_display *const priv = __glXInitialize(dpy); - __GLXDRIdrawable *pdraw; - struct glx_screen *psc; - - if (priv == NULL) - return NULL; - - psc = priv->screens[gc->screen]; - if (priv->drawHash == NULL) - return NULL; - - if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) - return pdraw; - - pdraw = psc->driScreen->createDrawable(psc, glxDrawable, - glxDrawable, gc->config); - if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) { - (*pdraw->destroyDrawable) (pdraw); - return NULL; - } - - return pdraw; -} -#endif /* GLX_DIRECT_RENDERING */ - static void __glXGenerateError(Display * dpy, struct glx_context *gc, XID resource, BYTE errorCode, CARD16 minorCode) @@ -331,6 +300,55 @@ __glXGenerateError(Display * dpy, struct glx_context *gc, XID resource, #endif /* GLX_USE_APPLEGL */ +_X_HIDDEN int +indirect_bind_context(struct glx_context *gc, struct glx_context *old, + GLXDrawable draw, GLXDrawable read) +{ + xGLXMakeCurrentReply reply; + GLXContextTag tag; + __GLXattribute *state; + Display *dpy = gc->psc->dpy; + int opcode = __glXSetupForCommand(dpy); + + if (old && !old->isDirect && old->psc->dpy == dpy) + tag = old->currentContextTag; + else + tag = None; + + SendMakeCurrentRequest(dpy, opcode, gc->xid, tag, draw, read, &reply); + + if (!IndirectAPI) + IndirectAPI = __glXNewIndirectAPI(); + _glapi_set_dispatch(IndirectAPI); + + gc->currentContextTag = reply.contextTag; + state = gc->client_state_private; + if (state->array_state == NULL) { + glGetString(GL_EXTENSIONS); + glGetString(GL_VERSION); + __glXInitVertexArrayState(gc); + } + + return Success; +} + +_X_HIDDEN void +indirect_unbind_context(struct glx_context *gc, struct glx_context *new) +{ + Display *dpy = gc->psc->dpy; + int opcode = __glXSetupForCommand(dpy); + xGLXMakeCurrentReply reply; + + /* We are either switching to no context, away from a indirect + * context to a direct context or from one dpy to another and have + * to send a request to the dpy to unbind the previous context. + */ + if (!new || new->isDirect || new->psc->dpy != dpy) + SendMakeCurrentRequest(dpy, opcode, None, + gc->currentContextTag, None, None, &reply); + gc->currentContextTag = 0; +} + /** * Make a particular context current. * @@ -342,25 +360,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, { struct glx_context *gc = (struct glx_context *) gc_user; struct glx_context *oldGC = __glXGetCurrentContext(); -#ifdef GLX_USE_APPLEGL - bool error = apple_glx_make_current_context(dpy, - (oldGC && oldGC != &dummyContext) ? oldGC->driContext : NULL, - gc ? gc->driContext : NULL, draw); - - apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO"); - if(error) - return GL_FALSE; -#else - xGLXMakeCurrentReply reply; - const CARD8 opcode = __glXSetupForCommand(dpy); - const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext)) - ? opcode : __glXSetupForCommand(oldGC->currentDpy); - Bool bindReturnValue; - __GLXattribute *state; - - if (!opcode || !oldOpcode) { - return GL_FALSE; - } + int ret = Success; /* Make sure that the new context has a nonzero ID. In the request, * a zero context ID is used only to mean that we bind to no current @@ -388,134 +388,36 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, return False; } -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - /* Bind the direct rendering context to the drawable */ - if (gc && gc->driContext) { - __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc); - __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc); - - if ((pdraw == NULL) || (pread == NULL)) { - __glXGenerateError(dpy, gc, (pdraw == NULL) ? draw : read, - GLXBadDrawable, X_GLXMakeContextCurrent); - return False; - } - - bindReturnValue = - (gc->driContext->bindContext) (gc, pdraw, pread); + if (oldGC != &dummyContext && oldGC != gc) { + oldGC->vtable->unbind(oldGC, gc); + oldGC->currentDpy = 0; + oldGC->currentDrawable = None; + oldGC->currentReadable = None; + oldGC->thread_id = 0; + if (oldGC->xid == None) + /* We are switching away from a context that was + * previously destroyed, so we need to free the memory + * for the old handle. + */ + oldGC->vtable->destroy(oldGC); } - else if (!gc && oldGC && oldGC->driContext) { - bindReturnValue = True; - } - else -#endif - { - /* Send a glXMakeCurrent request to bind the new context. */ - bindReturnValue = - SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None, - ((dpy != oldGC->currentDpy) - || oldGC->isDirect) - ? None : oldGC->currentContextTag, draw, read, - &reply); - } - - if (!bindReturnValue) { - return False; + if (gc) { + ret = gc->vtable->bind(gc, oldGC, draw, read); + gc->currentDpy = dpy; + gc->currentDrawable = draw; + gc->currentReadable = read; + gc->thread_id = _glthread_GetID(); + __glXSetCurrentContext(gc); + } else { + __glXSetCurrentContextNull(); } -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) && - !oldGC->isDirect && oldGC != &dummyContext) { -#else - if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) { -#endif - xGLXMakeCurrentReply dummy_reply; - - /* We are either switching from one dpy to another and have to - * send a request to the previous dpy to unbind the previous - * context, or we are switching away from a indirect context to - * a direct context and have to send a request to the dpy to - * unbind the previous context. - */ - (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None, - oldGC->currentContextTag, None, None, - &dummy_reply); - } -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - else if (oldGC->driContext && oldGC != gc) { - oldGC->driContext->unbindContext(oldGC); - } -#endif - -#endif /* GLX_USE_APPLEGL */ - - /* Update our notion of what is current */ - __glXLock(); - if (gc == oldGC) { - /* Even though the contexts are the same the drawable might have - * changed. Note that gc cannot be the dummy, and that oldGC - * cannot be NULL, therefore if they are the same, gc is not - * NULL and not the dummy. - */ - if(gc) { - gc->currentDrawable = draw; - gc->currentReadable = read; - } + if (ret) { + __glXGenerateError(dpy, gc, None, ret, X_GLXMakeContextCurrent); + return GL_FALSE; } - else { - if (oldGC != &dummyContext) { - /* Old current context is no longer current to anybody */ - oldGC->currentDpy = 0; - oldGC->currentDrawable = None; - oldGC->currentReadable = None; - oldGC->currentContextTag = 0; - oldGC->thread_id = 0; - - if (oldGC->xid == None) { - /* We are switching away from a context that was - * previously destroyed, so we need to free the memory - * for the old handle. - */ - oldGC->vtable->destroy(oldGC); - } - } - if (gc) { - __glXSetCurrentContext(gc); - - gc->currentDpy = dpy; - gc->currentDrawable = draw; - gc->currentReadable = read; -#ifndef GLX_USE_APPLEGL - gc->thread_id = _glthread_GetID(); -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (!gc->driContext) { -#endif - if (!IndirectAPI) - IndirectAPI = __glXNewIndirectAPI(); - _glapi_set_dispatch(IndirectAPI); - - state = (__GLXattribute *) (gc->client_state_private); - - gc->currentContextTag = reply.contextTag; - if (state->array_state == NULL) { - (void) glGetString(GL_EXTENSIONS); - (void) glGetString(GL_VERSION); - __glXInitVertexArrayState(gc); - } -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - } - else { - gc->currentContextTag = -1; - } -#endif -#endif /* GLX_USE_APPLEGL */ - } - else { - __glXSetCurrentContextNull(); - } - } - __glXUnlock(); return GL_TRUE; } diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 5930d7d5a8..e48c4c289c 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -742,7 +742,7 @@ glx_screen_init(struct glx_screen *psc, ** If that works then fetch the per screen configs data. */ static Bool - AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv) +AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv) { struct glx_screen *psc; GLint i, screens; diff --git a/src/glx/indirect.c b/src/glx/indirect.c index 0dea8e9f5a..c0fff6c4dc 100644 --- a/src/glx/indirect.c +++ b/src/glx/indirect.c @@ -5199,7 +5199,7 @@ glDeleteTexturesEXT(GLsizei n, const GLuint * textures) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_DeleteTextures(GET_DISPATCH(), (n, textures)); } else #endif @@ -5270,7 +5270,7 @@ glGenTexturesEXT(GLsizei n, GLuint * textures) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GenTextures(GET_DISPATCH(), (n, textures)); } else #endif @@ -5335,7 +5335,7 @@ glIsTextureEXT(GLuint texture) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { return CALL_IsTexture(GET_DISPATCH(), (texture)); } else #endif @@ -5651,7 +5651,7 @@ glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table)); } else #endif @@ -5727,7 +5727,7 @@ glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetColorTableParameterfv(GET_DISPATCH(), (target, pname, params)); } else @@ -5800,7 +5800,7 @@ glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetColorTableParameteriv(GET_DISPATCH(), (target, pname, params)); } else @@ -6126,7 +6126,7 @@ gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type, struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetConvolutionFilter(GET_DISPATCH(), (target, format, type, image)); } else @@ -6204,7 +6204,7 @@ gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetConvolutionParameterfv(GET_DISPATCH(), (target, pname, params)); } else @@ -6277,7 +6277,7 @@ gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetConvolutionParameteriv(GET_DISPATCH(), (target, pname, params)); } else @@ -6357,7 +6357,7 @@ gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format, struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetHistogram(GET_DISPATCH(), (target, reset, format, type, values)); } else @@ -6434,7 +6434,7 @@ gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params)); } else #endif @@ -6505,7 +6505,7 @@ gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params)); } else #endif @@ -6580,7 +6580,7 @@ gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format, struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values)); } else #endif @@ -6654,7 +6654,7 @@ gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params)); } else #endif @@ -6722,7 +6722,7 @@ gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params) struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params)); } else #endif diff --git a/src/glx/singlepix.c b/src/glx/singlepix.c index edb8858d7a..b61f26b2f3 100644 --- a/src/glx/singlepix.c +++ b/src/glx/singlepix.c @@ -120,7 +120,7 @@ void NAME(_gloffset_GetSeparableFilter) (GLenum target, GLenum format, struct glx_context *const gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { + if (gc->isDirect) { CALL_GetSeparableFilter(GET_DISPATCH(), (target, format, type, row, column, span)); return; -- cgit v1.2.3