[Piglit] [PATCH 5/7] egl-context-preemption: Add a subtest to reuse the same display.

Rafael Antognolli rafael.antognolli at intel.com
Thu Oct 4 15:35:33 UTC 2018


Add a subtest that reuses the same EGLDisplay used in the main thread.
This is just another case we can test and see if there's a difference in
the preemption behavior.
---
 tests/egl/egl-context-preemption.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/tests/egl/egl-context-preemption.c b/tests/egl/egl-context-preemption.c
index 85f5c8fd5..26ead9d58 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -51,6 +51,7 @@ struct test_data {
 	int nruns;
 	EGLDisplay dpy;
 	EGLContext ctx;
+	const struct test_profile *p;
 };
 
 struct test_profile {
@@ -58,6 +59,7 @@ struct test_profile {
 	size_t bufsize;
 	GLenum draw_mode;
 	GLuint (*shader_setup)(void);
+	bool same_display;
 };
 
 static bool small = false;
@@ -307,8 +309,9 @@ setup_thread_context(struct test_data *d)
 	bool ok = false;
 	EGLContext ctx2 = EGL_NO_CONTEXT;
 
-	EGLDisplay dpy;
-	if (init_other_display(&dpy) == PIGLIT_SKIP) {
+	EGLDisplay dpy = d->dpy;
+	if (!d->p->same_display &&
+	    init_other_display(&dpy) == PIGLIT_SKIP) {
 		piglit_loge("failed to get display\n");
 		result = PIGLIT_FAIL;
 		return result;
@@ -358,7 +361,9 @@ setup_thread_context(struct test_data *d)
 cleanup:
 	if (ctx2 != EGL_NO_CONTEXT)
 		eglDestroyContext(dpy, ctx2);
-	eglTerminate(dpy);
+
+	if (!d->p->same_display)
+		eglTerminate(dpy);
 
 	return result;
 }
@@ -445,7 +450,8 @@ thread2_create_high_priority_context(void *data)
 
 	if (d->ctx != EGL_NO_CONTEXT)
 		eglDestroyContext(d->dpy, d->ctx);
-	eglTerminate(d->dpy);
+	if (!d->p->same_display)
+		eglTerminate(d->dpy);
 
 	return result;
 }
@@ -486,6 +492,7 @@ test_preemption(void *data)
 	struct test_data d = {
 		.main_finished = false,
 		.nruns = 0,
+		.p = profile,
 	};
 	d.dpy = eglGetCurrentDisplay();
 
@@ -633,6 +640,14 @@ static struct test_profile trifan = {
 	.shader_setup = setup_shaders,
 };
 
+static struct test_profile triangles_same_display = {
+	.vertices = triangle_vertices,
+	.bufsize = sizeof(triangle_vertices),
+	.draw_mode = GL_TRIANGLES,
+	.shader_setup = setup_shaders,
+	.same_display = true,
+};
+
 static const struct piglit_subtest subtests[] = {
 	{
 		"triangles",
@@ -646,6 +661,12 @@ static const struct piglit_subtest subtests[] = {
 		test_preemption,
 		&trifan,
 	},
+	{
+		"triangles_same_display",
+		"same_display",
+		test_preemption,
+		&triangles_same_display,
+	},
 	{0},
 };
 
-- 
2.19.0



More information about the Piglit mailing list