xf86-video-intel: test/dri2-race.c test/dri2-test.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Feb 2 09:20:26 PST 2016


 test/dri2-race.c |  223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/dri2-test.c |    1 
 2 files changed, 224 insertions(+)

New commits:
commit 84e824873be4172c0ef51744fc9455bb9c12cc9a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 2 11:37:15 2016 +0000

    test/dri2-race: Capture race between window-manger and clients
    
    If the window manager closes the Window before the client disconnects,
    we can end up with a blocked client as dri2 does not call AttendClient()
    in its DRI2DrawableGone.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/dri2-race.c b/test/dri2-race.c
index c589f2b..39e2bbd 100644
--- a/test/dri2-race.c
+++ b/test/dri2-race.c
@@ -221,6 +221,221 @@ static void race_window(Display *dpy, int width, int height,
 	XSync(dpy, 1);
 }
 
+static void race_manager(Display *dpy, int width, int height,
+			 unsigned int *attachments, int nattachments,
+			 const char *name)
+{
+	Display *mgr = XOpenDisplay(NULL);
+	Window win;
+	XSetWindowAttributes attr;
+	int count, loop;
+	DRI2Buffer *buffers;
+
+	printf("%s(%s)\n", __func__, name);
+
+	/* Be nasty and install a fullscreen window on top so that we
+	 * can guarantee we do not get clipped by children.
+	 */
+	attr.override_redirect = 1;
+	loop = 100;
+	do {
+		win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+				    0, 0, width, height, 0,
+				    DefaultDepth(dpy, DefaultScreen(dpy)),
+				    InputOutput,
+				    DefaultVisual(dpy, DefaultScreen(dpy)),
+				    CWOverrideRedirect, &attr);
+		XMapWindow(dpy, win);
+
+		DRI2CreateDrawable(dpy, win);
+
+		buffers = DRI2GetBuffers(dpy, win, &width, &height,
+					 attachments, nattachments, &count);
+		if (count != nattachments)
+			return;
+
+		free(buffers);
+		for (count = 0; count < loop; count++)
+			DRI2SwapBuffers(dpy, win, 0, 0, 0);
+		XFlush(dpy);
+		XDestroyWindow(mgr, win);
+		XFlush(mgr);
+		printf("."); fflush(stdout);
+	} while (--loop);
+	printf("*\n");
+
+	loop = 100;
+	do {
+		win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+				    0, 0, width, height, 0,
+				    DefaultDepth(dpy, DefaultScreen(dpy)),
+				    InputOutput,
+				    DefaultVisual(dpy, DefaultScreen(dpy)),
+				    CWOverrideRedirect, &attr);
+		XMapWindow(dpy, win);
+
+		DRI2CreateDrawable(dpy, win);
+
+		buffers = DRI2GetBuffers(dpy, win, &width, &height,
+					 attachments, nattachments, &count);
+		if (count != nattachments)
+			return;
+
+		free(buffers);
+		for (count = 0; count < loop; count++)
+			DRI2SwapBuffers(dpy, win, 0, 1, 0);
+		XFlush(dpy);
+		XDestroyWindow(mgr, win);
+		XFlush(mgr);
+		printf("."); fflush(stdout);
+	} while (--loop);
+	printf("*\n");
+
+	loop = 100;
+	do {
+		win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+				    0, 0, width, height, 0,
+				    DefaultDepth(dpy, DefaultScreen(dpy)),
+				    InputOutput,
+				    DefaultVisual(dpy, DefaultScreen(dpy)),
+				    CWOverrideRedirect, &attr);
+		XMapWindow(dpy, win);
+
+		DRI2CreateDrawable(dpy, win);
+
+		buffers = DRI2GetBuffers(dpy, win, &width, &height,
+					 attachments, nattachments, &count);
+		if (count != nattachments)
+			return;
+
+		free(buffers);
+		for (count = 0; count < loop; count++)
+			DRI2SwapBuffers(dpy, win, 0, 16, count & 15);
+		XFlush(dpy);
+		XDestroyWindow(mgr, win);
+		XFlush(mgr);
+		printf("."); fflush(stdout);
+	} while (--loop);
+	printf("*\n");
+
+	loop = 100;
+	do {
+		win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+				    0, 0, width, height, 0,
+				    DefaultDepth(dpy, DefaultScreen(dpy)),
+				    InputOutput,
+				    DefaultVisual(dpy, DefaultScreen(dpy)),
+				    CWOverrideRedirect, &attr);
+		XMapWindow(dpy, win);
+
+		DRI2CreateDrawable(dpy, win);
+
+		buffers = DRI2GetBuffers(dpy, win, &width, &height,
+					 attachments, nattachments, &count);
+		if (count != nattachments)
+			return;
+
+		free(buffers);
+		for (count = 0; count < loop; count++)
+			swap_buffers(dpy, win, 0, attachments, nattachments);
+		XFlush(dpy);
+		XDestroyWindow(mgr, win);
+		XFlush(mgr);
+		printf("."); fflush(stdout);
+	} while (--loop);
+	printf("*\n");
+
+	loop = 100;
+	do {
+		win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+				    0, 0, width, height, 0,
+				    DefaultDepth(dpy, DefaultScreen(dpy)),
+				    InputOutput,
+				    DefaultVisual(dpy, DefaultScreen(dpy)),
+				    CWOverrideRedirect, &attr);
+		XMapWindow(dpy, win);
+
+		DRI2CreateDrawable(dpy, win);
+
+		buffers = DRI2GetBuffers(dpy, win, &width, &height,
+					 attachments, nattachments, &count);
+		if (count != nattachments)
+			return;
+
+		free(buffers);
+		for (count = 0; count < loop; count++)
+			swap_buffers(dpy, win, 1, attachments, nattachments);
+		XFlush(dpy);
+		XDestroyWindow(mgr, win);
+		XFlush(mgr);
+		printf("."); fflush(stdout);
+	} while (--loop);
+	printf("*\n");
+
+	loop = 100;
+	do {
+		win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+				    0, 0, width, height, 0,
+				    DefaultDepth(dpy, DefaultScreen(dpy)),
+				    InputOutput,
+				    DefaultVisual(dpy, DefaultScreen(dpy)),
+				    CWOverrideRedirect, &attr);
+		XMapWindow(dpy, win);
+
+		DRI2CreateDrawable(dpy, win);
+
+		buffers = DRI2GetBuffers(dpy, win, &width, &height,
+					 attachments, nattachments, &count);
+		if (count != nattachments)
+			return;
+
+		free(buffers);
+		for (count = 0; count < loop; count++)
+			swap_buffers(dpy, win, 16, attachments, nattachments);
+		XFlush(dpy);
+		XDestroyWindow(mgr, win);
+		XFlush(mgr);
+		printf("."); fflush(stdout);
+	} while (--loop);
+	printf("*\n");
+
+	loop = 100;
+	do {
+		uint64_t ignore, msc;
+		xcb_connection_t *c = XGetXCBConnection(dpy);
+
+		win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+				    0, 0, width, height, 0,
+				    DefaultDepth(dpy, DefaultScreen(dpy)),
+				    InputOutput,
+				    DefaultVisual(dpy, DefaultScreen(dpy)),
+				    CWOverrideRedirect, &attr);
+		XMapWindow(dpy, win);
+
+		DRI2CreateDrawable(dpy, win);
+		DRI2GetMSC(dpy, win, &ignore, &msc, &ignore);
+		for (count = 0; count < loop; count++)
+			xcb_discard_reply(c,
+					  xcb_dri2_wait_msc(c, win,
+							    upper_32_bits(msc + count + 1),
+							    lower_32_bits(msc + count + 1),
+							    0, 1, 0, 0).sequence);
+		XFlush(dpy);
+		XDestroyWindow(mgr, win);
+		XFlush(mgr);
+		printf("."); fflush(stdout);
+	} while (--loop);
+	printf("*\n");
+
+	XSync(dpy, 1);
+	XSync(mgr, 1);
+	sleep(2);
+	XSync(dpy, 1);
+	XSync(mgr, 1);
+
+	XCloseDisplay(mgr);
+}
+
 static void race_client(int width, int height,
 			unsigned int *attachments, int nattachments,
 			const char *name)
