This looks good to land to me:<div><br></div><div>Reviewed-by: Robert Bragg <<a href="mailto:robert@linux.intel.com">robert@linux.intel.com</a>></div><div><br></div><div>thanks,</div><div>- Robert</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Nov 28, 2012 at 4:47 PM,  <span dir="ltr"><<a href="mailto:otaylor@redhat.com" target="_blank">otaylor@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: "Owen W. Taylor" <<a href="mailto:otaylor@fishsoup.net">otaylor@fishsoup.net</a>><br>
<br>
When we block waiting for the swap, prefer doing that using<br>
glXWaitForMsc() from OML_sync_control because that returns a system<br>
time value for the precise time of the swap.<br>
---<br>
 cogl/winsys/cogl-winsys-glx-feature-functions.h | 23 +++++++++++++++++<br>
 cogl/winsys/cogl-winsys-glx.c                   | 34 ++++++++++++++++++++-----<br>
 2 files changed, 50 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/cogl/winsys/cogl-winsys-glx-feature-functions.h b/cogl/winsys/cogl-winsys-glx-feature-functions.h<br>
index 71fd827..837b22b 100644<br>
--- a/cogl/winsys/cogl-winsys-glx-feature-functions.h<br>
+++ b/cogl/winsys/cogl-winsys-glx-feature-functions.h<br>
@@ -84,6 +84,29 @@ COGL_WINSYS_FEATURE_FUNCTION (int, glXSwapInterval,<br>
                               (int interval))<br>
 COGL_WINSYS_FEATURE_END ()<br>
<br>
+COGL_WINSYS_FEATURE_BEGIN (sync_control,<br>
+                           "OML\0",<br>
+                           "sync_control\0",<br>
+                           0,<br>
+                           0,<br>
+                           0)<br>
+COGL_WINSYS_FEATURE_FUNCTION (Bool, glXGetSyncValues,<br>
+                              (Display* dpy,<br>
+                               GLXDrawable drawable,<br>
+                               int64_t* ust,<br>
+                               int64_t* msc,<br>
+                               int64_t* sbc))<br>
+COGL_WINSYS_FEATURE_FUNCTION (Bool, glXWaitForMsc,<br>
+                              (Display* dpy,<br>
+                               GLXDrawable drawable,<br>
+                               int64_t target_msc,<br>
+                               int64_t divisor,<br>
+                               int64_t remainder,<br>
+                               int64_t* ust,<br>
+                               int64_t* msc,<br>
+                               int64_t* sbc))<br>
+COGL_WINSYS_FEATURE_END ()<br>
+<br>
 COGL_WINSYS_FEATURE_BEGIN (copy_sub_buffer,<br>
                            "MESA\0",<br>
                            "copy_sub_buffer\0",<br>
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c<br>
index e7f83ab..4714c9a 100644<br>
--- a/cogl/winsys/cogl-winsys-glx.c<br>
+++ b/cogl/winsys/cogl-winsys-glx.c<br>
@@ -525,7 +525,8 @@ update_winsys_features (CoglContext *context, GError **error)<br>
                       FALSE);<br>
     }<br>
<br>
-  if (glx_renderer->pf_glXWaitVideoSync)<br>
+  if (glx_renderer->pf_glXWaitVideoSync ||<br>
+      glx_renderer->pf_glXWaitForMsc)<br>
     COGL_FLAGS_SET (context->winsys_features,<br>
                     COGL_WINSYS_FEATURE_VBLANK_WAIT,<br>
                     TRUE);<br>
@@ -1224,14 +1225,33 @@ _cogl_winsys_wait_for_vblank (void)<br>
<br>
   glx_renderer = ctx->display->renderer->winsys;<br>
<br>
-  if (glx_renderer->pf_glXGetVideoSync)<br>
+  if (glx_renderer->pf_glXWaitForMsc ||<br>
+      glx_renderer->pf_glXGetVideoSync)<br>
     {<br>
-      uint32_t current_count;<br>
<br>
-      glx_renderer->pf_glXGetVideoSync (&current_count);<br>
-      glx_renderer->pf_glXWaitVideoSync (2,<br>
-                                         (current_count + 1) % 2,<br>
-                                         &current_count);<br>
+      if (glx_renderer->pf_glXWaitForMsc)<br>
+        {<br>
+          CoglOnscreenGLX *glx_onscreen = onscreen->winsys;<br>
+          Drawable drawable = glx_onscreen->glxwin;<br>
+          int64_t ust;<br>
+          int64_t msc;<br>
+          int64_t sbc;<br>
+<br>
+          glx_renderer->pf_glXGetSyncValues (xlib_renderer->xdpy, drawable,<br>
+                                             &ust, &msc, &sbc);<br>
+          glx_renderer->pf_glXWaitForMsc (xlib_renderer->xdpy, drawable,<br>
+                                          0, 2, (msc + 1) % 2,<br>
+                                          &ust, &msc, &sbc);<br>
+        }<br>
+      else<br>
+        {<br>
+          uint32_t current_count;<br>
+<br>
+          glx_renderer->pf_glXGetVideoSync (&current_count);<br>
+          glx_renderer->pf_glXWaitVideoSync (2,<br>
+                                             (current_count + 1) % 2,<br>
+                                             &current_count);<br>
+        }<br>
     }<br>
 }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.7.12.1<br>
<br>
_______________________________________________<br>
Cogl mailing list<br>
<a href="mailto:Cogl@lists.freedesktop.org">Cogl@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/cogl" target="_blank">http://lists.freedesktop.org/mailman/listinfo/cogl</a><br>
</font></span></blockquote></div><br></div>