The swap complete event wasn't being handled fully; because XEvents are only 32 bytes long, we were getting junk for the sbc_lo value. If the server supports it, unpack the new structure, otherwise just return 0 for the sbc value instead of garbage. --- configure.ac | 4 ++-- src/glx/dri2.c | 7 ++++++- src/glx/dri2_glx.c | 13 +++++++++++++ src/glx/glxclient.h | 1 + src/glx/glxext.c | 8 +++++++- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 3b05ca3..94fb6f7 100644 --- a/configure.ac +++ b/configure.ac @@ -21,8 +21,8 @@ dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.24 LIBDRM_RADEON_REQUIRED=2.4.24 LIBDRM_INTEL_REQUIRED=2.4.24 -DRI2PROTO_REQUIRED=2.1 -GLPROTO_REQUIRED=1.4.11 +DRI2PROTO_REQUIRED=2.4 +GLPROTO_REQUIRED=1.4.13 LIBDRM_XORG_REQUIRED=2.4.24 LIBKMS_XORG_REQUIRED=1.0.0 diff --git a/src/glx/dri2.c b/src/glx/dri2.c index adfd3d1..864c941 100644 --- a/src/glx/dri2.c +++ b/src/glx/dri2.c @@ -124,7 +124,12 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire) } aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; - aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo; + if (dri2ServerSupportsSBC(dpy)) { + aevent->sbc = ((CARD64)awire->sbc_hi << 32) | (awire->sbc_lo16 << 16) | + (awire->sbc_lo8 << 8) | awire->sbc_lo0; + } else { + aevent->sbc = 0; + } return True; } #endif diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index fc0237a..be96ec6 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -791,6 +791,19 @@ static const struct glx_screen_vtable dri2_screen_vtable = { dri2_create_context }; +int +dri2ServerSupportsSBC(Display *dpy) +{ + struct glx_display *dpyPriv = __glXInitialize(dpy); + struct dri2_display *pdp = + (struct dri2_display *) dpyPriv->dri2Display; + + if (pdp->driMajor > 1 || (pdp->driMajor == 1 && pdp->driMinor > 3)) + return 1; + + return 0; +} + static struct glx_screen * dri2CreateScreen(int screen, struct glx_display * priv) { diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 2b6966f..acba82c 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -149,6 +149,7 @@ extern __GLXDRIdisplay *driCreateDisplay(Display * dpy); extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy); extern void dri2InvalidateBuffers(Display *dpy, XID drawable); extern unsigned dri2GetSwapEventType(Display *dpy, XID drawable); +extern int dri2ServerSupportsSBC(Display *dpy); /* diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 278c719..7393efc 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -138,7 +138,13 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire) aevent->drawable = awire->drawable; aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; - aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo; + if (glx_dpy->majorVersion > 1 || (glx_dpy->majorVersion == 1 && + glx_dpy->minorVersion > 4)) { + aevent->sbc = ((CARD64)awire->sbc_hi << 32) | (awire->sbc_lo16 << 16) | + (awire->sbc_lo8 << 8) | awire->sbc_lo0; + } else { + aevent->sbc = 0; + } return True; } default: -- 1.7.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel