[Piglit] [PATCH v2] Implement piglit tests for EXT_blend_func_extended

Ryan Houdek sonicadvance1 at gmail.com
Tue Nov 17 15:57:54 PST 2015


---
 tests/all.py                                       |  13 +++
 .../api/CMakeLists.gles2.txt                       |   5 +
 .../api/CMakeLists.gles3.txt                       |   6 ++
 .../api/bindfragdataindexed-invalid-parameters.c   |   8 ++
 tests/spec/arb_blend_func_extended/api/blend-api.c |   8 ++
 tests/spec/arb_blend_func_extended/api/builtins.c  | 111 +++++++++++++++++++++
 .../arb_blend_func_extended/api/getfragdataindex.c |  38 ++++++-
 .../arb_blend_func_extended/api/output-location.c  |  29 +++++-
 .../execution/CMakeLists.gles2.txt                 |   4 +
 .../execution/CMakeLists.gles3.txt                 |   6 ++
 .../execution/fbo-extended-blend-explicit.c        |  69 +++++++++++--
 .../execution/fbo-extended-blend-pattern.c         |  77 +++++++++++++-
 .../execution/fbo-extended-blend.c                 |  69 +++++++++++--
 13 files changed, 425 insertions(+), 18 deletions(-)
 create mode 100644 tests/spec/arb_blend_func_extended/api/CMakeLists.gles2.txt
 create mode 100644 tests/spec/arb_blend_func_extended/api/CMakeLists.gles3.txt
 create mode 100644 tests/spec/arb_blend_func_extended/api/builtins.c
 create mode 100644 tests/spec/arb_blend_func_extended/execution/CMakeLists.gles2.txt
 create mode 100644 tests/spec/arb_blend_func_extended/execution/CMakeLists.gles3.txt

diff --git a/tests/all.py b/tests/all.py
index ee2b7d9..b81578d 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3982,6 +3982,19 @@ with profile.group_manager(
       run_concurrent=False)
     g(['arb_blend_func_extended-fbo-extended-blend-pattern'],
       run_concurrent=False)
