summaryrefslogtreecommitdiffstats
path: root/src/glx/dri2_glx.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-09-25 11:39:17 -0700
committerEric Anholt <[email protected]>2012-10-09 14:32:03 -0700
commit183ab9e14efed2c5483a472ea8feff31fcf6d2a9 (patch)
tree8d05acf22fd974207ce66196e7b2fdf41dd67ce7 /src/glx/dri2_glx.c
parent1e74910bb7c3882c272c34ca1ed559b0b0058fa8 (diff)
glx: Replace DRI2WaitForSBC custom protocol with XCB.
Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/glx/dri2_glx.c')
-rw-r--r--src/glx/dri2_glx.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index e35ae5e3805..1cfa275c27a 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -34,6 +34,9 @@
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
+#include <X11/Xlib-xcb.h>
+#include <xcb/xcb.h>
+#include <xcb/dri2.h>
#include "glapi.h"
#include "glxclient.h"
#include <X11/extensions/dri2proto.h>
@@ -118,6 +121,22 @@ struct dri2_drawable
static const struct glx_context_vtable dri2_context_vtable;
+/* For XCB's handling of ust/msc/sbc counters, we have to hand it the high and
+ * low halves separately. This helps you split them.
+ */
+static void
+split_counter(uint64_t counter, uint32_t *hi, uint32_t *lo)
+{
+ *hi = (counter >> 32);
+ *lo = counter & 0xffffffff;
+}
+
+static uint64_t
+merge_counter(uint32_t hi, uint32_t lo)
+{
+ return ((uint64_t)hi << 32) | lo;
+}
+
static void
dri2_destroy_context(struct glx_context *context)
{
@@ -456,16 +475,22 @@ static int
dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc)
{
- CARD64 dri2_ust, dri2_msc, dri2_sbc;
- int ret;
+ xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
+ xcb_dri2_wait_sbc_cookie_t wait_sbc_cookie;
+ xcb_dri2_wait_sbc_reply_t *wait_sbc_reply;
+ uint32_t target_sbc_hi, target_sbc_lo;
- ret = DRI2WaitSBC(pdraw->psc->dpy, pdraw->xDrawable,
- target_sbc, &dri2_ust, &dri2_msc, &dri2_sbc);
- *ust = dri2_ust;
- *msc = dri2_msc;
- *sbc = dri2_sbc;
+ split_counter(target_sbc, &target_sbc_hi, &target_sbc_lo);
- return ret;
+ wait_sbc_cookie = xcb_dri2_wait_sbc_unchecked(c, pdraw->xDrawable,
+ target_sbc_hi, target_sbc_lo);
+ wait_sbc_reply = xcb_dri2_wait_sbc_reply(c, wait_sbc_cookie, NULL);
+ *ust = merge_counter(wait_sbc_reply->ust_hi, wait_sbc_reply->ust_lo);
+ *msc = merge_counter(wait_sbc_reply->msc_hi, wait_sbc_reply->msc_lo);
+ *sbc = merge_counter(wait_sbc_reply->sbc_hi, wait_sbc_reply->sbc_lo);
+ free(wait_sbc_reply);
+
+ return 0;
}
#endif /* X_DRI2WaitMSC */
@@ -1120,8 +1145,8 @@ dri2CreateScreen(int screen, struct glx_display * priv)
#endif
#ifdef X_DRI2WaitMSC
psp->waitForMSC = dri2WaitForMSC;
- psp->waitForSBC = dri2WaitForSBC;
#endif
+ psp->waitForSBC = dri2WaitForSBC;
#ifdef X_DRI2SwapInterval
psp->setSwapInterval = dri2SetSwapInterval;
psp->getSwapInterval = dri2GetSwapInterval;