Mesa (10.3): glx/dri3: Request non-vsynced Present for swapinterval zero. (v3)

Emil Velikov evelikov at kemper.freedesktop.org
Sun Dec 14 15:43:34 UTC 2014


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

Author: Mario Kleiner <mario.kleiner.de at gmail.com>
Date:   Fri Dec  5 08:42:31 2014 +0100

glx/dri3: Request non-vsynced Present for swapinterval zero. (v3)

Restores proper immediate tearing swap behaviour for
OpenGL bufferswap under DRI3/Present.

Cc: "10.3 10.4" <mesa-stable at lists.freedesktop.org>

v2: Add Frank Binns signed off by for his original earlier
patch from April 2014, which is identical to this one, and
Chris Wilsons reviewed tag from May 2014 for that patch, ergo
also for this one.

v3: Incorporate comment about triple buffering as suggested
by Axel Davy, and reference to relevant spec provided by
Eric Anholt.

Signed-off-by: Frank Binns <frank.binns at imgtec.com>
Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Reviewed-by: Axel Davy <axel.davy at ens.fr>
Reviewed-by: Eric Anholt <eric at anholt.net>
(cherry picked from commit 455d3036fab2c5da7e589644f12435fb104a69fc)

---

 src/glx/dri3_glx.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index 5844f32..9b30c96 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -1483,6 +1483,7 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
    xcb_connection_t *c = XGetXCBConnection(dpy);
    struct dri3_buffer *back;
    int64_t ret = 0;
+   uint32_t options = XCB_PRESENT_OPTION_NONE;
 
    unsigned flags = __DRI2_FLUSH_DRAWABLE;
    if (flush)
@@ -1522,6 +1523,17 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
       if (target_msc == 0)
          target_msc = priv->msc + priv->swap_interval * (priv->send_sbc - priv->recv_sbc);
 
+      /* From the GLX_EXT_swap_control spec:
+       *
+       *     "If <interval> is set to a value of 0, buffer swaps are not
+       *      synchronized to a video frame."
+       *
+       * Implementation note: It is possible to enable triple buffering behaviour
+       * by not using XCB_PRESENT_OPTION_ASYNC, but this should not be the default.
+       */
+      if (priv->swap_interval == 0)
+          options |= XCB_PRESENT_OPTION_ASYNC;
+
       back->busy = 1;
       back->last_swap = priv->send_sbc;
       xcb_present_pixmap(c,
@@ -1535,7 +1547,7 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
                          None,                                 /* target_crtc */
                          None,
                          back->sync_fence,
-                         XCB_PRESENT_OPTION_NONE,
+                         options,
                          target_msc,
                          divisor,
                          remainder, 0, NULL);




More information about the mesa-commit mailing list