[Mesa-dev] [PATCH 1/2] glx: Ensure that glXWaitX actually waits for X.

Eric Anholt eric at anholt.net
Mon May 6 17:39:11 PDT 2013


Ever since fake front was introduced in
63b51b5cf17ddde09b72a2811296f37b9a4c5ad2, we were skipping the XSync() in
the non-fake-front path, so compositors like Firefox's GL canvas were
having to manually put it in outside of glXWaitX().

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=52930
---
 src/glx/dri2_glx.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 7ce5775..3cdd249 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -639,10 +639,23 @@ dri2_wait_x(struct glx_context *gc)
    struct dri2_drawable *priv = (struct dri2_drawable *)
       GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
 
-   if (priv == NULL || !priv->have_fake_front)
-      return;
-
-   dri2_copy_drawable(priv, DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
+   if (priv != NULL && priv->have_fake_front) {
+      /* Ask the server to update our copy of the front buffer from the real
+       * front buffer.  This will round-trip with the server, so we can skip
+       * the XSync().
+       */
+      dri2_copy_drawable(priv, DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
+   } else {
+      /* From the GLX 1.4 spec, page 33:
+       *
+       *     "X rendering calls made prior to glXWaitX are guaranteed to be
+       *      executed before OpenGL rendering calls made after
+       *      glXWaitX. While the same result can be achieved using XSync,
+       *      glXWaitX does not require a round trip to the server, and may
+       *      therefore be more efficient."
+       */
+      XSync(gc->currentDpy, False);
+   }
 }
 
 static void
-- 
1.8.3.rc0



More information about the mesa-dev mailing list