[Piglit] [PATCH] arb_blend_func_extended: add three api tests

Dave Airlie airlied at gmail.com
Sun Nov 20 11:00:41 PST 2011


From: Dave Airlie <airlied at redhat.com>

The first two are heavily reused version of the gl-3.0 API tests from Ian, just
adapted to test the two APIs for GL_ARB_blend_func_extended,

the third is a simple test that glBlendFunc can accept the new tokens, and
the changed behaviour of the GL_SRC_ALPHA_SATURATE token.

Signed-off-by: Dave Airlie <airlied at linux.ie>
---
 tests/spec/CMakeLists.txt                          |    1 +
 tests/spec/arb_blend_func_extended/CMakeLists.txt  |    2 +
 .../arb_blend_func_extended/api/CMakeLists.gl.txt  |   18 +++
 .../arb_blend_func_extended/api/CMakeLists.txt     |    1 +
 .../api/bindfragdataindexed-invalid-parameters.c   |  121 +++++++++++++++++++
 tests/spec/arb_blend_func_extended/api/blend-api.c |   92 ++++++++++++++
 .../arb_blend_func_extended/api/getfragdataindex.c |  127 ++++++++++++++++++++
 7 files changed, 362 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/arb_blend_func_extended/CMakeLists.txt
 create mode 100644 tests/spec/arb_blend_func_extended/api/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_blend_func_extended/api/CMakeLists.txt
 create mode 100644 tests/spec/arb_blend_func_extended/api/bindfragdataindexed-invalid-parameters.c
 create mode 100644 tests/spec/arb_blend_func_extended/api/blend-api.c
 create mode 100644 tests/spec/arb_blend_func_extended/api/getfragdataindex.c

diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 23893dd..863d583 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -36,3 +36,4 @@ add_subdirectory (arb_vertex_type_2_10_10_10_rev)
 add_subdirectory (ext_texture_integer)
 add_subdirectory (arb_draw_buffers)
 add_subdirectory (oes_draw_texture)
