diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-05-23 09:13:31 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-05-23 09:49:05 +0100 |
commit | c8decdbccdefa87b635d871a8295608961f0d22e (patch) | |
tree | c30a0f25cae67fa65a7bb0b769f074ec6ce59629 | |
parent | a6613a8fe3908433ee33a167f57a0fae4e785a22 (diff) |
test/dri2: Check validity of MSC across CRTC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | test/dri2-test.c | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/test/dri2-test.c b/test/dri2-test.c index f712f125..d8ff3d9f 100644 --- a/test/dri2-test.c +++ b/test/dri2-test.c @@ -83,15 +83,6 @@ static void dri2_copy_swap(Display *dpy, Drawable d, XFixesDestroyRegion(dpy, region); } -static void xsync(Display *dpy, Window win) -{ - XImage *image; - - image = XGetImage(dpy, win, 0, 0, 1, 1, ~0, ZPixmap); - if (image) - XDestroyImage(image); -} - static double elapsed(const struct timespec *start, const struct timespec *end) { @@ -99,6 +90,17 @@ static double elapsed(const struct timespec *start, 1e-9*(end->tv_nsec - start->tv_nsec); } +static uint64_t check_msc(Display *dpy, Window win, uint64_t last_msc) +{ + uint64_t current_msc, current_ust, current_sbc; + DRI2GetMSC(dpy, win, ¤t_ust, ¤t_msc, ¤t_sbc); + if (current_msc < last_msc) { + printf("Invalid MSC: was %llu, now %llu\n", + (long long)last_msc, (long long)current_msc); + } + return current_msc; +} + static void run(Display *dpy, int width, int height, unsigned int *attachments, int nattachments, const char *name) @@ -108,6 +110,7 @@ static void run(Display *dpy, int width, int height, int count; DRI2Buffer *buffers; struct timespec start, end; + uint64_t msc; /* Be nasty and install a fullscreen window on top so that we * can guarantee we do not get clipped by children. @@ -120,29 +123,29 @@ static void run(Display *dpy, int width, int height, DefaultVisual(dpy, DefaultScreen(dpy)), CWOverrideRedirect, &attr); XMapWindow(dpy, win); - xsync(dpy, win); DRI2CreateDrawable(dpy, win); + msc = check_msc(dpy, win, 0); buffers = DRI2GetBuffers(dpy, win, &width, &height, attachments, nattachments, &count); if (count != nattachments) return; - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) DRI2SwapBuffers(dpy, win, 0, 0, 0); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) swaps in %fs.\n", count, name, width, height, elapsed(&start, &end)); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) dri2_copy_swap(dpy, win, width, height, nattachments == 2); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) blits in %fs.\n", @@ -150,11 +153,11 @@ static void run(Display *dpy, int width, int height, DRI2SwapInterval(dpy, win, 0); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) DRI2SwapBuffers(dpy, win, 0, 0, 0); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) vblank=0 swaps in %fs.\n", count, name, width, height, elapsed(&start, &end)); @@ -174,6 +177,8 @@ int main(void) DRI2BufferFrontLeft, }; XRRScreenResources *res; + Window root; + uint64_t last_msc; dpy = XOpenDisplay(NULL); if (dpy == NULL) @@ -186,16 +191,19 @@ int main(void) if (fd < 0) return 1; - res = _XRRGetScreenResourcesCurrent(dpy, DefaultRootWindow(dpy)); + root = DefaultRootWindow(dpy); + DRI2CreateDrawable(dpy, root); + + res = _XRRGetScreenResourcesCurrent(dpy, root); if (res == NULL) return 1; printf("noutput=%d, ncrtc=%d\n", res->noutput, res->ncrtc); - + last_msc = check_msc(dpy, root, 0); for (i = 0; i < res->ncrtc; i++) XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); - XSync(dpy, True); + last_msc = check_msc(dpy, root, last_msc); for (i = 0; i < res->noutput; i++) { XRROutputInfo *output; @@ -209,12 +217,17 @@ int main(void) if (res->nmode) mode = lookup_mode(res, output->modes[0]); - for (j = 0; mode && j < output->ncrtc; j++) { + for (j = 0; mode && j < 2*output->ncrtc; j++) { + int c = j; + if (c >= output->ncrtc) + c = 2*output->ncrtc - j - 1; + printf("[%d, %d] -- OUTPUT:%ld, CRTC:%ld\n", - i, j, (long)res->outputs[i], (long)output->crtcs[j]); - XRRSetCrtcConfig(dpy, res, output->crtcs[j], CurrentTime, + i, c, (long)res->outputs[i], (long)output->crtcs[c]); + last_msc = check_msc(dpy, root, last_msc); + XRRSetCrtcConfig(dpy, res, output->crtcs[c], CurrentTime, 0, 0, output->modes[0], RR_Rotate_0, &res->outputs[i], 1); - XSync(dpy, True); + last_msc = check_msc(dpy, root, last_msc); run(dpy, mode->width, mode->height, attachments, 1, "fullscreen"); run(dpy, mode->width, mode->height, attachments, 2, "fullscreen (with front)"); @@ -222,9 +235,10 @@ int main(void) run(dpy, mode->width/2, mode->height/2, attachments, 1, "windowed"); run(dpy, mode->width/2, mode->height/2, attachments, 2, "windowed (with front)"); - XRRSetCrtcConfig(dpy, res, output->crtcs[j], CurrentTime, + last_msc = check_msc(dpy, root, last_msc); + XRRSetCrtcConfig(dpy, res, output->crtcs[c], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); - XSync(dpy, True); + last_msc = check_msc(dpy, root, last_msc); } XRRFreeOutputInfo(output); |