diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-02-03 09:56:58 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-02-03 09:58:05 +0000 |
commit | 1c95b7e81140746e2904dbdf7b066937442243d7 (patch) | |
tree | cd50c467ef6eb148f4744b4dcbd9a1bc1ad1149f | |
parent | 65e6bae3ac250cb5f77f9e41498c4aad600fa9b5 (diff) |
test/dri2-test: Add WaitMSC accuracy tests
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | test/dri2-test.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/test/dri2-test.c b/test/dri2-test.c index d5753050..bdf01f38 100644 --- a/test/dri2-test.c +++ b/test/dri2-test.c @@ -22,6 +22,8 @@ #define COUNT 60 +static int prime[] = { 0, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 27, 29, 31, 37, 41, 43, 47, 51, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 }; + static inline XRRScreenResources *_XRRGetScreenResourcesCurrent(Display *dpy, Window window) { XRRScreenResources *res; @@ -136,10 +138,10 @@ static void run(Display *dpy, int width, int height, xcb_connection_t *c = XGetXCBConnection(dpy); Window win; XSetWindowAttributes attr; - int count; DRI2Buffer *buffers; struct timespec start, end; uint64_t start_msc, end_msc; + int modulus, remainder, count; /* Be nasty and install a fullscreen window on top so that we * can guarantee we do not get clipped by children. @@ -209,6 +211,45 @@ static void run(Display *dpy, int width, int height, count, (long)(end_msc - start_msc), name, elapsed(&start, &end)); + printf("Testing past & future waits\n"); + for (modulus = 1; modulus <= 128; modulus <<= 1) { + for (count = 0; prime[count] < modulus; count++) { + uint64_t msc, ust, sbc; + uint64_t target; + + remainder = prime[count]; + + DRI2WaitMSC(dpy, win, 0, 1, 0, &ust, &msc, &sbc); + + target = msc + modulus + 1; + target &= -modulus; + target += remainder; + + DRI2WaitMSC(dpy, win, target, modulus, remainder, + &ust, &msc, &sbc); + if (msc != target) { + printf("Missed future MSC (%d, %d): expected=%lld, found=%lld\n", + modulus, remainder, + (long long)target, (long long)msc); + } + + target = msc; + target &= -modulus; + target += remainder; + if (target <= msc) + target += modulus; + + DRI2WaitMSC(dpy, win, msc, modulus, remainder, + &ust, &msc, &sbc); + + if (msc != target) { + printf("Missed past MSC (%d, %d): expected=%lld, found=%lld\n", + modulus, remainder, + (long long)target, (long long)msc); + } + } + } + XDestroyWindow(dpy, win); free(buffers); |