summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/glx/xlib/xm_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/glx/xlib/xm_api.c')
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 33dc044ad55..a3d16516531 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -458,7 +458,7 @@ xmesa_free_buffer(XMesaBuffer buffer)
XDestroyImage(buffer->tempImage);
/* Unreference. If count = zero we'll really delete the buffer */
- _mesa_unreference_framebuffer(&fb);
+ _mesa_reference_framebuffer(&fb, NULL);
XFreeGC(b->xm_visual->display, b->gc);
@@ -763,7 +763,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
c->xm_visual = v;
c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
-
+ c->xm_read_buffer = NULL;
+
/* XXX: create once per Xlib Display.
*/
screen = driver.create_pipe_screen();
@@ -1037,27 +1038,25 @@ PUBLIC
GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
XMesaBuffer readBuffer )
{
+ XMesaContext old_ctx = XMesaGetCurrentContext();
+
+ if (old_ctx && old_ctx != c) {
+ XMesaFlush(old_ctx);
+ old_ctx->xm_buffer = NULL;
+ old_ctx->xm_read_buffer = NULL;
+ }
+
if (c) {
if (!drawBuffer || !readBuffer)
return GL_FALSE; /* must specify buffers! */
-#if 0
- /* XXX restore this optimization */
- if (&(c->mesa) == _mesa_get_current_context()
- && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer
- && c->mesa.ReadBuffer == &readBuffer->mesa_buffer
- && xmesa_buffer(c->mesa.DrawBuffer)->wasCurrent) {
- /* same context and buffer, do nothing */
- return GL_TRUE;
- }
-#endif
+ if (c == old_ctx &&
+ c->xm_buffer == drawBuffer &&
+ c->xm_read_buffer == readBuffer)
+ return GL_TRUE;
c->xm_buffer = drawBuffer;
-
- /* Call this periodically to detect when the user has begun using
- * GL rendering from multiple threads.
- */
- _glapi_check_multithread();
+ c->xm_read_buffer = readBuffer;
st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb);
@@ -1071,6 +1070,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
else {
/* Detach */
st_make_current( NULL, NULL, NULL );
+
}
return GL_TRUE;
}
@@ -1143,7 +1143,6 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
return;
pipe->surface_copy(pipe,
- FALSE,
surf_front, x, y, /* dest */
surf_back, x, y, /* src */
width, height);