diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-01-28 11:44:41 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-01-28 11:46:43 +0000 |
commit | 2e7ae76038c808d80c39dfaa56ad4648cd94e7fc (patch) | |
tree | d40163d890c9fcfdfa2b3fbca39c6693e718d15d /test | |
parent | 6f6190abcfc3abdefdb2826415e242749fcfb9f8 (diff) |
test/dri2: Use xcb for more accurate timing of SwapBuffers
To do SwapBuffers correctly requires a Swap/Get buffers combination, and
this is easiest using xcb rather than xlib.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'test')
-rw-r--r-- | test/dri2-test.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/test/dri2-test.c b/test/dri2-test.c index dd4179f3..d44ed99d 100644 --- a/test/dri2-test.c +++ b/test/dri2-test.c @@ -6,6 +6,10 @@ #include <X11/Xutil.h> #include <X11/extensions/Xfixes.h> #include <X11/extensions/Xrandr.h> +#include <X11/Xlib-xcb.h> +#include <xcb/xcb.h> +#include <xcb/xcbext.h> +#include <xcb/dri2.h> #include <unistd.h> #include <fcntl.h> #include <string.h> @@ -101,10 +105,29 @@ static uint64_t check_msc(Display *dpy, Window win, uint64_t last_msc) return current_msc; } +static void swap_buffers(xcb_connection_t *c, Window win, + unsigned int *attachments, int nattachments) +{ + unsigned int seq[2]; + + seq[0] = xcb_dri2_swap_buffers_unchecked(c, win, + 0, 0, 0, 0, 0, 0).sequence; + + + seq[1] = xcb_dri2_get_buffers_unchecked(c, win, + nattachments, nattachments, + attachments).sequence; + + xcb_flush(c); + xcb_discard_reply(c, seq[0]); + xcb_discard_reply(c, seq[1]); +} + static void run(Display *dpy, int width, int height, unsigned int *attachments, int nattachments, const char *name) { + xcb_connection_t *c = XGetXCBConnection(dpy); Window win; XSetWindowAttributes attr; int count; @@ -132,15 +155,17 @@ static void run(Display *dpy, int width, int height, if (count != nattachments) return; + swap_buffers(c, win, attachments, nattachments); msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) - DRI2SwapBuffers(dpy, win, 0, 0, 0); + swap_buffers(c, win, attachments, nattachments); 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)); + swap_buffers(c, win, attachments, nattachments); msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) @@ -153,10 +178,11 @@ static void run(Display *dpy, int width, int height, DRI2SwapInterval(dpy, win, 0); + swap_buffers(c, win, attachments, nattachments); msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) - DRI2SwapBuffers(dpy, win, 0, 0, 0); + swap_buffers(c, win, attachments, nattachments); msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) vblank=0 swaps in %fs.\n", |