+    g(['arb_blend_func_extended-blend-api_gles2'], run_concurrent=False)
+    g(['arb_blend_func_extended-builtins_gles2'], run_concurrent=False)
+    g(['arb_blend_func_extended-bindfragdataindexed-invalid-parameters_gles3'],
+      run_concurrent=False)
+    g(['arb_blend_func_extended-output-location_gles3'], run_concurrent=False)
+    g(['arb_blend_func_extended-getfragdataindex_gles3'], run_concurrent=False)
+    g(['arb_blend_func_extended-fbo-extended-blend-pattern_gles2'],
+      run_concurrent=False)
+    g(['arb_blend_func_extended-fbo-extended-blend-pattern_gles3'],
+      run_concurrent=False)
+    g(['arb_blend_func_extended-fbo-extended-blend_gles3'], run_concurrent=False)
+    g(['arb_blend_func_extended-fbo-extended-blend-explicit_gles3'],
+      run_concurrent=False)
 
 with profile.group_manager(
         PiglitGLTest,
diff --git a/tests/spec/arb_blend_func_extended/api/CMakeLists.gles2.txt b/tests/spec/arb_blend_func_extended/api/CMakeLists.gles2.txt
new file mode 100644
index 0000000..2966073
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/api/CMakeLists.gles2.txt
@@ -0,0 +1,5 @@
+link_libraries(piglitutil_${piglit_target_api})
+
+piglit_add_executable (arb_blend_func_extended-blend-api_${piglit_target_api} blend-api)
+piglit_add_executable (arb_blend_func_extended-builtins_${piglit_target_api} builtins.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_blend_func_extended/api/CMakeLists.gles3.txt b/tests/spec/arb_blend_func_extended/api/CMakeLists.gles3.txt
new file mode 100644
index 0000000..a005fc2
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/api/CMakeLists.gles3.txt
@@ -0,0 +1,6 @@
+link_libraries(piglitutil_${piglit_target_api})
+
+piglit_add_executable (arb_blend_func_extended-bindfragdataindexed-invalid-parameters_${piglit_target_api} bindfragdataindexed-invalid-parameters.c)
+piglit_add_executable (arb_blend_func_extended-output-location_${piglit_target_api} output-location.c)
+piglit_add_executable (arb_blend_func_extended-getfragdataindex_${piglit_target_api} getfragdataindex.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_blend_func_extended/api/bindfragdataindexed-invalid-parameters.c b/tests/spec/arb_blend_func_extended/api/bindfragdataindexed-invalid-parameters.c
index 7ef6048..c4a8d53 100644
--- a/tests/spec/arb_blend_func_extended/api/bindfragdataindexed-invalid-parameters.c
+++ b/tests/spec/arb_blend_func_extended/api/bindfragdataindexed-invalid-parameters.c
@@ -31,7 +31,11 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
+#ifdef PIGLIT_USE_OPENGL
 	config.supports_gl_compat_version = 10;
+#else // PIGLIT_USE_OPENGLES3
+	config.supports_gl_es_version = 30;
+#endif
 	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
@@ -47,8 +51,12 @@ void piglit_init(int argc, char **argv)
 	GLint max_draw_buffers, max_dual_source;
 	GLuint prog;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_gl_version(30);
 	piglit_require_extension("GL_ARB_blend_func_extended");
+#else // PIGLIT_USE_OPENGLES3
+	piglit_require_extension("GL_EXT_blend_func_extended");
+#endif
 
 	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
 	glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max_dual_source);
diff --git a/tests/spec/arb_blend_func_extended/api/blend-api.c b/tests/spec/arb_blend_func_extended/api/blend-api.c
index 00e4c7b..4c34bc7 100644
--- a/tests/spec/arb_blend_func_extended/api/blend-api.c
+++ b/tests/spec/arb_blend_func_extended/api/blend-api.c
@@ -30,7 +30,11 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
+#ifdef PIGLIT_USE_OPENGL
 	config.supports_gl_compat_version = 10;
+#else // PIGLIT_USE_OPENGL_ES2
+	config.supports_gl_es_version = 20;
+#endif
 	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
@@ -45,8 +49,12 @@ void piglit_init(int argc, char **argv)
 {
 	GLint max_dual_source;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_gl_version(30);
 	piglit_require_extension("GL_ARB_blend_func_extended");
+#else // PIGLIT_USE_OPENGL_ES2
+	piglit_require_extension("GL_EXT_blend_func_extended");
+#endif
 
 	/* This test needs some number of draw buffers, so make sure the
 	 * implementation isn't broken.  This enables the test to generate a
diff --git a/tests/spec/arb_blend_func_extended/api/builtins.c b/tests/spec/arb_blend_func_extended/api/builtins.c
new file mode 100644
index 0000000..e0a6c6f
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/api/builtins.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2015 Ryan Houdek <Sonicadvance1 at gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_es_version = 20;
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+bool compile_simple_program(const char* vs_text, const char* fs_text)
+{
+	GLuint vs;
+	GLuint fs;
+	GLuint prog;
+
+	prog = glCreateProgram();
+
+	vs = piglit_compile_shader_text_nothrow(GL_VERTEX_SHADER, vs_text);
+	fs = piglit_compile_shader_text_nothrow(GL_FRAGMENT_SHADER, fs_text);
+
+	if (!vs || !fs)
+		return false;
+
+	glAttachShader(prog, vs);
+	glAttachShader(prog, fs);
+	glLinkProgram(prog);
+
+	return !!prog;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+	char fs_text[256];
+
+	piglit_require_extension("GL_EXT_blend_func_extended");
+
+	static const char *vs_text =
+		"#version 100\n"
+		"void main() {\n"
+		"        gl_Position = vec4(0);\n"
+		"}\n"
+		;
+
+	static const char *fs_template =
+		"#version 100\n"
+		"#extension GL_EXT_blend_func_extended : enable\n"
+		"void main() {\n"
+		"	%s = vec4(0);\n"
+		"	%s = vec4(0);\n"
+		"}\n"
+		;
+
+	// Tests that should pass
+	// Regular FragColor
+	snprintf(fs_text, 256, fs_template,
+	         "gl_FragColor",
+		   "gl_SecondaryFragColorEXT");
+	pass = compile_simple_program(vs_text, fs_text) && pass;
+
+	// Regular FragData
+	snprintf(fs_text, 256, fs_template,
+	         "gl_FragData[0]",
+		   "gl_SecondaryFragDataEXT[0]");
+	pass = compile_simple_program(vs_text, fs_text) && pass;
+
+	// Tests that should fail
+	// FragColor & SecondaryFragData
+	snprintf(fs_text, 256, fs_template,
+	         "gl_FragColor",
+		   "gl_SecondaryFragDataEXT[0]");
+	pass = !compile_simple_program(vs_text, fs_text) && pass;
+
+	// FragData & SecondaryFragColor
+	snprintf(fs_text, 256, fs_template,
+	         "gl_FragData[0]",
+		   "gl_SecondaryFragColorEXT");
+	pass = !compile_simple_program(vs_text, fs_text) && pass;
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+
+}
diff --git a/tests/spec/arb_blend_func_extended/api/getfragdataindex.c b/tests/spec/arb_blend_func_extended/api/getfragdataindex.c
index 3fb8aa8..a30263e 100644
--- a/tests/spec/arb_blend_func_extended/api/getfragdataindex.c
+++ b/tests/spec/arb_blend_func_extended/api/getfragdataindex.c
@@ -30,11 +30,16 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
+#ifdef PIGLIT_USE_OPENGL
 	config.supports_gl_compat_version = 10;
+#else // PIGLIT_USE_OPENGL_ES3
+	config.supports_gl_es_version = 30;
+#endif
 	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
 
+#ifdef PIGLIT_USE_OPENGL
 static const char *vs_text =
 	"#version 130\n"
 	"in vec4 vertex;\n"
@@ -51,6 +56,25 @@ static const char *fs_text =
 	"    a[1] = vec4(2.0);\n"
 	"}\n"
 	;
+#else // PIGLIT_USE_OPENGL_ES3
+static const char *vs_text =
+	"#version 300 es\n"
+	"in vec4 vertex;\n"
+	"void main() { gl_Position = vertex; }\n"
+	;
+
+static const char *fs_text =
+	"#version 300 es\n"
+	"#extension GL_EXT_blend_func_extended : enable\n"
+	"out highp vec4 v;\n"
+	"out highp vec4 a[2];\n"
+	"void main() {\n"
+	"    v = vec4(0.0);\n"
+	"    a[0] = vec4(1.0);\n"
+	"    a[1] = vec4(2.0);\n"
+	"}\n"
+	;
+#endif
 
 enum piglit_result
 piglit_display(void)
@@ -66,8 +90,12 @@ void piglit_init(int argc, char **argv)
 	GLuint fs;
 	GLint idx;
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_gl_version(30);
 	piglit_require_extension("GL_ARB_blend_func_extended");
+#else // PIGLIT_USE_OPENGL_ES3
+	piglit_require_extension("GL_EXT_blend_func_extended");
+#endif
 
 	/* This test needs some number of draw buffers, so make sure the
 	 * implementation isn't broken.  This enables the test to generate a
@@ -84,7 +112,7 @@ void piglit_init(int argc, char **argv)
 	glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max_dual_source);
 	if (max_dual_source < 1) {
 		fprintf(stderr,
-			"ARB_blend_func_extended requires GL_MAX_DUAL_SOURCE_DRAW_BUFFERS >= 1.  "
+			"blend_func_extended requires GL_MAX_DUAL_SOURCE_DRAW_BUFFERS >= 1.  "
 			"Only got %d!\n",
 			max_dual_source);
 		piglit_report_result(PIGLIT_FAIL);
@@ -105,7 +133,11 @@ void piglit_init(int argc, char **argv)
 	 *     or if an error occurs, -1 will be returned."
 	 */
 	printf("Querying index before linking...\n");
+#ifdef PIGLIT_USE_OPENGL
 	idx = glGetFragDataIndex(prog, "v");
+#else // PIGLIT_USE_OPENGLES3
+	idx = glGetFragDataIndexEXT(prog, "v");
+#endif
 	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
 		piglit_report_result(PIGLIT_FAIL);
 
@@ -123,7 +155,11 @@ void piglit_init(int argc, char **argv)
 	}
 
 	printf("Querying index of nonexistent variable...\n");
+#ifdef PIGLIT_USE_OPENGL
 	idx = glGetFragDataIndex(prog, "waldo");
+#else // PIGLIT_USE_OPENGLES3
+	idx = glGetFragDataIndexEXT(prog, "waldo");
+#endif
 	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
 
diff --git a/tests/spec/arb_blend_func_extended/api/output-location.c b/tests/spec/arb_blend_func_extended/api/output-location.c
index b95ee72..1fc9203 100644
--- a/tests/spec/arb_blend_func_extended/api/output-location.c
+++ b/tests/spec/arb_blend_func_extended/api/output-location.c
@@ -30,11 +30,16 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
+#ifdef PIGLIT_USE_OPENGL
 	config.supports_gl_core_version = 31;
+#else // PIGLIT_USE_OPENGLES3
+	config.supports_gl_es_version = 30;
+#endif
 	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
 
+#ifdef PIGLIT_USE_OPENGL
 static const char *vs_text =
 	"#version 150\n"
 	"in vec4 vertex;\n"
@@ -51,6 +56,24 @@ static const char *fs_template =
 	"    b = vec4(1.0);\n"
 	"}\n"
 	;
+#else // PIGLIT_USE_OPENGLES3
+static const char *vs_text =
+	"#version 300 es\n"
+	"in vec4 vertex;\n"
+	"void main() { gl_Position = vertex; }\n"
+	;
+
+static const char *fs_template =
+	"#version 300 es\n"
+	"#extension GL_EXT_blend_func_extended : enable\n"
+	"layout(location = 0, index = 0) out highp vec4 a;\n"
+	"layout(location = %d, index = 1) out highp vec4 b;\n"
+	"void main() {\n"
+	"    a = vec4(0.0);\n"
+	"    b = vec4(1.0);\n"
+	"}\n"
+	;
+#endif
 
 enum piglit_result
 piglit_display(void)
@@ -64,8 +87,12 @@ void piglit_init(int argc, char **argv)
 	GLuint prog;
 	char fs_text[256];
 
-	piglit_require_extension("GL_ARB_blend_func_extended");
 
+#ifdef PIGLIT_USE_OPENGL
+	piglit_require_extension("GL_ARB_blend_func_extended");
+#else // PIGLIT_USE_OPENGLES3
+	piglit_require_extension("GL_EXT_blend_func_extended");
+#endif
 	glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max_dual_source);
 
 	if (max_dual_source < 1) {
diff --git a/tests/spec/arb_blend_func_extended/execution/CMakeLists.gles2.txt b/tests/spec/arb_blend_func_extended/execution/CMakeLists.gles2.txt
new file mode 100644
index 0000000..8039d99
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/execution/CMakeLists.gles2.txt
@@ -0,0 +1,4 @@
+link_libraries(piglitutil_${piglit_target_api})
+
+piglit_add_executable (arb_blend_func_extended-fbo-extended-blend-pattern_${piglit_target_api} fbo-extended-blend-pattern.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_blend_func_extended/execution/CMakeLists.gles3.txt b/tests/spec/arb_blend_func_extended/execution/CMakeLists.gles3.txt
new file mode 100644
index 0000000..a70e9fa
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/execution/CMakeLists.gles3.txt
@@ -0,0 +1,6 @@
+link_libraries(piglitutil_${piglit_target_api})
+
+piglit_add_executable (arb_blend_func_extended-fbo-extended-blend_${piglit_target_api} fbo-extended-blend.c)
+piglit_add_executable (arb_blend_func_extended-fbo-extended-blend-explicit_${piglit_target_api} fbo-extended-blend-explicit.c)
+piglit_add_executable (arb_blend_func_extended-fbo-extended-blend-pattern_${piglit_target_api} fbo-extended-blend-pattern.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
index a6450b8..ce3f7e4 100644
--- a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
+++ b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
@@ -39,7 +39,11 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
+#ifdef PIGLIT_USE_OPENGL
 	config.supports_gl_compat_version = 30;
+#else // PIGLIT_USE_OPENGL_ES3
+	config.supports_gl_es_version = 30;
+#endif
 	config.window_visual = PIGLIT_GL_VISUAL_RGB;
 
 PIGLIT_GL_TEST_CONFIG_END
@@ -92,13 +96,13 @@ static void blend(const float *src, const float *src1, const float *dst,
 		  GLenum blendsrc, GLenum blenddst, GLenum blendop)
 {
 	glUniform4fv(uniform_src0, 1, dst);
-	piglit_draw_rect(0, 0, piglit_width, piglit_height);
+	piglit_draw_rect(-1, -1, 2, 2);
 	glEnable(GL_BLEND);
 	glBlendEquation(blendop);
 	glBlendFunc(blendsrc, blenddst);
 	glUniform4fv(uniform_src0, 1, src);
 	glUniform4fv(uniform_src1, 1, src1);
-	piglit_draw_rect(0, 0, piglit_width, piglit_height);
+	piglit_draw_rect(-1, -1, 2, 2);
 	glDisable(GL_BLEND);
 }
 
@@ -200,11 +204,12 @@ static void blend_expected(float *expected, const float *src, const float *src1,
 	}
 }
 
+#ifdef PIGLIT_USE_OPENGL
 static const char *vs_text =
 	"#version 130\n"
+	"in vec4 piglit_vertex;\n"
 	"void main() {\n"
-	"        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-	"        gl_FrontColor = gl_Color;\n"
+	"        gl_Position = piglit_vertex;\n"
 	"}\n"
 	;
 
@@ -220,6 +225,28 @@ static const char *fs_text =
 	"        col1 = src1;\n"
 	"}\n"
 	;
+#else // PIGLIT_USE_OPENGL_ES3
+static const char *vs_text =
+	"#version 300 es\n"
+	"in vec4 piglit_vertex;\n"
+	"void main() {\n"
+	"        gl_Position = piglit_vertex;\n"
+	"}\n"
+	;
+
+static const char *fs_text =
+	"#version 300 es\n"
+	"#extension GL_EXT_blend_func_extended : enable\n"
+	"uniform highp vec4 src0;\n"
+	"uniform highp vec4 src1;\n"
+	"layout(location = 0, index = 0) out highp vec4 col0;\n"
+	"layout(location = 0, index = 1) out highp vec4 col1;\n"
+	"void main() {\n"
+	"        col0 = src0;\n"
+	"        col1 = src1;\n"
+	"}\n"
+	;
+#endif
 
 static void
 create_fbo(void)
@@ -227,6 +254,7 @@ create_fbo(void)
 	GLuint rb[32];
 	int i;
 
+#ifdef PIGLIT_USE_OPENGL
 	glGenFramebuffersEXT(1, &fbo);
 	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
 
@@ -247,6 +275,28 @@ create_fbo(void)
 					 piglit_width, piglit_height);
 		check_error(__LINE__);
 	}
+#else // PIGLIT_USE_OPENGL_ES3
+	glGenFramebuffers(1, &fbo);
+	glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
+
+	glGenRenderbuffers(max_ds_buffers, rb);
+	check_error(__LINE__);
+
+	for (i = 0; i < max_ds_buffers; i++) {
+		glBindRenderbuffer(GL_RENDERBUFFER_EXT, rb[i]);
+		check_error(__LINE__);
+
+		glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
+					     GL_COLOR_ATTACHMENT0 + i,
+					     GL_RENDERBUFFER_EXT,
+					     rb[i]);
+		check_error(__LINE__);
+
+		glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA8,
+					 piglit_width, piglit_height);
+		check_error(__LINE__);
+	}
+#endif
 }
 
 static enum piglit_result
