Skip to content

Commit

Permalink
Revert "glx: Replace DRI2WaitForSBC custom protocol with XCB."
Browse files Browse the repository at this point in the history
This reverts commit 183ab9e.
  • Loading branch information
keith-packard authored and courtney-lunarg committed Jun 25, 2014
1 parent 278a5c8 commit b5a6537
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 34 deletions.
41 changes: 41 additions & 0 deletions src/glx/dri2.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,47 @@ Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
}
#endif

#ifdef X_DRI2WaitSBC
static void
load_sbc_req(xDRI2WaitSBCReq *req, CARD64 target)
{
req->target_sbc_hi = target >> 32;
req->target_sbc_lo = target & 0xffffffff;
}

Bool DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
CARD64 *msc, CARD64 *sbc)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2WaitSBCReq *req;
xDRI2MSCReply rep;

XextCheckExtension (dpy, info, dri2ExtensionName, False);

LockDisplay(dpy);
GetReq(DRI2WaitSBC, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2WaitSBC;
req->drawable = drawable;
load_sbc_req(req, target_sbc);

if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}

*ust = ((CARD64)rep.ust_hi << 32) | rep.ust_lo;
*msc = ((CARD64)rep.msc_hi << 32) | rep.msc_lo;
*sbc = ((CARD64)rep.sbc_hi << 32) | rep.sbc_lo;

UnlockDisplay(dpy);
SyncHandle();

return True;
}
#endif

#ifdef X_DRI2SwapInterval
void DRI2SwapInterval(Display *dpy, XID drawable, int interval)
{
Expand Down
4 changes: 4 additions & 0 deletions src/glx/dri2.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ extern Bool
DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc);

extern Bool
DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
CARD64 *msc, CARD64 *sbc);

extern void
DRI2SwapInterval(Display *dpy, XID drawable, int interval);

Expand Down
43 changes: 9 additions & 34 deletions src/glx/dri2_glx.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@

#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>
Expand Down Expand Up @@ -103,22 +100,6 @@ 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)
{
Expand Down Expand Up @@ -479,22 +460,16 @@ static int
dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc)
{
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;

split_counter(target_sbc, &target_sbc_hi, &target_sbc_lo);
CARD64 dri2_ust, dri2_msc, dri2_sbc;
int 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);
ret = DRI2WaitSBC(pdraw->psc->dpy, pdraw->xDrawable,
target_sbc, &dri2_ust, &dri2_msc, &dri2_sbc);
*ust = dri2_ust;
*msc = dri2_msc;
*sbc = dri2_sbc;

return 0;
return ret;
}
#endif /* X_DRI2WaitMSC */

Expand Down Expand Up @@ -1236,8 +1211,8 @@ dri2CreateScreen(int screen, struct glx_display * priv)
#endif
#ifdef X_DRI2WaitMSC
psp->waitForMSC = dri2WaitForMSC;
#endif
psp->waitForSBC = dri2WaitForSBC;
#endif
#ifdef X_DRI2SwapInterval
psp->setSwapInterval = dri2SetSwapInterval;
psp->getSwapInterval = dri2GetSwapInterval;
Expand Down

0 comments on commit b5a6537

Please sign in to comment.