glx: Replace DRI2WaitForMSC custom protocol with XCB.
authorEric Anholt <eric@anholt.net>
Tue, 25 Sep 2012 19:01:27 +0000 (12:01 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 9 Oct 2012 21:32:03 +0000 (14:32 -0700)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
src/glx/dri2.c
src/glx/dri2.h
src/glx/dri2_glx.c

index 21b9c21a85cf218d9d93b44bf480efe29f0d16c8..96c2ae87aed59d36428375cdfb1152d7c5e621ba 100644 (file)
@@ -618,52 +618,6 @@ Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc,
 }
 #endif
 
-#ifdef X_DRI2WaitMSC
-static void
-load_msc_req(xDRI2WaitMSCReq *req, CARD64 target, CARD64 divisor,
-            CARD64 remainder)
-{
-    req->target_msc_hi = target >> 32;
-    req->target_msc_lo = target & 0xffffffff;
-    req->divisor_hi = divisor >> 32;
-    req->divisor_lo = divisor & 0xffffffff;
-    req->remainder_hi = remainder >> 32;
-    req->remainder_lo = remainder & 0xffffffff;
-}
-
-Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
-                CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
-{
-    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
-    xDRI2WaitMSCReq *req;
-    xDRI2MSCReply rep;
-
-    XextCheckExtension (dpy, info, dri2ExtensionName, False);
-
-    LockDisplay(dpy);
-    GetReq(DRI2WaitMSC, req);
-    req->reqType = info->codes->major_opcode;
-    req->dri2ReqType = X_DRI2WaitMSC;
-    req->drawable = drawable;
-    load_msc_req(req, target_msc, divisor, remainder);
-
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-       return False;
-    }
-
-    *ust = ((CARD64)rep.ust_hi << 32) | (CARD64)rep.ust_lo;
-    *msc = ((CARD64)rep.msc_hi << 32) | (CARD64)rep.msc_lo;
-    *sbc = ((CARD64)rep.sbc_hi << 32) | (CARD64)rep.sbc_lo;
-
-    UnlockDisplay(dpy);
-    SyncHandle();
-
-    return True;
-}
-#endif
-
 #ifdef X_DRI2SwapInterval
 void DRI2SwapInterval(Display *dpy, XID drawable, int interval)
 {
index bfd9910f792c71d23dac1c435d9e8f8ba48fa416..fe7c24e40ac96f8e648c02ed4f57a694a4373f3e 100644 (file)
@@ -92,10 +92,6 @@ DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
 extern Bool
 DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
 
-extern Bool
-DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
-           CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
-
 extern void
 DRI2SwapInterval(Display *dpy, XID drawable, int interval);
 
index 1cfa275c27a74fd40b8864ad8f59a5257e4e2860..60dc0354ca52ebcb9095f1499814ab0bcc955123 100644 (file)
@@ -452,23 +452,32 @@ dri2DrawableGetMSC(struct glx_screen *psc, __GLXDRIdrawable *pdraw,
 
 #endif
 
-
-#ifdef X_DRI2WaitMSC
-
 static int
 dri2WaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
               int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc)
 {
-   CARD64 dri2_ust, dri2_msc, dri2_sbc;
-   int ret;
-
-   ret = DRI2WaitMSC(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor,
-                    remainder, &dri2_ust, &dri2_msc, &dri2_sbc);
-   *ust = dri2_ust;
-   *msc = dri2_msc;
-   *sbc = dri2_sbc;
+   xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
+   xcb_dri2_wait_msc_cookie_t wait_msc_cookie;
+   xcb_dri2_wait_msc_reply_t *wait_msc_reply;
+   uint32_t target_msc_hi, target_msc_lo;
+   uint32_t divisor_hi, divisor_lo;
+   uint32_t remainder_hi, remainder_lo;
+
+   split_counter(target_msc, &target_msc_hi, &target_msc_lo);
+   split_counter(divisor, &divisor_hi, &divisor_lo);
+   split_counter(remainder, &remainder_hi, &remainder_lo);
+
+   wait_msc_cookie = xcb_dri2_wait_msc_unchecked(c, pdraw->xDrawable,
+                                                 target_msc_hi, target_msc_lo,
+                                                 divisor_hi, divisor_lo,
+                                                 remainder_hi, remainder_lo);
+   wait_msc_reply = xcb_dri2_wait_msc_reply(c, wait_msc_cookie, NULL);
+   *ust = merge_counter(wait_msc_reply->ust_hi, wait_msc_reply->ust_lo);
+   *msc = merge_counter(wait_msc_reply->msc_hi, wait_msc_reply->msc_lo);
+   *sbc = merge_counter(wait_msc_reply->sbc_hi, wait_msc_reply->sbc_lo);
+   free(wait_msc_reply);
 
-   return ret;
+   return 0;
 }
 
 static int
@@ -493,8 +502,6 @@ dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
    return 0;
 }
 
-#endif /* X_DRI2WaitMSC */
-
 /**
  * dri2Throttle - Request driver throttling
  *
@@ -1143,9 +1150,7 @@ dri2CreateScreen(int screen, struct glx_display * priv)
 #ifdef X_DRI2GetMSC
       psp->getDrawableMSC = dri2DrawableGetMSC;
 #endif
-#ifdef X_DRI2WaitMSC
       psp->waitForMSC = dri2WaitForMSC;
-#endif
       psp->waitForSBC = dri2WaitForSBC;
 #ifdef X_DRI2SwapInterval
       psp->setSwapInterval = dri2SetSwapInterval;