[Piglit] [PATCH] arb_viewport_array: rework tests to work with GL_OES_viewport_array

Ilia Mirkin imirkin at alum.mit.edu
Fri Sep 16 19:38:49 UTC 2016


This makes some fairly simple changes to the existing tests to also work
with GL_OES_viewport_array, which presents largely identical
functionality. All of the tests continue to pass with desktop GL, and
also work with my soon-to-be-posted GL ES implementation for mesa.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 tests/all.py                                       | 16 +++++
 tests/spec/arb_viewport_array/bounds.c             | 23 ++++++
 tests/spec/arb_viewport_array/clear.c              |  5 ++
 .../spec/arb_viewport_array/depth_range_indices.c  | 27 ++++++-
 tests/spec/arb_viewport_array/minmax.c             |  9 +++
 tests/spec/arb_viewport_array/queries.c            | 15 +++-
 tests/spec/arb_viewport_array/render_depthrange.c  | 52 +++++++++++---
 tests/spec/arb_viewport_array/render_scissor.c     | 28 ++++++--
 tests/spec/arb_viewport_array/render_viewport.c    | 48 +++++++++----
 tests/spec/arb_viewport_array/render_viewport_2.c  | 37 +++++++---
 tests/spec/arb_viewport_array/scissor_check.c      | 82 ++++++++--------------
 tests/spec/arb_viewport_array/scissor_indices.c    |  5 ++
 tests/spec/arb_viewport_array/viewport_indices.c   | 22 ++++++
 13 files changed, 274 insertions(+), 95 deletions(-)

