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

tapani.palli at intel.com tapani.palli at intel.com
Sun May 22 23:06:30 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. GL specification states that GL_INVALID_VALUE should
occur if index >= GL_MAX_VERTEX_ATTRIBS.
---
 tests/all.tests                        |    1 +
 tests/shaders/CMakeLists.gl.txt        |    1 +
 tests/shaders/glsl-max-vertex-attrib.c |   72 ++++++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 tests/shaders/glsl-max-vertex-attrib.c

diff --git a/tests/all.tests b/tests/all.tests
index 19e2904..f9624cd 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -409,6 +409,7 @@ add_plain_test(shaders, 'glsl-link-centroid-01')
 add_plain_test(shaders, 'glsl-link-struct-array')
 add_plain_test(shaders, 'glsl-kwin-blur-1')
 add_plain_test(shaders, 'glsl-kwin-blur-2')
+add_plain_test(shaders, 'glsl-max-vertex-attrib')
 add_plain_test(shaders, 'gpu_shader4_attribs')
 add_plain_test(shaders, 'link-mismatch-layout-01')
 add_plain_test(shaders, 'link-mismatch-layout-02')
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..3eaf987
--- /dev/null
+++ b/tests/shaders/glsl-max-vertex-attrib.c
@@ -0,0 +1,72 @@
+/**
+ * \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;
+char test[255];
+
+const char *vs_code =
+    "attribute float VertexTemp;"
+    "void main()\n\0"
+    "{\n"
+    "    gl_Position = VertexTemp; // vec4(1.0,0.0,0.0,0.0);  //piglit_Position;\n"
+    "}\n";
+
+const char *fs_code =
+    "void main()\n"
+    "{\n"
+    "    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
+    "}\n";
+
+enum piglit_result piglit_display(void)
+{
+        int AttribCount;
+        int error = 0;
+        GLuint myProgram, myVertex, myFrag;
+
+        myVertex = glCreateShader(GL_VERTEX_SHADER);
+        myFrag = glCreateShader(GL_FRAGMENT_SHADER);
+        myProgram = glCreateProgram();
+
+        glAttachShader(myProgram, myVertex);
+        glAttachShader(myProgram, myFrag);
+
+        glShaderSource(myVertex, 1, (const GLchar**)&vs_code,NULL);
+        glShaderSource(myFrag, 1, (const GLchar**)&fs_code,NULL);
+
+        glCompileShader(myVertex);
+        glCompileShader(myFrag);
+        glLinkProgram(myProgram);
+
+        glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &AttribCount);
+        glVertexAttrib1f(AttribCount, 234.5);
+
+        error = glGetError();
+
+        /* we should get expected value of GL_INVALID_VALUE 0x501 */
+        return (error == GL_INVALID_VALUE) ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+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