@@ -266,7 +316,12 @@ test(void)
 
 	create_fbo();
 
+#ifdef PIGLIT_USE_OPENGL
 	glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+#else // PIGLIT_USE_OPENGL_ES3
+	GLenum bufs[] = {GL_COLOR_ATTACHMENT0_EXT};
+	glDrawBuffers(1, bufs);
+#endif
 
 	prog = piglit_build_simple_program(vs_text, fs_text);
 	glUseProgram(prog);
@@ -315,10 +370,12 @@ void
 piglit_init(int argc, char**argv)
 {
 	enum piglit_result result;
-	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
-
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_blend_func_extended");
 	piglit_require_extension("GL_ARB_explicit_attrib_location");
+#else // PIGLIT_USE_OPENGL_ES3
+	piglit_require_extension("GL_EXT_blend_func_extended");
+#endif
 
 	glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max_ds_buffers);
 
diff --git a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-pattern.c b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-pattern.c
index 7168a2c..50f84af 100644
--- a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-pattern.c
+++ b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-pattern.c
@@ -48,7 +48,13 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
+#ifdef PIGLIT_USE_OPENGL
    config.supports_gl_compat_version = 30;
+#elif PIGLIT_USE_OPENGL_ES3
+   config.supports_gl_es_version = 30;
+#else // PIGLIT_USE_OPENGL_ES2
+   config.supports_gl_es_version = 20;
+#endif
    config.window_visual = PIGLIT_GL_VISUAL_RGB;
 
 PIGLIT_GL_TEST_CONFIG_END
