diff options
author | Adam Jackson <ajax@redhat.com> | 2019-09-10 15:11:19 -0400 |
---|---|---|
committer | Adam Jackson <ajax@nwnk.net> | 2019-09-17 20:16:00 +0000 |
commit | 320c36ed3a2a67383d9791a71626e5c5f1ccf59b (patch) | |
tree | ee1f94335c8775ccba7083eadded48a7c629b6b2 | |
parent | a693f98e17694841fac1e3c90dfb5f5f46942486 (diff) |
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.
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/glx_api.c | 52 | ||||
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/xm_api.c | 15 |
2 files changed, 40 insertions, 27 deletions
diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index ea503746604..029268b32e6 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -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; } } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 4351cd6e622..64eee53f2b8 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -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 */ |