glx: Don't flush twice if we fallback to dri2CopySubBuffer
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 18 Aug 2011 12:46:02 +0000 (08:46 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 18 Aug 2011 13:46:06 +0000 (09:46 -0400)
The flush extensions flush call indicates end of frame and should only
be called once per frame.  However, in the dri2SwapBuffer fallback
path, we call flush and then call dri2CopySubBuffer, which also calls
flush.  Refactor the code to only call flush once.

src/glx/dri2_glx.c

index d9524d765bd5b97367abc82d996153791a8fa4fa..9fa0d5ad3628674ab712ab6d5bffd67722e54e03 100644 (file)
@@ -543,6 +543,11 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
        (struct dri2_display *)dpyPriv->dri2Display;
     CARD64 ret = 0;
 
+    /* Old servers can't handle swapbuffers */
+    if (!pdp->swapAvailable) {
+       dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height);
+    } else {
+#ifdef X_DRI2SwapBuffers
 #ifdef __DRI2_FLUSH
     if (psc->f) {
        struct glx_context *gc = __glXGetCurrentContext();
@@ -553,21 +558,15 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
     }
 #endif
 
+       DRI2SwapBuffers(psc->base.dpy, pdraw->xDrawable,
+                      target_msc, divisor, remainder, &ret);
+#endif
+    }
+
     /* Old servers don't send invalidate events */
     if (!pdp->invalidateAvailable)
        dri2InvalidateBuffers(dpyPriv->dpy, pdraw->xDrawable);
 
-    /* Old servers can't handle swapbuffers */
-    if (!pdp->swapAvailable) {
-       dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height);
-       return 0;
-    }
-
-#ifdef X_DRI2SwapBuffers
-    DRI2SwapBuffers(psc->base.dpy, pdraw->xDrawable, target_msc, divisor,
-                   remainder, &ret);
-#endif
-
     return ret;
 }