@@ -57,10 +63,12 @@ static const char *TestName = "fbo-extended-blend-pattern";
 
 static GLint uniform_src0, uniform_src1, uniform_src2;
 
+#ifdef PIGLIT_USE_OPENGL
 static const char *vs_text =
    "#version 130\n"
+   "in vec4 piglit_vertex;\n"
    "void main() {\n"
-   "  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+   "  gl_Position = piglit_vertex;\n"
    "}\n"
    ;
 
@@ -83,6 +91,64 @@ static const char *fs_text =
    "      col1 = src2;\n"
    "}\n"
    ;
+#elif PIGLIT_USE_OPENGL_ES3
+static const char *vs_text =
+   "#version 300 es\n"
+   "in vec4 piglit_vertex;\n"
+   "void main() {\n"
+   "  gl_Position = piglit_vertex;\n"
+   "}\n"
+   ;
+
+static const char *fs_text =
+   "#version 300 es\n"
+   "#extension GL_EXT_blend_func_extended : enable\n"
+   "precision highp float;\n"
+   "uniform vec4 src0;\n"
+   "uniform vec4 src1;\n"
+   "uniform vec4 src2;\n"
+   "layout(location = 0, index = 0) out vec4 col0;\n"
+   "layout(location = 0, index = 1) out vec4 col1;\n"
+   "void main() {\n"
+   "   int a = int(gl_FragCoord.x) / 10;\n"
+   "   int b = int(gl_FragCoord.y) / 10;\n"
+   "   int c = int(mod(a + b, 2));\n"
+   "   col0 = src0;\n"
+   "   if (c == 0)\n"
+   "      col1 = src1;\n"
+   "   else\n"
+   "      col1 = src2;\n"
+   "}\n"
+   ;
+#else // PIGLIT_USE_OPENGL_ES2
+static const char *vs_text =
+   "#version 100\n"
+   "attribute vec4 piglit_vertex;\n"
+   "void main() {\n"
+   "  gl_Position = piglit_vertex;\n"
+   "}\n"
+   ;
+
+static const char *fs_text =
+   "#version 100\n"
+   "#extension GL_EXT_blend_func_extended : enable\n"
+   "precision highp float;\n"
+   "uniform vec4 src0;\n"
+   "uniform vec4 src1;\n"
+   "uniform vec4 src2;\n"
+   "void main() {\n"
+   "   float a = floor(gl_FragCoord.x / 10.0);\n"
+   "   float b = floor(gl_FragCoord.y / 10.0);\n"
+   "   float c = floor(mod(a + b, 2.0));\n"
+   "   gl_FragColor = src0;\n"
+   "   if (c == 0.0)\n"
+   "      gl_SecondaryFragColorEXT = src1;\n"
+   "   else\n"
+   "      gl_SecondaryFragColorEXT = src2;\n"
+   "}\n"
+   ;
+
+#endif
 
 static void
 check_error(int line)
