Mesa (master): xlib st: Fix makeCurrent.

Thomas Hellstrom thomash at kemper.freedesktop.org
Wed Mar 18 03:58:52 PDT 2009


Module: Mesa
Branch: master
Commit: d405ba3151de9585a310b7e2ebcae09302c0dbe4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d405ba3151de9585a310b7e2ebcae09302c0dbe4

Author: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
Date:   Wed Mar 18 11:52:24 2009 +0100

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>

---

 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(-)

diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 7f32b46..75a4efd 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 2b8302d..bdd434c 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 */
 };
 
 



More information about the mesa-commit mailing list