[Piglit] [PATCH 1/2] tests/egl : pass EGL config attributes from tests

Tapani Pälli tapani.palli at intel.com
Mon May 30 00:45:20 PDT 2011


Add config_attribs field to egl_test so that tests have to pass
their wanted attributes for the EGL config selection. Existing
tests were modified to pass the attributes.
---
 tests/egl/egl-create-surface.c          |   11 +++++++++++
 tests/egl/egl-nok-swap-region.c         |   11 +++++++++++
 tests/egl/egl-nok-texture-from-pixmap.c |   11 +++++++++++
 tests/egl/egl-util.c                    |   20 ++++++++------------
 tests/egl/egl-util.h                    |    1 +
 5 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/tests/egl/egl-create-surface.c b/tests/egl/egl-create-surface.c
index 83ac510..4481446 100644
--- a/tests/egl/egl-create-surface.c
+++ b/tests/egl/egl-create-surface.c
@@ -43,6 +43,16 @@ static const EGLint pixmap_attribs[] = {
 	EGL_NONE
 };
 
+static const EGLint attribs[] = {
+	EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
+	EGL_RED_SIZE, 1,
+	EGL_GREEN_SIZE, 1,
+	EGL_BLUE_SIZE, 1,
+	EGL_DEPTH_SIZE, 1,
+	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+	EGL_NONE
+};
+
 static enum piglit_result
 draw(struct egl_state *state)
 {
@@ -70,6 +80,7 @@ draw(struct egl_state *state)
 static const char *extensions[] = { NULL };
 
 static const struct egl_test test = {
+	.config_attribs = attribs,
 	.extensions = extensions,
 	.draw = draw
 };
diff --git a/tests/egl/egl-nok-swap-region.c b/tests/egl/egl-nok-swap-region.c
index 1da2d1b..993a407 100644
--- a/tests/egl/egl-nok-swap-region.c
+++ b/tests/egl/egl-nok-swap-region.c
@@ -35,6 +35,16 @@
 
 const char *extensions[] = { "EGL_NOK_swap_region", NULL };
 
+static const EGLint attribs[] = {
+	EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
+	EGL_RED_SIZE, 1,
+	EGL_GREEN_SIZE, 1,
+	EGL_BLUE_SIZE, 1,
+	EGL_DEPTH_SIZE, 1,
+	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+	EGL_NONE
+};
+
 static enum piglit_result
 draw(struct egl_state *state)
 {
@@ -73,6 +83,7 @@ draw(struct egl_state *state)
 }
 
 static const struct egl_test test = {
+	.config_attribs = attribs,
 	.extensions = extensions,
 	.draw = draw
 };
diff --git a/tests/egl/egl-nok-texture-from-pixmap.c b/tests/egl/egl-nok-texture-from-pixmap.c
index 0c6dc9a..337da1a 100644
--- a/tests/egl/egl-nok-texture-from-pixmap.c
+++ b/tests/egl/egl-nok-texture-from-pixmap.c
@@ -41,6 +41,16 @@ static const EGLint pixmap_attribs[] = {
 	EGL_NONE
 };
 
+static const EGLint attribs[] = {
+	EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
+	EGL_RED_SIZE, 1,
+	EGL_GREEN_SIZE, 1,
+	EGL_BLUE_SIZE, 1,
+	EGL_DEPTH_SIZE, 1,
+	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+	EGL_NONE
+};
+
 static enum piglit_result
 draw(struct egl_state *state)
 {
@@ -101,6 +111,7 @@ draw(struct egl_state *state)
 }
 
 static const struct egl_test test = {
+	.config_attribs = attribs,
 	.extensions = extensions,
 	.draw = draw
 };
diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c
index b7ae4b2..c009977 100644
--- a/tests/egl/egl-util.c
+++ b/tests/egl/egl-util.c
@@ -35,16 +35,6 @@ static int automatic;
 
 int depth;
 
-static const EGLint attribs[] = {
-	EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
-	EGL_RED_SIZE, 1,
-	EGL_GREEN_SIZE, 1,
-	EGL_BLUE_SIZE, 1,
-	EGL_DEPTH_SIZE, 1,
-	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
-	EGL_NONE
-};
-
 EGLSurface
 egl_util_create_pixmap(struct egl_state *state,
 		       int width, int height, const EGLint *attribs)
@@ -167,7 +157,13 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
 		piglit_report_result(PIGLIT_FAIL);
 	}
 
-	eglBindAPI(EGL_OPENGL_API);
+	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);
+		}
+	}
+
 
 	state.egl_dpy = eglGetDisplay(state.dpy);
 	if (state.egl_dpy == EGL_NO_DISPLAY) {
@@ -182,7 +178,7 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
 
 	check_extensions(&state, test);
 
-	if (!eglChooseConfig(state.egl_dpy, attribs, &state.cfg, 1, &count) ||
+	if (!eglChooseConfig(state.egl_dpy, test->config_attribs, &state.cfg, 1, &count) ||
 	    count == 0) {
 		fprintf(stderr, "eglChooseConfig() failed\n");
 		piglit_report_result(PIGLIT_FAIL);
diff --git a/tests/egl/egl-util.h b/tests/egl/egl-util.h
index f44a79e..e60de9b 100644
--- a/tests/egl/egl-util.h
+++ b/tests/egl/egl-util.h
@@ -22,6 +22,7 @@ struct egl_state {
 };
 
 struct egl_test {
+	const EGLint *config_attribs;
 	const char **extensions;
 	enum piglit_result (*draw)(struct egl_state *state);
 };
-- 
1.7.5.2

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



More information about the Piglit mailing list