@@ -98,13 +164,13 @@ static void
 blend(const float *src, const float *src1, const float *src2, const float *dst)
 {
    glUniform4fv(uniform_src0, 1, dst);
-   piglit_draw_rect(0, 0, piglit_width, piglit_height);
+   piglit_draw_rect(-1, -1, 2, 2);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_COLOR, GL_SRC1_COLOR);
    glUniform4fv(uniform_src0, 1, src);
    glUniform4fv(uniform_src1, 1, src1);
    glUniform4fv(uniform_src2, 1, src2);
-   piglit_draw_rect(0, 0, piglit_width, piglit_height);
+   piglit_draw_rect(-1, -1, 2, 2);
    glDisable(GL_BLEND);
    glFinish();
 }
@@ -148,7 +214,10 @@ piglit_display(void)
 void
 piglit_init(int argc, char **argv)
 {
+#ifdef PIGLIT_USE_OPENGL
    piglit_require_extension("GL_ARB_blend_func_extended");
    piglit_require_extension("GL_ARB_explicit_attrib_location");
-   piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+#else // PIGLIT_USE_OPENGL_ES{2, 3}
+   piglit_require_extension("GL_EXT_blend_func_extended");
+#endif
 }
diff --git a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
index 523d07c..0902a4b 100644
--- a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
+++ b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
@@ -39,7 +39,11 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
+#ifdef PIGLIT_USE_OPENGL
 	config.supports_gl_compat_version = 30;
