glx/dri3: Fix glXWaitForSbcOML() to handle targetSBC==0 correctly. (v2)
authorMario Kleiner <mario.kleiner.de@gmail.com>
Fri, 5 Dec 2014 07:42:29 +0000 (08:42 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sun, 14 Dec 2014 15:09:49 +0000 (15:09 +0000)
targetSBC == 0 is a special case, which asks the function
to block until all pending OpenGL bufferswap requests have
completed.

Currently the function just falls through for targetSBC == 0,
returning bogus results.

This breaks applications originally written and tested against
DRI2 which also rely on this not regressing under DRI3/Present,
e.g., Neuro-Science software like Psychtoolbox-3.

This patch fixes the problem.

v2: Simplify as suggested by Axel Davy. Add comments proposed
by Eric Anholt.

Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glx/dri3_glx.c

index a9ff73b36f4c75ef09fbe26f4272b34eee5342c7..15d874d660fdb6abc398fa1ff7b295a17d4e4291 100644 (file)
@@ -529,6 +529,15 @@ dri3_wait_for_sbc(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
 {
    struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
 
+   /* From the GLX_OML_sync_control spec:
+    *
+    *     "If <target_sbc> = 0, the function will block until all previous
+    *      swaps requested with glXSwapBuffersMscOML for that window have
+    *      completed."
+    */
+   if (!target_sbc)
+      target_sbc = priv->send_sbc;
+
    while (priv->recv_sbc < target_sbc) {
       if (!dri3_wait_for_event(pdraw))
          return 0;