[Piglit] [PATCH 1/7] arb_vertex_attrib_binding: Test error conditions

Fredrik Höglund fredrik at kde.org
Thu Jul 11 21:16:16 PDT 2013


---
 tests/all.tests                                    |    4 +
 tests/spec/CMakeLists.txt                          |    1 +
 .../arb_vertex_attrib_binding/CMakeLists.gl.txt    |   14 ++
 .../spec/arb_vertex_attrib_binding/CMakeLists.txt  |    1 +
 tests/spec/arb_vertex_attrib_binding/errors.c      |  249 ++++++++++++++++++++
 5 files changed, 269 insertions(+)
 create mode 100644 tests/spec/arb_vertex_attrib_binding/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_vertex_attrib_binding/CMakeLists.txt
 create mode 100644 tests/spec/arb_vertex_attrib_binding/errors.c

diff --git a/tests/all.tests b/tests/all.tests
index 2a5fbd0..42ff70c 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1390,6 +1390,10 @@ spec['ARB_vertex_array_object'] = arb_vertex_array_object
 add_concurrent_test(arb_vertex_array_object, 'vao-element-array-buffer')
 arb_vertex_array_object['isvertexarray'] = concurrent_test('arb_vertex_array-isvertexarray')
 
+arb_vertex_attrib_binding = Group()
+spec['ARB_vertex_attrib_binding'] = arb_vertex_attrib_binding
+arb_vertex_attrib_binding['errors'] = concurrent_test('arb_vertex_attrib_binding-errors')
+
 arb_vertex_buffer_object = Group()
 spec['ARB_vertex_buffer_object'] = arb_vertex_buffer_object
 arb_vertex_buffer_object['elements-negative-offset'] = PlainExecTest(['arb_vertex_buffer_object-elements-negative-offset', '-auto'])
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index e6cd6d2..a43e6e0 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -75,3 +75,4 @@ add_subdirectory (oes_fixed_point)
 add_subdirectory (arb_blend_func_extended)
 add_subdirectory (ext_unpack_subimage)
 add_subdirectory (arb_vertex_array_object)