+#else // PIGLIT_USE_OPENGL_ES3
+	config.supports_gl_es_version = 30;
+#endif
 	config.window_visual = PIGLIT_GL_VISUAL_RGB;
 
 PIGLIT_GL_TEST_CONFIG_END
@@ -92,13 +96,13 @@ static void blend(const float *src, const float *src1, const float *dst,
 		  GLenum blendsrc, GLenum blenddst, GLenum blendop)
 {
 	glUniform4fv(uniform_src0, 1, dst);
-	piglit_draw_rect(0, 0, piglit_width, piglit_height);
+	piglit_draw_rect(-1, -1, 2, 2);
 	glEnable(GL_BLEND);
 	glBlendEquation(blendop);
 	glBlendFunc(blendsrc, blenddst);
 	glUniform4fv(uniform_src0, 1, src);
 	glUniform4fv(uniform_src1, 1, src1);
-	piglit_draw_rect(0, 0, piglit_width, piglit_height);
+	piglit_draw_rect(-1, -1, 2, 2);
 	glDisable(GL_BLEND);
 }
 
@@ -200,11 +204,12 @@ static void blend_expected(float *expected, const float *src, const float *src1,
 	}
 }
 
+#ifdef PIGLIT_USE_OPENGL
 static const char *vs_text =
 	"#version 130\n"
