[Mesa-dev] [RFC PATCH] dri3: Sync after buffer swaps with glXSwapBuffers

Thomas Hellstrom thellstrom at vmware.com
Mon Jun 19 15:44:10 UTC 2017


Applications calling glXSwapBuffers should be able to expect that any X
rendering submitted after the call to glXSwapBuffers returns should be ordered
with respect to the glXSwapBuffers call. (For example piglit reading out from
a window). This appears not to be the case at least with the current server
side present extension implementation.

Fixes piglit glx-multithread-texture on svga/vmwgfx.

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
---
 src/loader/loader_dri3_helper.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 493a7f5..97abd7e 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -634,6 +634,7 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
    int64_t ret = 0;
    uint32_t options = XCB_PRESENT_OPTION_NONE;
    int swap_interval;
+   bool sync_after_swap = false;
 
    dri_context = draw->vtable->get_dri_context(draw);
    swap_interval = draw->vtable->get_swap_interval(draw);
@@ -671,10 +672,11 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
        * semantic"
        */
       ++draw->send_sbc;
-      if (target_msc == 0 && divisor == 0 && remainder == 0)
+      if (target_msc == 0 && divisor == 0 && remainder == 0) {
          target_msc = draw->msc + swap_interval *
-                      (draw->send_sbc - draw->recv_sbc);
-      else if (divisor == 0 && remainder > 0) {
+            (draw->send_sbc - draw->recv_sbc);
+         sync_after_swap = true;
+      } else if (divisor == 0 && remainder > 0) {
          /* From the GLX_OML_sync_control spec:
           *     "If <divisor> = 0, the swap will occur when MSC becomes
           *      greater than or equal to <target_msc>."
@@ -741,6 +743,11 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
    }
 
    draw->ext->flush->invalidate(draw->dri_drawable);
+   if (sync_after_swap) {
+      int64_t ust, msc, sbc;
+
+      (void) loader_dri3_wait_for_sbc(draw, 0, &ust, &msc, &sbc);
+   }
 
    return ret;
 }
-- 
2.7.4



More information about the mesa-dev mailing list