diff --git a/tests/all.py b/tests/all.py
index fc77335..bc400e6 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2813,6 +2813,22 @@ with profile.group_manager(
 
 with profile.group_manager(
         PiglitGLTest,
+        grouptools.join('spec', 'oes_viewport_array')) as g:
+    g(['arb_viewport_array-viewport-indices_gles3'], 'viewport-indices')
+    g(['arb_viewport_array-depthrange-indices_gles3'], 'depthrange-indices')
+    g(['arb_viewport_array-scissor-check_gles3'], 'scissor-check')
+    g(['arb_viewport_array-scissor-indices_gles3'], 'scissor-indices')
+    g(['arb_viewport_array-bounds_gles3'], 'bounds')
+    g(['arb_viewport_array-queries_gles3'], 'queries')
+    g(['arb_viewport_array-minmax_gles3'], 'minmax')
+    g(['arb_viewport_array-render-viewport_gles3'], 'render-viewport')
+    g(['arb_viewport_array-render-viewport-2_gles3'], 'render-viewport-2')
+    g(['arb_viewport_array-render-depthrange_gles3'], 'render-depthrange')
+    g(['arb_viewport_array-render-scissor_gles3'], 'render-scissor')
+    g(['arb_viewport_array-clear_gles3'], 'clear')
+
+with profile.group_manager(
+        PiglitGLTest,
         grouptools.join('spec', 'nv_vertex_program2_option')) as g:
     g(['vp-address-03'], run_concurrent=False)
     g(['vp-address-05'], run_concurrent=False)
diff --git a/tests/spec/arb_viewport_array/bounds.c b/tests/spec/arb_viewport_array/bounds.c
index b34d962..9a8e869 100644
--- a/tests/spec/arb_viewport_array/bounds.c
+++ b/tests/spec/arb_viewport_array/bounds.c
@@ -34,6 +34,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -143,12 +144,20 @@ static bool
 depth_range_bounds(GLint maxVP)
 {
 	bool pass = true;
+#ifdef PIGLIT_USE_OPENGL
 	GLdouble dr[2], drGet[2];
+#else
+	GLfloat dr[2], drGet[2];
+#endif
 	int i;
 
 	/* intial values for near, far are 0.0, 1.0 repsectively */
 	for (i = 0; i < maxVP; i++) {
+#ifdef PIGLIT_USE_OPENGL
 		glGetDoublei_v(GL_DEPTH_RANGE, i, dr);
+#else
+		glGetFloati_v(GL_DEPTH_RANGE, i, dr);
+#endif
 		if (dr[0] != 0.0 || dr[1] != 1.0) {
 			printf("depth_range default value wrong for idx %d\n",
 			       i);
@@ -160,14 +169,24 @@ depth_range_bounds(GLint maxVP)
 	/* test clamping of depth_range values */
 	dr[0] = -0.001;
 	dr[1] = 2.0;
+#ifdef PIGLIT_USE_OPENGL
 	glDepthRangeArrayv(0, 1, dr);
 	glGetDoublei_v(GL_DEPTH_RANGE, 0, drGet);
+#else
+	glDepthRangeArrayfvOES(0, 1, dr);
+	glGetFloati_vOES(GL_DEPTH_RANGE, 0, drGet);
+#endif
 	if (drGet[0] != 0.0 || drGet[1] != 1.0) {
 		printf("depth_range clamping failed glDepthRangeArrayv\n");
 		pass = false;
 	}
+#ifdef PIGLIT_USE_OPENGL
 	glDepthRangeIndexed(1, dr[0], dr[1]);
 	glGetDoublei_v(GL_DEPTH_RANGE, 1, drGet);
+#else
+	glDepthRangeIndexedfOES(1, dr[0], dr[1]);
+	glGetFloati_vOES(GL_DEPTH_RANGE, 1, drGet);
+#endif
 	if (drGet[0] != 0.0 || drGet[1] != 1.0) {
 		printf("depth_range clamping failed glDepthRangeIndexed\n");
 		pass = false;
@@ -251,7 +270,11 @@ piglit_init(int argc, char **argv)
 	bool pass = true;
 	GLint maxVP;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP);
 	if (!piglit_check_gl_error(GL_NO_ERROR)) {
diff --git a/tests/spec/arb_viewport_array/clear.c b/tests/spec/arb_viewport_array/clear.c
index 96facf5..aee9bca 100644
--- a/tests/spec/arb_viewport_array/clear.c
+++ b/tests/spec/arb_viewport_array/clear.c
@@ -32,6 +32,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 10;
 	config.supports_gl_core_version = 31;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -42,7 +43,11 @@ static GLint num_viewports;
 void
 piglit_init(int argc, char **argv)
 {
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 	glGetIntegerv(GL_MAX_VIEWPORTS, &num_viewports);
 }
 
diff --git a/tests/spec/arb_viewport_array/depth_range_indices.c b/tests/spec/arb_viewport_array/depth_range_indices.c
index 84b524f..806b24c 100644
--- a/tests/spec/arb_viewport_array/depth_range_indices.c
+++ b/tests/spec/arb_viewport_array/depth_range_indices.c
@@ -38,6 +38,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -51,29 +52,45 @@ PIGLIT_GL_TEST_CONFIG_END
 static bool
 check_dr_index(GLuint first, GLsizei count, GLenum expected_error)
 {
+#ifdef PIGLIT_USE_OPENGL
 	static const GLclampd dv[] = {0.213, 1.0};
 	GLclampd *mv, dvGet[2];
+#else
+	static const GLfloat dv[] = {0.213, 1.0};
+	GLfloat *mv, dvGet[2];
+#endif
 	unsigned int i;
 	bool pass = true;
 	const unsigned int numIterate = (expected_error == GL_NO_ERROR) ? count : 1;
 
-	mv = malloc(sizeof(GLclampd) * 2 * count);
+	mv = malloc(sizeof(*dv) * 2 * count);
 	if (mv == NULL)
 		return false;
 	for (i = 0; i < count; i++) {
 		mv[i * 2] = dv[0];
 		mv[i * 2 + 1] = dv[1];
 	}
+#ifdef PIGLIT_USE_OPENGL
 	glDepthRangeArrayv(first, count, mv);
+#else
+	glDepthRangeArrayfvOES(first, count, mv);
+#endif
 	free(mv);
 	pass = piglit_check_gl_error(expected_error) && pass;
 
 	/* only iterate multiple indices for no error case */
 	for (i = count; i > count - numIterate; i--) {
+#ifdef PIGLIT_USE_OPENGL
 		glDepthRangeIndexed(first + i - 1, dv[0], dv[1]);
 		pass = piglit_check_gl_error(expected_error) && pass;
 		glGetDoublei_v(GL_DEPTH_RANGE, first + i - 1, dvGet);
 		pass = piglit_check_gl_error(expected_error) && pass;
+#else
+		glDepthRangeIndexedfOES(first + i - 1, dv[0], dv[1]);
+		pass = piglit_check_gl_error(expected_error) && pass;
+		glGetFloati_vOES(GL_DEPTH_RANGE, first + i - 1, dvGet);
+		pass = piglit_check_gl_error(expected_error) && pass;
+#endif
 	}
 
 	return pass;
@@ -117,7 +134,11 @@ test_dr_indices(GLint maxVP)
 	 * OpenGL Spec Core 4.3 Spec, section 13.6.1 ref:
 	 *    "An INVALID_VALUE error is generated if count is negative."
 	 */
+#ifdef PIGLIT_USE_OPENGL
 	glDepthRangeArrayv(0, -1, NULL);
+#else
+	glDepthRangeArrayfvOES(0, -1, NULL);
+#endif
 	if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
 		printf("Wrong error for invalid DepthRange count\n");
 		pass = false;
@@ -139,7 +160,11 @@ piglit_init(int argc, char **argv)
 	bool pass = true;
 	GLint maxVP;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP);
 	if (!piglit_check_gl_error(GL_NO_ERROR)) {
diff --git a/tests/spec/arb_viewport_array/minmax.c b/tests/spec/arb_viewport_array/minmax.c
index ff49048..8bb0c9d 100644
--- a/tests/spec/arb_viewport_array/minmax.c
+++ b/tests/spec/arb_viewport_array/minmax.c
@@ -39,6 +39,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_core_version = 32;
 	config.supports_gl_compat_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
 
@@ -56,7 +57,11 @@ piglit_init(int argc, char **argv)
 {
 	GLint layer, index;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 	piglit_print_minmax_header();
 
 	piglit_test_min_viewport_dimensions(); /* GL_MAX_VIEWPORT_DIMS */
@@ -69,12 +74,16 @@ piglit_init(int argc, char **argv)
 	 *    least [-16384, 16383].
 	 *    On GL4-capable hardware the VIEWPORT_BOUNDS_RANGE should be at
 	 *    least [-32768, 32767]."
+	 *
+	 * OES_viewport_array requires the larger range.
 	 */
 	/* Since no known way to determine GL3 versus GL4 capable hardware use
 	   GL version instead */
+#ifdef PIGLIT_USE_OPENGL
 	if (piglit_get_gl_version() < 40)
 		piglit_test_range_float(GL_VIEWPORT_BOUNDS_RANGE, -16384, 16383);
 	else
+#endif
 		piglit_test_range_float(GL_VIEWPORT_BOUNDS_RANGE, -32768, 32767);
 
 	/**
diff --git a/tests/spec/arb_viewport_array/queries.c b/tests/spec/arb_viewport_array/queries.c
index 74b15d1..2b10b3a 100644
--- a/tests/spec/arb_viewport_array/queries.c
+++ b/tests/spec/arb_viewport_array/queries.c
@@ -37,6 +37,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -64,7 +65,11 @@ piglit_init(int argc, char **argv)
 	const GLenum indexedTokens[] = {GL_VIEWPORT, GL_DEPTH_RANGE,
 					GL_SCISSOR_BOX};
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP);
 	/**
@@ -80,8 +85,10 @@ piglit_init(int argc, char **argv)
 	for (i = 0; i < ARRAY_SIZE(tokens); i++) {
 		glGetFloati_v(tokens[i], 1, valf);
 		pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;
+#ifdef PIGLIT_USE_OPENGL
 		glGetDoublei_v(tokens[i], 1, vald);
 		pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;
+#endif
 	}
 
 	/**
@@ -125,12 +132,16 @@ piglit_init(int argc, char **argv)
 	 * return the same data.
 	 */
 	glViewport(1, 2, 30, 40);
+#ifdef PIGLIT_USE_OPENGL
 	glDepthRange(0.25, 0.75);
+#else
+	glDepthRangef(0.25, 0.75);
+#endif
 	glScissor(3, 4, 50, 60);
 	for (i =0; i < ARRAY_SIZE(indexedTokens); i++) {
 		glGetFloati_v(indexedTokens[i], 1, valf);
+#ifdef PIGLIT_USE_OPENGL
 		glGetDoublei_v(indexedTokens[i], 1, vald);
-		glGetIntegeri_v(indexedTokens[i], 1, vali);
 		if (valf[0] != vald[0] || valf[1] != vald[1] ||
 		    valf[2] != vald[2] || valf[3] != vald[3]) {
 			pass = false;
@@ -141,6 +152,8 @@ piglit_init(int argc, char **argv)
 			printf("vald[0-3] = %f %f %f %f\n", vald[0], vald[1],
 			       vald[2], vald[3]);
 		}
+#endif
+		glGetIntegeri_v(indexedTokens[i], 1, vali);
 		if ((int) (valf[0] + 0.5) != vali[0] ||
 		    (int) (valf[1] + 0.5) != vali[1] ||
 		    (int) (valf[2] + 0.5) != vali[2] ||
diff --git a/tests/spec/arb_viewport_array/render_depthrange.c b/tests/spec/arb_viewport_array/render_depthrange.c
index b695f4f..c7e016f 100644
--- a/tests/spec/arb_viewport_array/render_depthrange.c
+++ b/tests/spec/arb_viewport_array/render_depthrange.c
@@ -45,13 +45,20 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
 
+#ifdef PIGLIT_USE_OPENGL
+#define GLSL_VERSION "150"
+#else
+#define GLSL_VERSION "310 es"
+#endif
+
 const char *vsSource = {
-	"#version 150\n"
+	"#version " GLSL_VERSION "\n"
 	"in vec4 piglit_vertex;\n"
 	"void main() {\n"
 	"	gl_Position = piglit_vertex;\n"
@@ -59,8 +66,11 @@ const char *vsSource = {
 };
 
 const char *gsSource = {
-	"#version 150\n"
+	"#version " GLSL_VERSION "\n"
 	"#extension GL_ARB_viewport_array : enable\n"
+	"#extension GL_OES_viewport_array : enable\n"
+	"#extension GL_EXT_geometry_shader : enable\n"
+	"#extension GL_OES_geometry_shader : enable\n"
 	"layout(triangles) in;\n"
 	"layout(triangle_strip, max_vertices = 3) out;\n"
 	"uniform int idx;\n"
@@ -79,13 +89,16 @@ const char *gsSource = {
 };
 
 const char *fsSource = {
-	"#version 150\n"
-	"#extension GL_ARB_viewport_array : enable\n"
+	"#version " GLSL_VERSION "\n"
+	"#ifdef GL_ES\n"
+	"precision highp float;\n"
+	"#endif\n"
 	"uniform vec3 color;\n"
 	"flat in int ViewportIndex;\n"
+	"out vec4 c;\n"
 	"void main() {\n"
-	"	float idx = ViewportIndex / 10.0;\n"
-	"	gl_FragColor = vec4(gl_FragCoord.z, gl_DepthRange.far, idx, 1.0);\n"
+	"	float idx = float(ViewportIndex) / 10.0;\n"
+	"	c = vec4(gl_FragCoord.z, gl_DepthRange.far, idx, 1.0);\n"
 	"}\n"
 };
 
@@ -116,8 +129,13 @@ draw_multi_viewport(void)
 	GLfloat h = (GLfloat) piglit_height / (GLfloat) DIVY;
 	GLfloat zVal = 0.25f;
 	GLfloat drFar = 0.6f;
-	GLfloat colors[DIVX * DIVY][3];
-	const GLdouble depthRange[][2] = {{0.5, 1.0},
+	GLfloat colors[DIVX * DIVY][4];
+#ifdef PIGLIT_USE_OPENGL
+	const GLdouble depthRange[][2] =
+#else
+	const GLfloat depthRange[][2] =
+#endif
+				   {{0.5, 1.0},
 				    {0.0, 0.8},
 				    {1.0, 0.75},
 				    {0.3, 0.8},
@@ -132,7 +150,11 @@ draw_multi_viewport(void)
 	glClearDepthf(1.0);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 	glEnable(GL_DEPTH_TEST);
+#ifdef PIGLIT_USE_OPENGL
 	glDepthRangeIndexed(0, 0.4, drFar);
+#else
+	glDepthRangeIndexedfOES(0, 0.4, drFar);
+#endif
 	glDepthFunc(GL_ALWAYS);
 
 	/* initialize expected colors
@@ -145,6 +167,7 @@ draw_multi_viewport(void)
 		colors[i][0] = (((farZ - nearZ) * zVal)  + nearZ + farZ) / 2.0f;
 		colors[i][1] = drFar;
 		colors[i][2] = (GLfloat) (i + 1) / 10.0f;
+		colors[i][3] = 1.0;
 	}
 
 	/* draw with varying viewports and depth ranges */
@@ -158,12 +181,17 @@ draw_multi_viewport(void)
 			glUniform3fv(colorLoc, 1, &colors[idx-1][0]);
 			glUniform1i(vpIndexLoc, idx);
 			glViewportIndexedf(idx, i * w, j * h, w, h);
+#ifdef PIGLIT_USE_OPENGL
 			glDepthRangeIndexed(idx, depthRange[idx-1][0],
 					    depthRange[idx-1][1]);
+#else
+			glDepthRangeIndexedfOES(idx, depthRange[idx-1][0],
+						depthRange[idx-1][1]);
+#endif
 			piglit_draw_rect_z(zVal, -1.0, -1.0, 2.0, 2.0);
 			pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
-			p = piglit_probe_pixel_rgb(i * w + w/2, j * h + h/2,
-						   &colors[idx-1][0]);
+			p = piglit_probe_pixel_rgba(i * w + w/2, j * h + h/2,
+						    &colors[idx-1][0]);
 			piglit_present_results();
 			if (!p) {
 				printf("Wrong color for viewport i,j %d %d\n",
@@ -190,7 +218,11 @@ piglit_init(int argc, char **argv)
 {
 	GLuint program;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	program = piglit_build_simple_program_multiple_shaders(
 					GL_VERTEX_SHADER, vsSource,
diff --git a/tests/spec/arb_viewport_array/render_scissor.c b/tests/spec/arb_viewport_array/render_scissor.c
index 2555068..95d3450 100644
--- a/tests/spec/arb_viewport_array/render_scissor.c
+++ b/tests/spec/arb_viewport_array/render_scissor.c
@@ -45,6 +45,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -196,6 +197,12 @@ piglit_display(void)
 	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
 }
 
+#ifdef PIGLIT_USE_OPENGL
+#define GLSL_VERSION "150"
+#else
+#define GLSL_VERSION "310 es"
+#endif
+
 void
 piglit_init(int argc, char **argv)
 {
@@ -204,18 +211,25 @@ piglit_init(int argc, char **argv)
 	char *gsSource;
 	char *fsSource;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	(void)!asprintf(&vsSource,
-		 "#version 150\n"
+		 "#version " GLSL_VERSION "\n"
 		 "in vec4 piglit_vertex;\n"
 		 "void main() {\n"
 		 "	gl_Position = piglit_vertex;\n"
 		 "}\n");
 
 	(void)!asprintf(&gsSource,
-		 "#version 150\n"
+		 "#version " GLSL_VERSION "\n"
 		 "#extension GL_ARB_viewport_array : enable\n"
+		 "#extension GL_OES_viewport_array : enable\n"
+		 "#extension GL_EXT_geometry_shader : enable\n"
+		 "#extension GL_OES_geometry_shader : enable\n"
 		 "layout(triangles) in;\n"
 		 "layout(triangle_strip, max_vertices = 18) out;\n"
 		 "out vec3 color;\n"
@@ -224,7 +238,7 @@ piglit_init(int argc, char **argv)
 		 "{\n"
 		 "	for (int j = 0; j < %d; j++) {\n"
 		 "		gl_ViewportIndex = j;\n"
-		 "		color = vec3(1.0 / (j+1), 1.0 / (j+1), 1.0 / (j+1));\n"
+		 "		color = vec3(1.0 / float(j + 1));\n"
 		 "		for(int i = 0; i < gl_in.length(); i++) {\n"
 		 "			gl_Position = gl_in[i].gl_Position;\n"
 		 "			EmitVertex();\n"
@@ -234,10 +248,14 @@ piglit_init(int argc, char **argv)
 		 "}\n", divX * divY);
 
 	(void)!asprintf(&fsSource,
-		 "#version 150\n"
+		 "#version " GLSL_VERSION "\n"
+                 "#ifdef GL_ES\n"
+		 "precision highp float;\n"
+		 "#endif\n"
 		 "in vec3 color;\n"
+		 "out vec4 c;\n"
 		 "void main() {\n"
-		 "	gl_FragColor = vec4(color.xyz, 1.0);\n"
+		 "	c = vec4(color.xyz, 1.0);\n"
 		 "}\n");
 
 
diff --git a/tests/spec/arb_viewport_array/render_viewport.c b/tests/spec/arb_viewport_array/render_viewport.c
index 192133a..50630de 100644
--- a/tests/spec/arb_viewport_array/render_viewport.c
+++ b/tests/spec/arb_viewport_array/render_viewport.c
@@ -42,13 +42,20 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
 
+#ifdef PIGLIT_USE_OPENGL
+#define GLSL_VERSION "150"
+#else
+#define GLSL_VERSION "310 es"
+#endif
+
 const char *vsSource = {
-	"#version 150\n"
+	"#version " GLSL_VERSION "\n"
 	"in vec4 piglit_vertex;\n"
 	"void main() {\n"
 	"	gl_Position = piglit_vertex;\n"
@@ -56,8 +63,11 @@ const char *vsSource = {
 };
 
 const char *gsSource = {
-	"#version 150\n"
+	"#version " GLSL_VERSION "\n"
 	"#extension GL_ARB_viewport_array : enable\n"
+	"#extension GL_OES_viewport_array : enable\n"
+	"#extension GL_EXT_geometry_shader : enable\n"
+	"#extension GL_OES_geometry_shader : enable\n"
 	"layout(triangles) in;\n"
 	"layout(triangle_strip, max_vertices = 3) out;\n"
 	"uniform int idx;\n"
@@ -74,10 +84,14 @@ const char *gsSource = {
 };
 
 const char *fsSource = {
-	"#version 150\n"
+	"#version " GLSL_VERSION "\n"
+	"#ifdef GL_ES\n"
+	"precision highp float;\n"
+	"#endif\n"
 	"uniform vec3 color;\n"
+	"out vec4 c;\n"
 	"void main() {\n"
-	"	gl_FragColor = vec4(color.xyz, 1.0);\n"
+	"	c = vec4(color.xyz, 1.0);\n"
 	"}\n"
 };
 
@@ -98,15 +112,15 @@ draw_multi_viewport(const bool changeVPLoc)
 	const int divX=2, divY=4;
 	GLfloat w = (GLfloat) piglit_width / (GLfloat) divX;
 	GLfloat h = (GLfloat) piglit_height / (GLfloat) divY;
-	const GLfloat colors[][3] = {{0.0, 0.0, 1.0},
-				  {0.0, 1.0, 0.0},
-				  {1.0, 0.0, 0.0},
-				  {1.0, 1.0, 0.0},
-				  {0.0, 1.0, 1.0},
-				  {1.0, 0.0, 1.0},
-				  {1.0, 1.0, 1.0},
-				  {0.0, 0.0, 0.5},
-				  {0.0, 0.0, 0.0}};
+	const GLfloat colors[][4] = {{0.0, 0.0, 1.0, 1.0},
+				     {0.0, 1.0, 0.0, 1.0},
+				     {1.0, 0.0, 0.0, 1.0},
+				     {1.0, 1.0, 0.0, 1.0},
+				     {0.0, 1.0, 1.0, 1.0},
+				     {1.0, 0.0, 1.0, 1.0},
+				     {1.0, 1.0, 1.0, 1.0},
+				     {0.0, 0.0, 0.5, 1.0},
+				     {0.0, 0.0, 0.0, 0.0}};
 
 	assert(ARRAY_SIZE(colors) == divX*divY + 1);
 
@@ -128,8 +142,8 @@ draw_multi_viewport(const bool changeVPLoc)
 			glViewportIndexedf(j + i*divY, i * w, j * h, w, h);
 			piglit_draw_rect(-1, -1, 2, 2);
 			pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
-			p = piglit_probe_pixel_rgb(i * w + w/2, j * h + h/2,
-						   expected);
+			p = piglit_probe_pixel_rgba(i * w + w/2, j * h + h/2,
+						    expected);
 			piglit_present_results();
 			if (!p) {
 				printf("Wrong color for viewport i,j %d %d changeVP=%d\n",
@@ -157,7 +171,11 @@ piglit_init(int argc, char **argv)
 {
 	GLuint program;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	program = piglit_build_simple_program_multiple_shaders(
 					GL_VERTEX_SHADER, vsSource,
diff --git a/tests/spec/arb_viewport_array/render_viewport_2.c b/tests/spec/arb_viewport_array/render_viewport_2.c
index 7e8360f..28c54fa 100644
--- a/tests/spec/arb_viewport_array/render_viewport_2.c
+++ b/tests/spec/arb_viewport_array/render_viewport_2.c
@@ -35,21 +35,31 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
 
+#ifdef PIGLIT_USE_OPENGL
+#define GLSL_VERSION "150"
+#else
+#define GLSL_VERSION "310 es"
+#endif
+
 const char *vsSource = {
-	"#version 150\n"
+	"#version " GLSL_VERSION "\n"
 	"void main() {\n"
 	"}\n"
 };
 
 const char *gsSource = {
-	"#version 150\n"
+	"#version " GLSL_VERSION "\n"
 	"#extension GL_ARB_gpu_shader5 : enable\n"
 	"#extension GL_ARB_viewport_array : enable\n"
+	"#extension GL_OES_viewport_array : enable\n"
+	"#extension GL_EXT_geometry_shader : enable\n"
+	"#extension GL_OES_geometry_shader : enable\n"
 	"layout(points, invocations = 16) in;\n"
 	"layout(triangle_strip, max_vertices = 4) out;\n"
 	" flat out int gs_fs_color;\n"
@@ -76,11 +86,15 @@ const char *gsSource = {
 };
 
 const char *fsSource = {
-	"#version 150\n"
+	"#version " GLSL_VERSION "\n"
+	"#ifdef GL_ES\n"
+	"precision highp float;\n"
+	"#endif\n"
 	"flat in int gs_fs_color;\n"
 	"uniform vec3 color;\n"
+	"out vec4 c;\n"
 	"void main() {\n"
-	"	gl_FragColor = vec4(1.0 / float(gs_fs_color + 1), 0.0, 0.0, 1.0);\n"
+	"	c = vec4(1.0 / float(gs_fs_color + 1), 0.0, 0.0, 1.0);\n"
 	"}\n"
 };
 
@@ -99,7 +113,6 @@ draw_multi_viewport(void)
 	idx = 0;
 	for (i = 0; i < divX; i++) {
 		for (j = 0; j < divY; j++) {
-			
 			data[idx * 4 + 0] = (GLfloat)(i * w);
 			data[idx * 4 + 1] = (GLfloat)(j * h);
 			data[idx * 4 + 2] = w;
@@ -117,12 +130,13 @@ draw_multi_viewport(void)
 	for (i = 0; i < divX; i++) {
 		for (j = 0; j < divY; j++) {
 			GLfloat expected[4];
-			
+
 			expected[0] = 1.0 / (1 + i*4 + j);
 			expected[1] = 0.0;
 			expected[2] = 0.0;
-			p = piglit_probe_pixel_rgb(i * w + w/2, j * h + h /2,
-						   expected);
+			expected[3] = 1.0;
+			p = piglit_probe_pixel_rgba(i * w + w/2, j * h + h /2,
+						    expected);
 			if (!p) {
 				printf("Wrong color for viewport i,j %d %d\n",
 				       i, j);
@@ -130,7 +144,7 @@ draw_multi_viewport(void)
 			}
 		}
 	}
-	      
+
 	piglit_present_results();
 
 	return pass;
@@ -151,8 +165,13 @@ piglit_init(int argc, char **argv)
 {
 	GLuint program;
 	GLuint vao;
+
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
 	piglit_require_extension("GL_ARB_gpu_shader5");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	program = piglit_build_simple_program_multiple_shaders(
 					GL_VERTEX_SHADER, vsSource,
diff --git a/tests/spec/arb_viewport_array/scissor_check.c b/tests/spec/arb_viewport_array/scissor_check.c
index 71f76e3..6526221 100644
--- a/tests/spec/arb_viewport_array/scissor_check.c
+++ b/tests/spec/arb_viewport_array/scissor_check.c
@@ -36,6 +36,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_core_version = 32;
 	config.supports_gl_compat_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -44,17 +45,26 @@ PIGLIT_GL_TEST_CONFIG_END
 #define WIDTH 32
 #define HEIGHT 32
 
+#ifdef PIGLIT_USE_OPENGL
+#define GLSL_VERSION "150"
+#else
+#define GLSL_VERSION "310 es"
+#endif
+
 static bool
 test(void)
 {
 	static const char *vsSrc =
-		"#version 150\n"
+		"#version " GLSL_VERSION "\n"
 		"in vec4 Attr0;"
 		"void main(void) {"
 		"   gl_Position = Attr0;"
 		"}";
 	static const char *fsSrc =
-		"#version 150\n"
+		"#version " GLSL_VERSION "\n"
+		"#ifdef GL_ES\n"
+		"precision highp float;\n"
+		"#endif\n"
 		"out vec4 fragColor0;"
 		"void main(void) {"
 		"   fragColor0 = vec4(1, 0, 0, 1);"
@@ -65,16 +75,13 @@ test(void)
 		-1.0f, -1.0f, 0.0f, 1.0f,
 		-1.0f,  1.0f, 0.0f, 1.0f,
 	};
-	const GLuint white = 0xffffffff;
-	const GLuint red = 0xff0000ff;
-	const GLuint magenta = 0xff00ffff;
-	const unsigned int numPixels = WIDTH * HEIGHT;
-	GLuint texData[WIDTH * HEIGHT];
-	GLuint i, tex, fbo, prog, vertexArray, vertexBuf;
-
-	for (i = 0; i < numPixels; ++i) {
-		texData[i] = white;
-	}
+	const GLfloat white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+	const GLfloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f};
+	const GLfloat magenta[4] = {1.0f, 0.0f, 1.0f, 1.0f};
+	GLbyte texData[WIDTH * HEIGHT * 4];
+	GLuint tex, fbo, prog, vertexArray, vertexBuf;
+
+	memset(texData, 0xff, sizeof(texData));
 
 	/* Create a white 2D texture. */
 	glGenTextures(1, &tex);
@@ -84,7 +91,7 @@ test(void)
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
 	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, WIDTH, HEIGHT,
-			GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, texData);
+			GL_RGBA, GL_UNSIGNED_BYTE, texData);
 
 	/* Create FBO with texture color attachment */
 	glGenFramebuffers(1, &fbo);
@@ -96,12 +103,6 @@ test(void)
 		printf("incomplete framebuffer at line %d\n", __LINE__);
 		return false;
 	}
-	glDrawBuffer(GL_COLOR_ATTACHMENT0);
-	if (glCheckFramebufferStatus(GL_FRAMEBUFFER) !=
-	    GL_FRAMEBUFFER_COMPLETE) {
-		printf("incomplete framebuffer at line %d\n", __LINE__);
-		return false;
-	}
 
 	/* Create shader program */
 	prog = piglit_build_simple_program(vsSrc, fsSrc);
@@ -137,31 +138,11 @@ test(void)
 	 */
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	glReadBuffer(GL_COLOR_ATTACHMENT0);
-	if (glCheckFramebufferStatus(GL_FRAMEBUFFER) !=
-	    GL_FRAMEBUFFER_COMPLETE) {
-		printf("incomplete framebuffer at line %d\n", __LINE__);
-		return false;
-	}
-
-	/* read color buffer */
-	glPixelStorei(GL_PACK_ROW_LENGTH, WIDTH);
-	glPixelStorei(GL_PACK_ALIGNMENT, 1);
-	memset(texData, 0, sizeof(texData));
-	glReadPixels(0, 0, WIDTH, HEIGHT,
-		     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, texData);
-
-	if (texData[0] != white) {
-		printf("At pixel (0,0) expected 0x%x but found 0x%x\n",
-		       white, texData[0]);
+	if (!piglit_probe_pixel_rgba(0, 0, white))
 		return false;
-	}
 
-	if (texData[numPixels - 1] != magenta) {
-		printf("At pixel (%d,%d) expected 0x%x but found 0x%x\n",
-		       WIDTH - 1, HEIGHT - 1, magenta, texData[numPixels - 1]);
+	if (!piglit_probe_pixel_rgba(WIDTH - 1, HEIGHT - 1, magenta))
 		return false;
-	}
 
 	/* Draw red quad (fragment shader always emits red).
 	 * With scissor, upper-right 16x16 should be red, leaving the rest
@@ -169,22 +150,11 @@ test(void)
 	 */
 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
-	/* read color buffer */
-	memset(texData, 0, sizeof(texData));
-	glReadPixels(0, 0, WIDTH, HEIGHT,
-		     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, texData);
-
-	if (texData[0] != white) {
-		printf("At pixel (0,0) expected 0x%x but found 0x%x\n",
-		       white, texData[0]);
+	if (!piglit_probe_pixel_rgba(0, 0, white))
 		return false;
-	}
 
-	if (texData[numPixels - 1] != red) {
-		printf("At pixel (%d,%d) expected 0x%x but found 0x%x\n",
-		       WIDTH - 1, HEIGHT - 1, magenta, texData[numPixels - 1]);
+	if (!piglit_probe_pixel_rgba(WIDTH - 1, HEIGHT - 1, red))
 		return false;
-	}
 
 	return true;
 }
@@ -203,8 +173,12 @@ piglit_init(int argc, char **argv)
 {
 	bool pass;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_texture_storage");
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	pass = test();
 	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
diff --git a/tests/spec/arb_viewport_array/scissor_indices.c b/tests/spec/arb_viewport_array/scissor_indices.c
index d7bbbab..e4e7355 100644
--- a/tests/spec/arb_viewport_array/scissor_indices.c
+++ b/tests/spec/arb_viewport_array/scissor_indices.c
@@ -39,6 +39,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -144,7 +145,11 @@ piglit_init(int argc, char **argv)
 	bool pass = true;
 	GLint maxVP;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP);
 	if (!piglit_check_gl_error(GL_NO_ERROR)) {
diff --git a/tests/spec/arb_viewport_array/viewport_indices.c b/tests/spec/arb_viewport_array/viewport_indices.c
index 96ab166..2f7b6d5 100644
--- a/tests/spec/arb_viewport_array/viewport_indices.c
+++ b/tests/spec/arb_viewport_array/viewport_indices.c
@@ -42,6 +42,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 32;
 	config.supports_gl_core_version = 32;
+	config.supports_gl_es_version = 31;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -146,15 +147,24 @@ test_preserve_invalid_index(GLint maxVP)
 	GLfloat vpGet[4];
 	static const GLint sc[4] = {3, 9, 17, 23};
 	GLint scGet[4];
+#ifdef PIGLIT_USE_OPENGL
 	static const GLdouble dr[2] = {0.3333, 0.66666};
 	GLdouble drGet[2];
+#else
+	static const GLfloat dr[2] = {0.3333, 0.66666};
+	GLfloat drGet[2];
+#endif
 	GLboolean scEnabled;
 	int i;
 
 	/* intialize all indices to know values */
 	for (i = 0; i < maxVP; i++) {
 		glViewportIndexedfv(i, vp);
+#ifdef PIGLIT_USE_OPENGL
 		glDepthRangeIndexed(i, dr[0], dr[1]);
+#else
+		glDepthRangeIndexedfOES(i, dr[0], dr[1]);
+#endif
 		glScissorIndexedv(i, sc);
 		glEnablei(GL_SCISSOR_TEST, i);
 	}
@@ -163,7 +173,11 @@ test_preserve_invalid_index(GLint maxVP)
 	/* set an illegal index and then test that no indices changed*/
 	glViewportIndexedf(maxVP, 0.0, 0.0, 1.0, 1.0);
 	glScissorIndexed(maxVP, 0, 0, 1, 1);
+#ifdef PIGLIT_USE_OPENGL
 	glDepthRangeIndexed(maxVP, 0.0, 0.0);
+#else
+	glDepthRangeIndexedfOES(maxVP, 0.0, 0.0);
+#endif
 	glDisablei(GL_SCISSOR_TEST, maxVP);
 
 	pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
@@ -176,7 +190,11 @@ test_preserve_invalid_index(GLint maxVP)
 			       i);
 			pass = false;
 		}
+#ifdef PIGLIT_USE_OPENGL
 		glGetDoublei_v(GL_DEPTH_RANGE, i, drGet);
+#else
+		glGetFloati_vOES(GL_DEPTH_RANGE, i, drGet);
+#endif
 		if (drGet[0] != dr[0] || drGet[1] != dr[1]) {
 			printf("DepthRange index %d got erroneously changed\n",
 			       i);
@@ -211,7 +229,11 @@ piglit_init(int argc, char **argv)
 	bool pass = true;
 	GLint maxVP;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_viewport_array");
+#else
+	piglit_require_extension("GL_OES_viewport_array");
+#endif
 
 	glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP);
 	if (!piglit_check_gl_error(GL_NO_ERROR))
-- 
2.7.3



More information about the Piglit mailing list