summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/glx/xlib
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom-at-vmware-dot-com>2009-03-18 11:52:24 +0100
committerThomas Hellstrom <thellstrom-at-vmware-dot-com>2009-03-18 11:58:40 +0100
commitd405ba3151de9585a310b7e2ebcae09302c0dbe4 (patch)
tree5aa2ce6fe3196ec3779cd95699a5ea8a220a50c2 /src/gallium/state_trackers/glx/xlib
parentae36fadb7f137cd7f53dccb58d1a73fc46ccc26b (diff)
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 <thellstrom-at-vmware-dot-com>
Diffstat (limited to 'src/gallium/state_trackers/glx/xlib')
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c27
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.h1
2 files changed, 17 insertions, 11 deletions
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 */
};