summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/all.tests3
-rw-r--r--tests/shaders/CMakeLists.txt3
-rw-r--r--tests/shaders/glsl-getactiveuniform-array-size.c93
-rw-r--r--tests/shaders/glsl-getactiveuniform-array-size.vert8
-rw-r--r--tests/shaders/glsl-getactiveuniform-count.c77
-rw-r--r--tests/shaders/glsl-getactiveuniform-length.c109
-rw-r--r--tests/shaders/glsl-getactiveuniform-length.vert9
7 files changed, 302 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests
index 4f88ff663..352178ac4 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -239,6 +239,9 @@ add_shader_generic(shaders, 'glsl-deadcode-self-assign')
add_shader_generic(shaders, 'glsl-deadcode-varying')
add_plain_test(shaders, 'glsl-bindattriblocation')
add_plain_test(shaders, 'glsl-dlist-getattriblocation')
+add_plain_test(shaders, 'glsl-getactiveuniform-array-size')
+add_plain_test(shaders, 'glsl-getactiveuniform-count')
+add_plain_test(shaders, 'glsl-getactiveuniform-length')
add_plain_test(shaders, 'glsl-getattriblocation')
add_plain_test(shaders, 'glsl-novertexdata')
add_plain_test(shaders, 'glsl-preprocessor-comments')
diff --git a/tests/shaders/CMakeLists.txt b/tests/shaders/CMakeLists.txt
index ae4b9f2ee..6452bc799 100644
--- a/tests/shaders/CMakeLists.txt
+++ b/tests/shaders/CMakeLists.txt
@@ -51,6 +51,9 @@ add_executable (glsl-bindattriblocation glsl-bindattriblocation.c)
add_executable (glsl-bug-22603 glsl-bug-22603.c)
add_executable (glsl-dlist-getattriblocation glsl-dlist-getattriblocation.c)
add_executable (glsl-getattriblocation glsl-getattriblocation.c)
+add_executable (glsl-getactiveuniform-array-size glsl-getactiveuniform-array-size.c)
+add_executable (glsl-getactiveuniform-count glsl-getactiveuniform-count.c)
+add_executable (glsl-getactiveuniform-length glsl-getactiveuniform-length.c)
add_executable (glsl-novertexdata glsl-novertexdata.c)
add_executable (glsl-orangebook-ch06-bump glsl-orangebook-ch06-bump.c)
add_executable (glsl-reload-source glsl-reload-source.c)
diff --git a/tests/shaders/glsl-getactiveuniform-array-size.c b/tests/shaders/glsl-getactiveuniform-array-size.c
new file mode 100644
index 000000000..a630a86d4
--- /dev/null
+++ b/tests/shaders/glsl-getactiveuniform-array-size.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2009 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file glsl-vs-sqrt-zero.c
+ *
+ * Tests that sqrt(0.0) in the VS produces 0.0.
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static GLint prog;
+
+enum piglit_result
+piglit_display(void)
+{
+ /* unreached */
+ return PIGLIT_FAILURE;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLboolean pass = GL_TRUE;
+ GLint vs, fs, len;
+ char *name;
+ GLsizei size;
+ GLenum type;
+
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ vs = piglit_compile_shader(GL_VERTEX_SHADER,
+ "shaders/glsl-getactiveuniform-array-size.vert");
+ fs = piglit_compile_shader(GL_FRAGMENT_SHADER,
+ "shaders/glsl-color.frag");
+
+ prog = piglit_link_simple_program(vs, fs);
+
+ glGetProgramiv(prog, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len);
+ name = malloc(len + 20);
+
+ glGetActiveUniform(prog, 0, len + 20, &len, &size, &type, name);
+
+ /* From page 81 (page 89 of the PDF) of the OpenGL 2.1 specification:
+ *
+ * If one or more elements of an array are active,
+ * GetActiveUniform will return the name of the array in
+ * name, subject to the restrictions listed above. The
+ * type of the array is returned in type. The size
+ * parameter contains the highest array element index
+ * used, plus one.
+ */
+
+ if (size != 25) {
+ printf("Unexpected active uniform size "
+ "(saw %d, expected %d)\n", size, 25);
+ pass = GL_FALSE;
+ }
+
+ if (pass)
+ piglit_report_result(PIGLIT_SUCCESS);
+ else
+ piglit_report_result(PIGLIT_FAILURE);
+}
diff --git a/tests/shaders/glsl-getactiveuniform-array-size.vert b/tests/shaders/glsl-getactiveuniform-array-size.vert
new file mode 100644
index 000000000..ee5432c40
--- /dev/null
+++ b/tests/shaders/glsl-getactiveuniform-array-size.vert
@@ -0,0 +1,8 @@
+uniform vec4 color[50];
+uniform vec4 unused[100];
+
+void main()
+{
+ gl_Position = gl_Vertex;
+ gl_FrontColor = color[24];
+}
diff --git a/tests/shaders/glsl-getactiveuniform-count.c b/tests/shaders/glsl-getactiveuniform-count.c
new file mode 100644
index 000000000..cd9f0e427
--- /dev/null
+++ b/tests/shaders/glsl-getactiveuniform-count.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright © 2009 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file glsl-getactiveuniform-count.c
+ *
+ * Tests that glGetActiveUniform's maximum index is correctly reflected in
+ * GL_ACTIVE_UNIFORMS.
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static GLint prog;
+
+enum piglit_result
+piglit_display(void)
+{
+ /* unreached */
+ return PIGLIT_FAILURE;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLboolean pass = GL_TRUE;
+ GLint vs, fs, num;
+
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ vs = piglit_compile_shader(GL_VERTEX_SHADER,
+ "shaders/glsl-getactiveuniform-length.vert");
+ fs = piglit_compile_shader(GL_FRAGMENT_SHADER,
+ "shaders/glsl-color.frag");
+
+ prog = piglit_link_simple_program(vs, fs);
+
+ glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &num);
+ if (num != 1) {
+ printf("Unexpected active uniform length "
+ "(saw %d, expected 1)\n", num);
+ pass = GL_FALSE;
+ }
+
+ if (pass)
+ piglit_report_result(PIGLIT_SUCCESS);
+ else
+ piglit_report_result(PIGLIT_FAILURE);
+}
diff --git a/tests/shaders/glsl-getactiveuniform-length.c b/tests/shaders/glsl-getactiveuniform-length.c
new file mode 100644
index 000000000..241273fc8
--- /dev/null
+++ b/tests/shaders/glsl-getactiveuniform-length.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright © 2009 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file glsl-getactiveuniform-count.c
+ *
+ * Tests that glGetActiveUniform() has the uniform's string length correctly
+ * reflected in GL_ACTIVE_UNIFORM_MAX_LENGTH and the *length outvalue.
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static GLint prog;
+
+enum piglit_result
+piglit_display(void)
+{
+ /* unreached */
+ return PIGLIT_FAILURE;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLboolean pass = GL_TRUE;
+ GLint vs, fs, len, ret_len;
+ GLenum type;
+ char *name;
+ GLsizei size;
+
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ vs = piglit_compile_shader(GL_VERTEX_SHADER,
+ "shaders/glsl-getactiveuniform-length.vert");
+ fs = piglit_compile_shader(GL_FRAGMENT_SHADER,
+ "shaders/glsl-color.frag");
+
+ prog = piglit_link_simple_program(vs, fs);
+
+ /* From page 80 (page 88 of the PDF) of the OpenGL 2.1 specification:
+ *
+ * The actual number of characters written into name,
+ * excluding the null terminator, is returned in length.
+ *
+ * This describes the length outvalue of glGetActiveUniform().
+ * GL_ACTIVE_UNIFORM_MAX_LENGTH on the following page just
+ * says:
+ *
+ * The length of the longest uniform name in program is
+ * given by ACTIVE UNIFORM MAX LENGTH, which can be
+ * queried with GetProgramiv (see section 6.1.14).
+ */
+
+ glGetProgramiv(prog, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len);
+ if (len != strlen("color")) {
+ printf("Unexpected max active uniform length "
+ "(saw %d, expected %d)\n", len, strlen("color"));
+ pass = GL_FALSE;
+ }
+
+ /* From page 80 (page 88 of the PDF) of the OpenGL 2.1 specification:
+ *
+ * The actual number of characters written into name,
+ * excluding the null terminator, is returned in length.
+ */
+ name = malloc(len + 1);
+ glGetActiveUniform(prog, 0, len + 20, &ret_len, &size, &type, name);
+ if (ret_len != len) {
+ printf("Unexpected active uniform length "
+ "(saw %d, expected %d) for \"%s\"\n",
+ ret_len, len, name);
+ pass = GL_FALSE;
+ }
+
+
+ if (pass)
+ piglit_report_result(PIGLIT_SUCCESS);
+ else
+ piglit_report_result(PIGLIT_FAILURE);
+}
diff --git a/tests/shaders/glsl-getactiveuniform-length.vert b/tests/shaders/glsl-getactiveuniform-length.vert
new file mode 100644
index 000000000..04d93d581
--- /dev/null
+++ b/tests/shaders/glsl-getactiveuniform-length.vert
@@ -0,0 +1,9 @@
+/* Shared with glsl-getactiveuniform-length, glsl-getactiveuniform-count */
+uniform vec4 color[4];
+uniform vec4 totally_unused;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+ gl_FrontColor = color[1];
+}