+	"in vec4 piglit_vertex;\n"
 	"void main() {\n"
-	"        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-	"        gl_FrontColor = gl_Color;\n"
+	"        gl_Position = piglit_vertex;\n"
 	"}\n"
 	;
 
@@ -219,6 +224,28 @@ static const char *fs_text =
 	"        col1 = src1;\n"
 	"}\n"
 	;
+#else // PIGLIT_USE_OPENGL_ES3
+static const char *vs_text =
+	"#version 300 es\n"
+	"in vec4 piglit_vertex;\n"
+	"void main() {\n"
+	"        gl_Position = piglit_vertex;\n"
+	"}\n"
+	;
+
+static const char *fs_text =
+	"#version 300 es\n"
+	"#extension GL_EXT_blend_func_extended : enable\n"
+	"uniform highp vec4 src0;\n"
+	"uniform highp vec4 src1;\n"
+	"out highp vec4 col0;\n"
+	"out highp vec4 col1;\n"
+	"void main() {\n"
+	"        col0 = src0;\n"
+	"        col1 = src1;\n"
+	"}\n"
+	;
+#endif
 
 static void
 create_fbo(void)
@@ -226,6 +253,7 @@ create_fbo(void)
 	GLuint rb[32];
 	int i;
 
+#ifdef PIGLIT_USE_OPENGL
 	glGenFramebuffersEXT(1, &fbo);
 	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
 
@@ -246,6 +274,28 @@ create_fbo(void)
 					 piglit_width, piglit_height);
 		check_error(__LINE__);
 	}
+#else // PIGLIT_USE_OPENGL_ES3
+	glGenFramebuffers(1, &fbo);
+	glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
+
+	glGenRenderbuffers(max_ds_buffers, rb);
+	check_error(__LINE__);
+
+	for (i = 0; i < max_ds_buffers; i++) {
+		glBindRenderbuffer(GL_RENDERBUFFER_EXT, rb[i]);
+		check_error(__LINE__);
+
+		glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
+					     GL_COLOR_ATTACHMENT0 + i,
+					     GL_RENDERBUFFER_EXT,
+					     rb[i]);
+		check_error(__LINE__);
+
+		glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA8,
+					 piglit_width, piglit_height);
+		check_error(__LINE__);
+	}
+#endif
 }
 
 static enum piglit_result
@@ -278,7 +328,12 @@ test(void)
 
 	create_fbo();
 
+#ifdef PIGLIT_USE_OPENGL
 	glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+#else // PIGLIT_USE_OPENGL_ES3
+	GLenum bufs[] = {GL_COLOR_ATTACHMENT0_EXT};
+	glDrawBuffers(1, bufs);
+#endif
 
 	glLinkProgram(prog);
 	glUseProgram(prog);
@@ -327,9 +382,11 @@ void
 piglit_init(int argc, char**argv)
 {
 	enum piglit_result result;
-	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
-
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_ARB_blend_func_extended");
+#else // PIGLIT_USE_OPENGL_ES3
+	piglit_require_extension("GL_EXT_blend_func_extended");
+#endif
 
 	glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max_ds_buffers);
 
-- 
2.5.0



More information about the Piglit mailing list