From b7f802eca2c78397ea7b8472b3a7e90a997fc140 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 18 Jan 2009 09:59:07 -0700 Subject: glx: gcc 2.95 build fix (move declaration before code) Adapted from patch by Matthieu Herbb --- src/glx/x11/glxcmds.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/glx/x11') diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 1d373ed29d..c68b6ac4ef 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -864,6 +864,12 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) GLXContext gc; GLXContextTag tag; CARD8 opcode; +#ifdef USE_XCB + xcb_connection_t *c; +#else + xGLXSwapBuffersReq *req; +#endif + #ifdef GLX_DIRECT_RENDERING __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); @@ -892,12 +898,10 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) } #ifdef USE_XCB - xcb_connection_t* c = XGetXCBConnection(dpy); + c = XGetXCBConnection(dpy); xcb_glx_swap_buffers(c, tag, drawable); xcb_flush(c); #else - xGLXSwapBuffersReq *req; - /* Send the glXSwapBuffers request */ LockDisplay(dpy); GetReq(GLXSwapBuffers,req); -- cgit v1.2.3 From ab9b4e1f593b2006a61c0f5440c2d7d3af80ea74 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Jan 2009 13:55:18 -0800 Subject: Fix issues with glXMakeContextCurrent and glXMakeCurrentReadSGI There were several bugs in the infrastructure for these two routines. 1. GLX_ALIAS was incorrectly used. The function and its alias must be identical! glXMakeContextCurrent / glXMakeCurrentReadSGI and MakeContextCurrent had different parameters. This caused the last parameter of MakeContextCurrent to get random values. 2. We based the implementation of glXMakeContextCurrent on the manual page instead of the GLX spec. The GLX spec says that glXMakeContextCurrent can be passed a Window as a drawable. When this happens, it will behave just like glXMakeCurrentReadSGI or glXMakeCurrent. 3. If there was a problem finding or creating the DRI drawable, MakeContextCurrent would crash instead of returning an error. This commit fixes all three issues, and fixes bug #18367 and bug #19625. --- src/glx/x11/glxcurrent.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/glx/x11') diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c index 5af46cf0ba..4d0a7c65eb 100644 --- a/src/glx/x11/glxcurrent.c +++ b/src/glx/x11/glxcurrent.c @@ -312,13 +312,11 @@ SendMakeCurrentRequest(Display * dpy, CARD8 opcode, #ifdef GLX_DIRECT_RENDERING static __GLXDRIdrawable * -FetchDRIDrawable(Display * dpy, - GLXDrawable glxDrawable, GLXContext gc, Bool pre13) +FetchDRIDrawable(Display * dpy, GLXDrawable glxDrawable, GLXContext gc) { __GLXdisplayPrivate *const priv = __glXInitialize(dpy); __GLXDRIdrawable *pdraw; __GLXscreenConfigs *psc; - XID drawable; if (priv == NULL) return NULL; @@ -330,15 +328,7 @@ FetchDRIDrawable(Display * dpy, if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0) return pdraw; - /* If this is glXMakeCurrent (pre GLX 1.3) we allow creating the - * GLX drawable on the fly. Otherwise we pass None as the X - * drawable */ - if (pre13) - drawable = glxDrawable; - else - drawable = None; - - pdraw = psc->driScreen->createDrawable(psc, drawable, + pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable, gc->mode); if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) { (*pdraw->destroyDrawable) (pdraw); @@ -357,7 +347,7 @@ FetchDRIDrawable(Display * dpy, */ static Bool MakeContextCurrent(Display * dpy, GLXDrawable draw, - GLXDrawable read, GLXContext gc, Bool pre13) + GLXDrawable read, GLXContext gc) { xGLXMakeCurrentReply reply; const GLXContext oldGC = __glXGetCurrentContext(); @@ -384,8 +374,21 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, #ifdef GLX_DIRECT_RENDERING /* Bind the direct rendering context to the drawable */ if (gc && gc->driContext) { - __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc, pre13); - __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc, pre13); + __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc); + __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc); + + if ((pdraw == NULL) || (pread == NULL)) { + xError error; + + error.errorCode = GLXBadDrawable; + error.resourceID = (pdraw == NULL) ? draw : read; + error.sequenceNumber = dpy->request; + error.type = X_Error; + error.majorCode = gc->majorOpcode; + error.minorCode = X_GLXMakeContextCurrent; + _XError(dpy, &error); + return False; + } bindReturnValue = (gc->driContext->bindContext) (gc->driContext, pdraw, pread); @@ -516,15 +519,16 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, PUBLIC Bool glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc) { - return MakeContextCurrent(dpy, draw, draw, gc, True); + return MakeContextCurrent(dpy, draw, draw, gc); } PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI, (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx), - (dpy, d, r, ctx, False), MakeContextCurrent) + (dpy, d, r, ctx), MakeContextCurrent) - PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent, - (Display * dpy, GLXDrawable d, GLXDrawable r, - GLXContext ctx), (dpy, d, r, ctx, False), - MakeContextCurrent) +PUBLIC +GLX_ALIAS(Bool, glXMakeContextCurrent, + (Display * dpy, GLXDrawable d, GLXDrawable r, + GLXContext ctx), (dpy, d, r, ctx), + MakeContextCurrent) -- cgit v1.2.3