[Piglit] [PATCH] new test : glsl-max-vertex-attrib.c

tapani.palli at intel.com tapani.palli at intel.com
Mon May 23 23:58:04 PDT 2011


From: Tapani Pälli <tapani.palli at intel.com>

Queries the value for GL_MAX_VERTEX_ATTRIBS and uses that as index
to set a value with various functions. GL specification states that
GL_INVALID_VALUE should occur if index >= GL_MAX_VERTEX_ATTRIBS.

Refactored (no shader needed for this) and cleaned up the code + added
missing copyright header.

---
 tests/all.tests                        |    1 +
 tests/shaders/CMakeLists.gl.txt        |    1 +
 tests/shaders/glsl-max-vertex-attrib.c |   92 ++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 0 deletions(-)
 create mode 100644 tests/shaders/glsl-max-vertex-attrib.c

diff --git a/tests/all.tests b/tests/all.tests
index 561fc42..ffeb67a 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -408,6 +408,7 @@ add_plain_test(shaders, 'glsl-link-initializer-06')
 add_plain_test(shaders, 'glsl-link-invariant-01')
 add_plain_test(shaders, 'glsl-link-centroid-01')
 add_plain_test(shaders, 'glsl-link-struct-array')
+add_plain_test(shaders, 'glsl-max-vertex-attrib')
 add_plain_test(shaders, 'glsl-kwin-blur-1')
 add_plain_test(shaders, 'glsl-kwin-blur-2')
 add_plain_test(shaders, 'gpu_shader4_attribs')
diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt
index cf9e3e9..3fcd4ca 100644
--- a/tests/shaders/CMakeLists.gl.txt
+++ b/tests/shaders/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ link_libraries (
 	${GLUT_glut_LIBRARY}
 )
 
+add_executable (glsl-max-vertex-attrib glsl-max-vertex-attrib.c)
 add_executable (activeprogram-bad-program activeprogram-bad-program.c)
 add_executable (activeprogram-get activeprogram-get.c)
 add_executable (ati-fs-bad-delete ati-fs-bad-delete.c)
diff --git a/tests/shaders/glsl-max-vertex-attrib.c b/tests/shaders/glsl-max-vertex-attrib.c
new file mode 100644
index 0000000..d8cdcc3
--- /dev/null
+++ b/tests/shaders/glsl-max-vertex-attrib.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2010 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 glsl-max-vertex-attrib.c
+ * Test setting vertex attrib value of GL_MAX_VERTEX_ATTRIBS attrib
+ *
+ * Queries the value for GL_MAX_VERTEX_ATTRIBS and uses that as index
+ * to set a value. GL specification states that GL_INVALID_VALUE should
+ * occur if index >= GL_MAX_VERTEX_ATTRIBS.
+ *
+ * \author Sun Yi <yi.sun at intel.com>
+ * \author Tapani Pälli <tapani.palli at intel.com>
+ */
+
+#include "piglit-util.h"
+#include "piglit-framework.h"
+
+int piglit_window_mode = GLUT_RGB;
+int piglit_width = 250, piglit_height = 250;
+
+#define CHECK_GL_INVALID_VALUE if (glGetError() != GL_INVALID_VALUE) return PIGLIT_FAIL;
+
+enum piglit_result piglit_display(void)
+{
+	int attribCount;
+
+	GLfloat floatv[] = { 1.0, 1.0, 1.0, 1.0 };
+	GLfloat quad[] = { -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0 };
+
+	glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribCount);
+
+	glVertexAttrib1f(attribCount, floatv[0]);
+	CHECK_GL_INVALID_VALUE;
+
+	glVertexAttrib2f(attribCount, floatv[0], floatv[1]);
+	CHECK_GL_INVALID_VALUE;
+
+	glVertexAttrib3f(attribCount, floatv[0], floatv[1], floatv[2]);
+	CHECK_GL_INVALID_VALUE;
+
+	glVertexAttrib4f(attribCount, floatv[0], floatv[1], floatv[2],
+			 floatv[3]);
+	CHECK_GL_INVALID_VALUE;
+
+	glVertexAttrib1fv(attribCount, floatv);
+	CHECK_GL_INVALID_VALUE;
+
+	glVertexAttrib2fv(attribCount, floatv);
+	CHECK_GL_INVALID_VALUE;
+
+	glVertexAttrib3fv(attribCount, floatv);
+	CHECK_GL_INVALID_VALUE;
+
+	glVertexAttrib4fv(attribCount, floatv);
+	CHECK_GL_INVALID_VALUE;
+
+	glVertexAttribPointer(attribCount, 2, GL_FLOAT, GL_FALSE, 0, quad);
+	CHECK_GL_INVALID_VALUE;
+
+	return PIGLIT_PASS;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	if (!GLEW_VERSION_2_0) {
+		printf("Requires OpenGL 2.0\n");
+		piglit_report_result(PIGLIT_SKIP);
+		exit(1);
+	}
+}
-- 
1.7.5.1

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


More information about the Piglit mailing list