[Mesa-dev] [PATCH] glx/dri3: request async pixmap present for swap interval 0

Frank Binns frank.binns at imgtec.com
Thu Apr 24 05:19:44 PDT 2014


Typically we want swaps to occur during vertical blank to avoid
tearing. However, when the swap interval is 0 we want to go
as quickly as possible even if this results in tearing.

Indicate to the X server that it should attempt to do an
asynchronise swap when the swap interval is 0.

Signed-off-by: Frank Binns <frank.binns at imgtec.com>
---
 src/glx/dri3_glx.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index b7dac8e..e385723 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -1321,6 +1321,7 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
    xcb_connection_t *c = XGetXCBConnection(dpy);
    int buf_id = DRI3_BACK_ID(priv->cur_back);
    int64_t ret = 0;
+   uint32_t options = XCB_PRESENT_OPTION_NONE;
 
    unsigned flags = __DRI2_FLUSH_DRAWABLE;
    if (flush)
@@ -1339,6 +1340,9 @@ 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);
 
+      if (priv->swap_interval == 0)
+         options |= XCB_PRESENT_OPTION_ASYNC;
+
       priv->buffers[buf_id]->busy = 1;
       priv->buffers[buf_id]->last_swap = priv->send_sbc;
       xcb_present_pixmap(c,
@@ -1352,7 +1356,7 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
                          None,                                 /* target_crtc */
                          None,
                          priv->buffers[buf_id]->sync_fence,
-                         XCB_PRESENT_OPTION_NONE,
+                         options,
                          target_msc,
                          divisor,
                          remainder, 0, NULL);
-- 
1.8.5.4.gfdaaaa2



More information about the mesa-dev mailing list