diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-04-06 14:00:44 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-04-06 14:02:41 +0100 |
commit | c47fd1dcada882757573261a0d714bccad5aa21c (patch) | |
tree | cb1a2ad04c1cef584cd319ee5b946c8ca428d8e7 | |
parent | e74ff581449e92d7933da1b5df6680cb880fc454 (diff) |
test/present: Synchronize MSC notifiy modulus test to the vblank
As the test presumes we can queue all the modulus queries within the
same vblank, we can improve matters by synchronizing to the next vblank
first.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | test/present-test.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/test/present-test.c b/test/present-test.c index f63e9def..3630241a 100644 --- a/test/present-test.c +++ b/test/present-test.c @@ -178,6 +178,39 @@ static uint64_t check_msc(Display *dpy, Window win, void *q, uint64_t last_msc, return msc; } +static uint64_t wait_vblank(Display *dpy, Window win, void *q) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + static uint32_t serial = 1; + uint64_t msc = 0; + int complete = 0; + + xcb_present_notify_msc(c, win, serial ^ 0xdeadbeef, 0, 1, 0); + xcb_flush(c); + + do { + xcb_present_complete_notify_event_t *ce; + xcb_generic_event_t *ev; + + ev = xcb_wait_for_special_event(c, q); + if (ev == NULL) + break; + + ce = (xcb_present_complete_notify_event_t *)ev; + if (ce->kind == XCB_PRESENT_COMPLETE_KIND_NOTIFY_MSC && + ce->serial == (serial ^ 0xdeadbeef)) { + msc = ce->msc; + complete = 1; + } + free(ev); + } while (!complete); + + if (++serial == 0) + serial = 1; + + return msc; +} + static uint64_t msc_interval(Display *dpy, Window win, void *q) { xcb_connection_t *c = XGetXCBConnection(dpy); @@ -1095,13 +1128,12 @@ static int test_modulus_msc(Display *dpy, void *Q) printf("Testing notify modulus\n"); _x_error_occurred = 0; - target = check_msc(dpy, root, Q, 0, NULL); + target = wait_vblank(dpy, root, Q); xcb_present_notify_msc(c, root, 0, 0, 0, 0); for (x = 1; x <= 19; x++) { - for (y = 0; y < x; y++) { + for (y = 0; y < x; y++) xcb_present_notify_msc(c, root, y << 16 | x, 0, x, y); - } } xcb_present_notify_msc(c, root, 0xdeadbeef, target + 2*x, 0, 0); xcb_flush(c); @@ -1111,6 +1143,7 @@ static int test_modulus_msc(Display *dpy, void *Q) ce = (xcb_present_complete_notify_event_t *)ev; assert(ce->kind == XCB_PRESENT_COMPLETE_KIND_NOTIFY_MSC); assert(ce->serial == 0); + assert(target == ce->msc); target = ce->msc; } |