From d405ba3151de9585a310b7e2ebcae09302c0dbe4 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 18 Mar 2009 11:52:24 +0100 Subject: xlib st: Fix makeCurrent. Flush if we change context. Also reinstate the old optimization of doing nothing if nothing changes. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/glx/xlib/xm_api.c | 27 ++++++++++++++++----------- src/gallium/state_trackers/glx/xlib/xm_api.h | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 7f32b460aae..75a4efd823e 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -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,22 +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; + c->xm_read_buffer = readBuffer; /* Call this periodically to detect when the user has begun using * GL rendering from multiple threads. @@ -1071,6 +1075,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, else { /* Detach */ st_make_current( NULL, NULL, NULL ); + } return GL_TRUE; } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index 2b8302d1747..bdd434cd364 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -295,6 +295,7 @@ struct xmesa_context { struct st_context *st; XMesaVisual xm_visual; /** pixel format info */ XMesaBuffer xm_buffer; /** current drawbuffer */ + XMesaBuffer xm_read_buffer; /** current readbuffer */ }; -- cgit v1.2.3