[Piglit] [PATCH V2] gl-4.4: Test GL_MAX_VERTEX_ATTRIB_STRIDE

Timothy Arceri t_arceri at yahoo.com.au
Thu Aug 14 15:28:15 PDT 2014


V2: changed to -> too

Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
---
 tests/all.py                                    |   1 +
 tests/spec/CMakeLists.txt                       |   1 +
 tests/spec/gl-4.4/CMakeLists.gl.txt             |  14 +++
 tests/spec/gl-4.4/CMakeLists.txt                |   1 +
 tests/spec/gl-4.4/gl_max_vertex_attrib_stride.c | 140 ++++++++++++++++++++++++
 5 files changed, 157 insertions(+)
 create mode 100644 tests/spec/gl-4.4/CMakeLists.gl.txt
 create mode 100644 tests/spec/gl-4.4/CMakeLists.txt
 create mode 100644 tests/spec/gl-4.4/gl_max_vertex_attrib_stride.c

diff --git a/tests/all.py b/tests/all.py
index 4541654..858bec6 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -976,6 +976,7 @@ spec['!OpenGL 3.3/required-texture-attachment-formats'] = concurrent_test('gl-3.
 spec['!OpenGL 4.2/required-renderbuffer-attachment-formats'] = concurrent_test('gl-3.0-required-renderbuffer-attachment-formats 42')
 spec['!OpenGL 4.2/required-sized-texture-formats'] = concurrent_test('gl-3.0-required-sized-texture-formats 42')
 spec['!OpenGL 4.2/required-texture-attachment-formats'] = concurrent_test('gl-3.0-required-texture-attachment-formats 42')
+spec['!OpenGL 4.4/gl-max-vertex-attrib-stride'] = concurrent_test('gl-4.4-max_vertex_attrib_stride')
 
 # Group spec/glsl-es-1.00
 spec['glsl-es-1.00'] = {}
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 5148412..a73c4cb 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -93,6 +93,7 @@ add_subdirectory (gl-3.0)
 add_subdirectory (gl-3.1)
 add_subdirectory (gl-3.2)
 add_subdirectory (gl-3.3)
+add_subdirectory (gl-4.4)
 add_subdirectory (gles-2.0)
 add_subdirectory (gles-3.0)
 add_subdirectory (glx_arb_create_context)
diff --git a/tests/spec/gl-4.4/CMakeLists.gl.txt b/tests/spec/gl-4.4/CMakeLists.gl.txt
new file mode 100644
index 0000000..3287f85
--- /dev/null
+++ b/tests/spec/gl-4.4/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 (gl-4.4-max_vertex_attrib_stride gl_max_vertex_attrib_stride.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/gl-4.4/CMakeLists.txt b/tests/spec/gl-4.4/CMakeLists.txt
new file mode 100644
index 0000000..4a012b9
--- /dev/null
+++ b/tests/spec/gl-4.4/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
\ No newline at end of file
diff --git a/tests/spec/gl-4.4/gl_max_vertex_attrib_stride.c b/tests/spec/gl-4.4/gl_max_vertex_attrib_stride.c
new file mode 100644
index 0000000..2f62281
--- /dev/null
+++ b/tests/spec/gl-4.4/gl_max_vertex_attrib_stride.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2014 Timothy Arceri <t_arceri at yahoo.com.au>
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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
+ * NON-INFRINGEMENT.  IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
+ * 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"
+#include "minmax-test.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 44;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static bool check_invalid_stride(char *function)
+{
+	bool pass = true;
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+		fprintf(stderr, "GL_INVALID_VALUE should be generated when setting"
+			" %s stride too value large than MAX_VERTEX_ATTRIB_STRIDE\n",
+                        function);
+		pass = false;
+	}
+
+	return pass;
+}
+
+static bool test_stride_too_large_vertex_attribl(GLint stride_max_plus_one)
+{
+	GLdouble vertices[4][4];
+
+	glVertexAttribLPointer(0, 4, GL_DOUBLE, stride_max_plus_one, vertices);
+
+	return check_invalid_stride("glVertexAttribLPointer");
+}
+
+static bool test_stride_too_large_vertex_attribi(GLint stride_max_plus_one)
+{
+	GLuint vertices[4][4];
+
+	glVertexAttribIPointer(0, 4, GL_UNSIGNED_INT,
+			       stride_max_plus_one, vertices);
+
+	return check_invalid_stride("glVertexAttribIPointer");
+}
+
+static bool test_stride_too_large_vertex_attrib(GLint stride_max_plus_one)
+{
+	GLfloat vertices[4][4];
+
+	glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE,
+			      stride_max_plus_one, vertices);
+
+	return check_invalid_stride("glVertexAttribPointer");
+}
+
+static bool test_stride_too_large_bind_buffers(GLint stride_max_plus_one)
+{
+	GLint strides[2];
+	GLuint buf[2];
+	GLintptr offsets[2] = { 1024, 1024 };
+
+	glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &strides[0]);
+	strides[1] = stride_max_plus_one;
+
+	/* Create buffer objects */
+	glGenBuffers(2, buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf[0]);
+	glBindBuffer(GL_ARRAY_BUFFER, buf[1]);
+
+	/* Try passing a stride value that is to large */
+	glBindVertexBuffers(0, 2, buf, offsets, strides);
+
+	return check_invalid_stride("glBindVertexBuffers");
+}
+
+static bool test_stride_too_large_bind_buffer(GLint stride_max_plus_one)
+{
+	GLuint vbo;
+
+	/* Create a buffer object */
+	glGenBuffers(1, &vbo);
+	glBindBuffer(GL_ARRAY_BUFFER, vbo);
+
+	/* Try passing a stride value that is to large */
+	glBindVertexBuffer(0, vbo, 1024, stride_max_plus_one);
+
+	return check_invalid_stride("glBindVertexBuffer");
+}
+
+void piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+	GLint stride_max_plus_one;
+	GLuint vao;
+
+	/* Create and bind a vertex array object, this is needed
+	   for glBindBuffer* tests */
+	glGenVertexArrays(1, &vao);
+	glBindVertexArray(vao);
+
+	glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &stride_max_plus_one);
+	stride_max_plus_one++;
+
+	piglit_test_min_int(GL_MAX_VERTEX_ATTRIB_STRIDE, 2048);
+	pass = piglit_minmax_pass;
+	pass = test_stride_too_large_bind_buffer(stride_max_plus_one) && pass;
+	pass = test_stride_too_large_bind_buffers(stride_max_plus_one) && pass;
+	pass = test_stride_too_large_vertex_attrib(stride_max_plus_one) && pass;
+	pass = test_stride_too_large_vertex_attribi(stride_max_plus_one) && pass;
+	pass = test_stride_too_large_vertex_attribl(stride_max_plus_one) && pass;
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_PASS;
+}
-- 
1.9.3



More information about the Piglit mailing list