[Piglit] [PATCH v3] egl_util : support for es1 and es2 tests

Tapani Pälli tapani.palli at intel.com
Mon Jan 20 03:55:16 PST 2014


egl_util was hardcoded to use PIGLIT_DISPATCH_GL, now code makes
decision based on config attribs set by the test.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---

(still needed to add EGL_CONTEXT_CLIENT_VERSION for ES context creation).

 tests/egl/egl-util.c | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c
index 012f547..e47863a 100644
--- a/tests/egl/egl-util.c
+++ b/tests/egl/egl-util.c
@@ -187,7 +187,13 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
 	struct egl_state state;
 	EGLint count;
 	enum piglit_result result;
-	int i;
+	int i, api_bit, dispatch_api;
+
+	EGLint ctxAttribsES[] = {
+		EGL_CONTEXT_CLIENT_VERSION, 0,
+		EGL_NONE
+	};
+	EGLint *ctxAttribs = NULL;
 
 	for (i = 1; i < argc; ++i) {
 		if (!strcmp(argv[i], "-auto"))
@@ -203,13 +209,22 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
 	}
 
 	for (count = 0; test->config_attribs[count] != EGL_NONE; count += 2) {
-		if (test->config_attribs[count] == EGL_RENDERABLE_TYPE &&
-		    test->config_attribs[count+1] == EGL_OPENGL_BIT) {
-			eglBindAPI(EGL_OPENGL_API);
+		if (test->config_attribs[count] == EGL_RENDERABLE_TYPE) {
+			api_bit = test->config_attribs[count+1];
+			if (api_bit == EGL_OPENGL_BIT)
+				eglBindAPI(EGL_OPENGL_API);
+			else {
+				eglBindAPI(EGL_OPENGL_ES_API);
+				ctxAttribs = ctxAttribsES;
+
+				if (api_bit == EGL_OPENGL_ES_BIT)
+					ctxAttribsES[1] = 1;
+				if (api_bit == EGL_OPENGL_ES2_BIT)
+					ctxAttribsES[1] = 2;
+			}
 		}
 	}
 
-
 	state.egl_dpy = eglGetDisplay(state.dpy);
 	if (state.egl_dpy == EGL_NO_DISPLAY) {
 		fprintf(stderr, "eglGetDisplay() failed\n");
@@ -230,7 +245,7 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
 	}
 
 	state.ctx = eglCreateContext(state.egl_dpy, state.cfg,
-				     EGL_NO_CONTEXT, NULL);
+				     EGL_NO_CONTEXT, ctxAttribs);
 	if (state.ctx == EGL_NO_CONTEXT) {
 		fprintf(stderr, "eglCreateContext() failed\n");
 		piglit_report_result(PIGLIT_FAIL);
@@ -253,7 +268,19 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
 		piglit_report_result(PIGLIT_FAIL);
 	}
 
-	piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
+	/* choose dispatch init */
+	switch (api_bit) {
+	case EGL_OPENGL_ES_BIT:
+		dispatch_api = PIGLIT_DISPATCH_ES1;
+		break;
+	case EGL_OPENGL_ES2_BIT:
+		dispatch_api = PIGLIT_DISPATCH_ES2;
+		break;
+	default:
+		dispatch_api = PIGLIT_DISPATCH_GL;
+	}
+
+	piglit_dispatch_default_init(dispatch_api);
 
 	result = event_loop(&state, test);
 
-- 
1.8.3.1



More information about the Piglit mailing list