+add_subdirectory (arb_vertex_attrib_binding)
diff --git a/tests/spec/arb_vertex_attrib_binding/CMakeLists.gl.txt b/tests/spec/arb_vertex_attrib_binding/CMakeLists.gl.txt
new file mode 100644
index 0000000..ebc0cc3
--- /dev/null
+++ b/tests/spec/arb_vertex_attrib_binding/CMakeLists.gl.txt
@@ -0,0 +1,14 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+	piglitutil_${piglit_target_api}
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (arb_vertex_attrib_binding-errors errors.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_vertex_attrib_binding/CMakeLists.txt b/tests/spec/arb_vertex_attrib_binding/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_vertex_attrib_binding/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_vertex_attrib_binding/errors.c b/tests/spec/arb_vertex_attrib_binding/errors.c
new file mode 100644
index 0000000..adac098
--- /dev/null
+++ b/tests/spec/arb_vertex_attrib_binding/errors.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright © 2013 Fredrik Höglund
+ *
+ * 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 errors.c
+ *
+ * Tests error conditions for ARB_vertex_attrib_binding.
+ */
+
+#include "piglit-util-gl-common.h"
+
+#define MIN(a, b) (a < b ? a : b)
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	/* uncreached */
+	return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLint maxBindings, maxAttribs, maxRelativeOffset;
+	GLuint vbo, vao;
+	int i;
+
+	piglit_require_extension("GL_ARB_vertex_attrib_binding");
+	piglit_require_extension("GL_ARB_vertex_array_bgra");
+	piglit_require_extension("GL_ARB_vertex_type_2_10_10_10_rev");
+	piglit_require_extension("GL_ARB_ES2_compatibility");
+
+	/* Create and bind a vertex array object */
+	glGenVertexArrays(1, &vao);
+	glBindVertexArray(vao);
+
+	glGenBuffers(1, &vbo);
+	glBindBuffer(GL_ARRAY_BUFFER, vbo);
+
+
+	/* Query limits */
+	glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);
+	glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, &maxBindings);
+	glGetIntegerv(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, &maxRelativeOffset);
+
+	/* Clear the error state */
+	while (glGetError() != GL_NO_ERROR) {}
+
+
+	/* index >= GL_MAX_VERTEX_ATTRIB_BINDINGS */
+	glBindVertexBuffer(maxBindings, vbo, 0, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	/* stride < 0 */
+	glBindVertexBuffer(0, vbo, 0, -1);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	/* offset < 0 */
+	glBindVertexBuffer(0, vbo, -1, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* bindingIndex >= GL_MAX_VERTEX_ATTRIB_BINDINGS */
+	glVertexAttribBinding(0, maxBindings);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	/* attribIndex >= GL_MAX_VERTEX_ATTRIBS */
+	glVertexAttribBinding(maxAttribs, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* index >= GL_MAX_VERTEX_ATTRIB_BINDINGS */
+	glVertexBindingDivisor(maxBindings, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* index >= GL_MAX_VERTEX_ATTRIBS */
+	glVertexAttribFormat(maxAttribs, 4, GL_FLOAT, GL_FALSE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribIFormat(maxAttribs, 4, GL_UNSIGNED_BYTE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribLFormat(maxAttribs, 4, GL_DOUBLE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* relativeoffset > maxRelativeOffset */
+	glVertexAttribFormat(0, 4, GL_FLOAT, GL_FALSE, maxRelativeOffset + 1);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribIFormat(0, 4, GL_UNSIGNED_INT, maxRelativeOffset + 1);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribLFormat(0, 4, GL_DOUBLE, maxRelativeOffset + 1);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* size < 1 */
+	glVertexAttribFormat(0, 0, GL_FLOAT, GL_FALSE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribIFormat(0, 0, GL_UNSIGNED_BYTE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribLFormat(0, 0, GL_DOUBLE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* size > 4 */
+	glVertexAttribFormat(0, 5, GL_FLOAT, GL_FALSE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribIFormat(0, 5, GL_UNSIGNED_BYTE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribLFormat(0, 5, GL_DOUBLE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* size = GL_BGRA and normalized = GL_FALSE */
+	glVertexAttribFormat(0, GL_BGRA, GL_UNSIGNED_BYTE, GL_FALSE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* Types not allowed when size = GL_BGRA */
+	{
+		const GLenum types[] = {
+			GL_BYTE,
+			GL_SHORT, GL_UNSIGNED_SHORT,
+			GL_INT, GL_UNSIGNED_INT,
+			GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE,
+			GL_FIXED
+		};
+
+		for (i = 0; i < sizeof(types) / sizeof(types[0]); i++) {
+			glVertexAttribFormat(0, GL_BGRA, types[i], GL_TRUE, 0);
+			if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+				piglit_report_result(PIGLIT_FAIL);
+		}
+	}
+
+
+	/* type = GL_UNSIGNED_INT_2_10_10_10_REV or GL_INT_2_10_10_10_REV, and size != 4 or GL_BGRA */
+	for (i = 1; i < 3; i++) {
+		glVertexAttribFormat(0, i, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0);
+		if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glVertexAttribFormat(0, i, GL_INT_2_10_10_10_REV, GL_TRUE, 0);
+		if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+
+
+	/* GL_BGRA is not allowed with glVertexAttribIFormat() or glVertexAttribLFormat() */
+	glVertexAttribIFormat(0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glVertexAttribLFormat(0, GL_BGRA, GL_DOUBLE, 0);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	/* Types not allowed with glVertexAttribIFormat() */
+	{
+		const GLenum types[] = {
+			GL_FIXED, GL_FLOAT, GL_HALF_FLOAT, GL_DOUBLE,
+			GL_UNSIGNED_INT_2_10_10_10_REV,
+			GL_INT_2_10_10_10_REV
+		};
+
+		for (i = 0; i < sizeof(types) / sizeof(types[0]); i++) {
+			glVertexAttribIFormat(0, 4, types[i], 0);
+			if (!piglit_check_gl_error(GL_INVALID_ENUM))
+				piglit_report_result(PIGLIT_FAIL);
+		}
+	}
+
+
+	/* Types not allowed with glVertexAttribLFormat() */
+	{
+		const GLenum types[] = {
+			GL_BYTE, GL_UNSIGNED_BYTE,
+			GL_SHORT, GL_UNSIGNED_SHORT,
+			GL_INT, GL_UNSIGNED_INT,
+			GL_FIXED, GL_FLOAT, GL_HALF_FLOAT,
+			GL_UNSIGNED_INT_2_10_10_10_REV,
+			GL_INT_2_10_10_10_REV
+		};
+
+		for (i = 0; i < sizeof(types) / sizeof(types[0]); i++) {
+			glVertexAttribLFormat(0, 4, types[i], 0);
+			if (!piglit_check_gl_error(GL_INVALID_ENUM))
+				piglit_report_result(PIGLIT_FAIL);
+		}
+	}
+
+
+	piglit_report_result(PIGLIT_PASS);
+}
-- 
1.7.10.4



More information about the Piglit mailing list