gallium/xlib: Fix glXMakeCurrent(dpy, None, None, ctx)

This is entirely legal in GL 3.0+. I wonder how many more times I'll
need to fix this specific bug.
This commit is contained in:
Adam Jackson 2019-09-10 15:11:19 -04:00 committed by Adam Jackson
parent a693f98e17
commit 320c36ed3a
2 changed files with 40 additions and 27 deletions

View file

@ -1188,33 +1188,41 @@ glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
firsttime = 0;
}
if (ctx && draw && read) {
XMesaBuffer drawBuffer, readBuffer;
if (ctx) {
XMesaBuffer drawBuffer = NULL, readBuffer = NULL;
XMesaContext xmctx = glxCtx->xmesaContext;
/* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
if (ctx == current) {
drawBuffer = XMesaFindBuffer( dpy, draw );
}
if (!drawBuffer) {
/* drawable must be a new window! */
drawBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, draw );
/* either both must be null, or both must be non-null */
if (!draw != !read)
return False;
if (draw) {
/* Find the XMesaBuffer which corresponds to 'draw' */
if (ctx == current) {
drawBuffer = XMesaFindBuffer( dpy, draw );
}
if (!drawBuffer) {
/* Out of memory, or context/drawable depth mismatch */
return False;
/* drawable must be a new window! */
drawBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, draw );
if (!drawBuffer) {
/* Out of memory, or context/drawable depth mismatch */
return False;
}
}
}
/* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
if (ctx == current) {
readBuffer = XMesaFindBuffer( dpy, read );
}
if (!readBuffer) {
/* drawable must be a new window! */
readBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, read );
if (read) {
/* Find the XMesaBuffer which corresponds to 'read' */
if (ctx == current) {
readBuffer = XMesaFindBuffer( dpy, read );
}
if (!readBuffer) {
/* Out of memory, or context/drawable depth mismatch */
return False;
/* drawable must be a new window! */
readBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, read );
if (!readBuffer) {
/* Out of memory, or context/drawable depth mismatch */
return False;
}
}
}
@ -1240,9 +1248,7 @@ glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
return True;
}
else {
/* The args must either all be non-zero or all zero.
* This is an error.
*/
/* We were given an invalid set of arguments */
return False;
}
}

View file

@ -1258,6 +1258,9 @@ xmesa_check_buffer_size(XMesaBuffer b)
{
GLuint old_width, old_height;
if (!b)
return;
if (b->type == PBUFFER)
return;
@ -1287,8 +1290,9 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
}
if (c) {
if (!drawBuffer || !readBuffer)
return GL_FALSE; /* must specify buffers! */
if (!drawBuffer != !readBuffer) {
return GL_FALSE; /* must specify zero or two buffers! */
}
if (c == old_ctx &&
c->xm_buffer == drawBuffer &&
@ -1302,10 +1306,13 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
c->xm_buffer = drawBuffer;
c->xm_read_buffer = readBuffer;
stapi->make_current(stapi, c->st, drawBuffer->stfb, readBuffer->stfb);
stapi->make_current(stapi, c->st,
drawBuffer ? drawBuffer->stfb : NULL,
readBuffer ? readBuffer->stfb : NULL);
/* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
drawBuffer->wasCurrent = GL_TRUE;
if (drawBuffer)
drawBuffer->wasCurrent = GL_TRUE;
}
else {
/* Detach */