@@ -359,6 +574,10 @@ int main(void)
 	height = HeightOfScreen(DefaultScreenOfDisplay(dpy));
 	race_window(dpy, width, height, attachments, 1, "fullscreen");
 	race_window(dpy, width, height, attachments, 2, "fullscreen (with front)");
+
+	race_manager(dpy, width, height, attachments, 1, "fullscreen");
+	race_manager(dpy, width, height, attachments, 2, "fullscreen (with front)");
+
 	race_client(width, height, attachments, 1, "fullscreen");
 	race_client(width, height, attachments, 2, "fullscreen (with front)");
 
@@ -366,6 +585,10 @@ int main(void)
 	height /= 2;
 	race_window(dpy, width, height, attachments, 1, "windowed");
 	race_window(dpy, width, height, attachments, 2, "windowed (with front)");
+
+	race_manager(dpy, width, height, attachments, 1, "windowed");
+	race_manager(dpy, width, height, attachments, 2, "windowed (with front)");
+
 	race_client(width, height, attachments, 1, "windowed");
 	race_client(width, height, attachments, 2, "windowed (with front)");
 
diff --git a/test/dri2-test.c b/test/dri2-test.c
index 88c0e4c..d575305 100644
--- a/test/dri2-test.c
+++ b/test/dri2-test.c
@@ -186,6 +186,7 @@ static void run(Display *dpy, int width, int height,
 	       name, width, height, elapsed(&start, &end));
 
 	DRI2SwapInterval(dpy, win, 0);
+	wait_next_vblank(dpy, win);
 
 	swap_buffers(c, win, attachments, nattachments);
 	start_msc = check_msc(dpy, win, end_msc);


More information about the xorg-commit mailing list