+add_subdirectory (arb_blend_func_extended)
diff --git a/tests/spec/arb_blend_func_extended/CMakeLists.txt b/tests/spec/arb_blend_func_extended/CMakeLists.txt
new file mode 100644
index 0000000..6903d88
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (api)
+piglit_include_target_api()
\ No newline at end of file
diff --git a/tests/spec/arb_blend_func_extended/api/CMakeLists.gl.txt b/tests/spec/arb_blend_func_extended/api/CMakeLists.gl.txt
new file mode 100644
index 0000000..a6a1067
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/api/CMakeLists.gl.txt
@@ -0,0 +1,18 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+	${GLUT_INCLUDE_DIR}
+	${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+	piglitutil
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+	${GLUT_glut_LIBRARY}
+)
+
+add_executable (arb_blend_func_extended-bindfragdataindexed-invalid-parameters bindfragdataindexed-invalid-parameters.c)
+add_executable (arb_blend_func_extended-getfragdataindex getfragdataindex.c)
+add_executable (arb_blend_func_extended-blend-api blend-api)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_blend_func_extended/api/CMakeLists.txt b/tests/spec/arb_blend_func_extended/api/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/api/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
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
new file mode 100644
index 0000000..400efd1
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/api/bindfragdataindexed-invalid-parameters.c
@@ -0,0 +1,121 @@
+/* Copyright © 2011 Intel Corporation
+ *
+ * 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.
+ */
+
+/**
+ * \file bindfragdataindexed-invalid-parameters.c
+ * Verify that passing invalid parameters to glBindFragDataLocationIndexed
+ * generates the correct errors.
+ *
+ * \author Ian Romanick + Dave Airlie (extended tests)
+ */
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	GLint max_draw_buffers, max_dual_source;
+	GLuint prog;
+
+	piglit_require_gl_version(30);
+	piglit_require_extension("GL_ARB_blend_func_extended");
+
+	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
+	glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max_dual_source);
+
+	/* Page 237 (page 253 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "BindFragDataLocation may be issued before any shader objects
+	 *     are attached to a program object."
+	 *
+	 * As a result, all of the invalid location tests can be performed
+	 * without a shader at all.  Only a program object is necessary.
+	 */
+	prog = glCreateProgram();
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	/* Page 236 (page 252 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "The error INVALID VALUE is generated if colorNumber is equal
+	 *     or greater than MAX DRAW BUFFERS."
+	 *
+	 * Since the colorNumber parameter is unsigned, this statement means
+	 * an error should be generated if a negative number is used.
+	 */
+	printf("Trying location = -1...\n");
+	glBindFragDataLocationIndexed(prog, -1, 0, "foo");
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	printf("Trying location = GL_MAX_DRAW_BUFFERS...\n");
+	glBindFragDataLocationIndexed(prog, max_draw_buffers, 0, "foo");
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+
+	/* ARB_blend_func_extended says,
+	 * The error INVALID_VALUE is generated if <colorNumber> is equal
+	 * or greater than MAX_DRAW_BUFFERS and <index> is zero, or if
+	 * <colorNumber> is equal or greater than MAX_DUAL_SOURCE_DRAW_BUFFERS
+	 * and <index> is greater than or equal to one.
+	 */
+	printf("Trying index > 1...\n");
+	glBindFragDataLocationIndexed(prog, 0, 2, "foo");
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	printf("Trying location = GL_MAX_DUAL_SOURCE_DRAW_BUFFERS with index 1...\n");
+	glBindFragDataLocationIndexed(prog, max_dual_source, 1, "foo");
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	/* Page 236 (page 252 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "The error INVALID_OPERATION is generated if name starts with
+	 *     the reserved gl prefix."
+	 *
+	 * This was changed in a later version of the spec.  Page 279 (page
+	 * 296 of the PDF) of the OpenGL 4.2 Core spec says:
+	 *
+	 *     "The error INVALID_OPERATION is generated if name starts with
+	 *     the reserved gl_ prefix."
+	 *
+	 * The OpenGL 4.2 spec also matches the specified behavior of
+	 * glBindAttribLocation as far back as OpenGL 2.0.
+	 */
+	printf("Trying name = `gl_FragColor'...\n");
+	glBindFragDataLocationIndexed(prog, 0, 0, "gl_FragColor");
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+	printf("Trying name = `gl_FragDepth'...\n");
+	glBindFragDataLocationIndexed(prog, 0, 0, "gl_FragDepth");
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+	printf("Trying name = `gl_'...\n");
+	glBindFragDataLocationIndexed(prog, 0, 0, "gl_");
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_blend_func_extended/api/blend-api.c b/tests/spec/arb_blend_func_extended/api/blend-api.c
new file mode 100644
index 0000000..c054b25
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/api/blend-api.c
@@ -0,0 +1,92 @@
+/* Copyright © 2011 Intel Corporation
+ *
+ * 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.
+ */
+
+/**
+ * \file blend-api.c
+ *
+ * \author Dave Airlie
+ * Test additions to blending API from ARB_blend_func_extended
+ */
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	GLint max_dual_source;
+
+	piglit_require_gl_version(30);
+	piglit_require_extension("GL_ARB_blend_func_extended");
+
+	/* This test needs some number of draw buffers, so make sure the
+	 * implementation isn't broken.  This enables the test to generate a
+	 * useful failure message.
+	 */
+	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.  "
+			"Only got %d!\n",
+			max_dual_source);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	printf("Querying blend modes.\n");
+      
+	/* try all new blending modes */
+	glBlendFunc(GL_SRC1_COLOR, GL_ZERO);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glBlendFunc(GL_SRC1_ALPHA, GL_ZERO);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glBlendFunc(GL_ONE_MINUS_SRC1_COLOR, GL_ZERO);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glBlendFunc(GL_ONE_MINUS_SRC1_ALPHA, GL_ZERO);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glBlendFunc(GL_ZERO, GL_SRC1_COLOR);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glBlendFunc(GL_ZERO, GL_SRC1_ALPHA);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC1_COLOR);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC1_ALPHA);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	/* GL_SRC_ALPHA_SATURATE is now handled as a DST attrib */
+	glBlendFunc(GL_ZERO, GL_SRC_ALPHA_SATURATE);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_blend_func_extended/api/getfragdataindex.c b/tests/spec/arb_blend_func_extended/api/getfragdataindex.c
new file mode 100644
index 0000000..21a3538
--- /dev/null
+++ b/tests/spec/arb_blend_func_extended/api/getfragdataindex.c
@@ -0,0 +1,127 @@
+/* Copyright © 2011 Intel Corporation
+ *
+ * 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.
+ */
+
+/**
+ * \file getfragdataindex.c
+ *
+ * \author Dave Airlie
+ * heavily inspired by getfragdatalocation.c from Ian Romanick
+ */
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static const char *vs_text =
+	"#version 130\n"
+	"in vec4 vertex;\n"
+	"void main() { gl_Position = vertex; }\n"
+	;
+
+static const char *fs_text =
+	"#version 130\n"
+	"out vec4 v;\n"
+	"out 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"
+	;
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	GLint max_draw_buffers, max_dual_source;
+	GLuint prog;
+	GLuint vs;
+	GLuint fs;
+	GLint idx;
+
+	piglit_require_gl_version(30);
+	piglit_require_extension("GL_ARB_blend_func_extended");
+
+	/* This test needs some number of draw buffers, so make sure the
+	 * implementation isn't broken.  This enables the test to generate a
+	 * useful failure message.
+	 */
+	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
+	if (max_draw_buffers < 8) {
+		fprintf(stderr,
+			"OpenGL 3.0 requires GL_MAX_DRAW_BUFFERS >= 8.  "
+			"Only got %d!\n",
+			max_draw_buffers);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+	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.  "
+			"Only got %d!\n",
+			max_dual_source);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	prog = glCreateProgram();
+	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
+	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
+	glAttachShader(prog, vs);
+	glAttachShader(prog, fs);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	/* Page 237 (page 253 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "If program has not been successfully linked, the error INVALID
+	 *     OPERATION is generated. If name is not a varying out variable,
+	 *     or if an error occurs, -1 will be returned."
+	 */
+	printf("Querying index before linking...\n");
+	idx = glGetFragDataIndex(prog, "v");
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+	if (idx != -1) {
+		fprintf(stderr, "Expected index = -1, got %d\n", idx);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	glLinkProgram(prog);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	if (!piglit_link_check_status(prog)) {
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	printf("Querying index of nonexistent variable...\n");
+	idx = glGetFragDataIndex(prog, "waldo");
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	if (idx != -1) {
+		fprintf(stderr, "Expected index = -1, got %d\n", idx);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+	piglit_report_result(PIGLIT_PASS);
+}
-- 
1.7.7.1



More information about the Piglit mailing list