diff options
Diffstat (limited to 'test/dri2-test.c')
-rw-r--r-- | test/dri2-test.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/test/dri2-test.c b/test/dri2-test.c index d44ed99d..b88e65c7 100644 --- a/test/dri2-test.c +++ b/test/dri2-test.c @@ -105,6 +105,12 @@ static uint64_t check_msc(Display *dpy, Window win, uint64_t last_msc) return current_msc; } +static void wait_next_vblank(Display *dpy, Window win) +{ + uint64_t msc, ust, sbc; + DRI2WaitMSC(dpy, win, 0, 1, 0, &ust, &msc, &sbc); +} + static void swap_buffers(xcb_connection_t *c, Window win, unsigned int *attachments, int nattachments) { @@ -133,7 +139,7 @@ static void run(Display *dpy, int width, int height, int count; DRI2Buffer *buffers; struct timespec start, end; - uint64_t msc; + uint64_t start_msc, end_msc; /* Be nasty and install a fullscreen window on top so that we * can guarantee we do not get clipped by children. @@ -148,7 +154,7 @@ static void run(Display *dpy, int width, int height, XMapWindow(dpy, win); DRI2CreateDrawable(dpy, win); - msc = check_msc(dpy, win, 0); + start_msc = check_msc(dpy, win, 0); buffers = DRI2GetBuffers(dpy, win, &width, &height, attachments, nattachments, &count); @@ -156,37 +162,50 @@ static void run(Display *dpy, int width, int height, return; swap_buffers(c, win, attachments, nattachments); - msc = check_msc(dpy, win, msc); + start_msc = check_msc(dpy, win, start_msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) swap_buffers(c, win, attachments, nattachments); - msc = check_msc(dpy, win, msc); + end_msc = check_msc(dpy, win, start_msc); clock_gettime(CLOCK_MONOTONIC, &end); - printf("%d %s (%dx%d) swaps in %fs.\n", - count, name, width, height, elapsed(&start, &end)); + printf("%d [%ld] %s (%dx%d) swaps in %fs.\n", + count, (long)(end_msc - start_msc), + name, width, height, elapsed(&start, &end)); swap_buffers(c, win, attachments, nattachments); - msc = check_msc(dpy, win, msc); + start_msc = check_msc(dpy, win, end_msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) dri2_copy_swap(dpy, win, width, height, nattachments == 2); - msc = check_msc(dpy, win, msc); + end_msc = check_msc(dpy, win, start_msc); clock_gettime(CLOCK_MONOTONIC, &end); - printf("%d %s (%dx%d) blits in %fs.\n", - count, name, width, height, elapsed(&start, &end)); + printf("%d [%ld] %s (%dx%d) blits in %fs.\n", + count, (long)(end_msc - start_msc), + name, width, height, elapsed(&start, &end)); DRI2SwapInterval(dpy, win, 0); swap_buffers(c, win, attachments, nattachments); - msc = check_msc(dpy, win, msc); + start_msc = check_msc(dpy, win, end_msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) swap_buffers(c, win, attachments, nattachments); - msc = check_msc(dpy, win, msc); + end_msc = check_msc(dpy, win, start_msc); + clock_gettime(CLOCK_MONOTONIC, &end); + printf("%d [%ld] %s (%dx%d) vblank=0 swaps in %fs.\n", + count, (long)(end_msc - start_msc), + name, width, height, elapsed(&start, &end)); + + start_msc = check_msc(dpy, win, end_msc); + clock_gettime(CLOCK_MONOTONIC, &start); + for (count = 0; count < COUNT; count++) + wait_next_vblank(dpy, win); + end_msc = check_msc(dpy, win, start_msc); clock_gettime(CLOCK_MONOTONIC, &end); - printf("%d %s (%dx%d) vblank=0 swaps in %fs.\n", - count, name, width, height, elapsed(&start, &end)); + printf("%d [%ld] %s waits in %fs.\n", + count, (long)(end_msc - start_msc), + name, elapsed(&start, &end)); XDestroyWindow(dpy, win); free(buffers); |