<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">All I want for Christmas is a review. Thanks.<br><br><div class="gmail_quote">On Wed, Dec 5, 2012 at 12:04 PM, Frank Henigman <span dir="ltr"><<a href="mailto:fjhenigman@google.com" target="_blank">fjhenigman@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">v3<br>
Removed write/read/verify uniform test and renamed variables per<br>
reviewer comments.<br>
<br>
<br>
Check for consistent reporting of active array elements from<br>
glGetActiveUniform and glGetUniformLocation.<br>
Check for correct error reporting when reading/writing bogus<br>
uniform locations.<br>
---<br>
tests/all.tests | 1 +<br>
tests/shaders/CMakeLists.gl.txt | 1 +<br>
tests/shaders/glsl-uniform-out-of-bounds-2.c | 151 ++++++++++++++++++++++++++<br>
3 files changed, 153 insertions(+), 0 deletions(-)<br>
create mode 100644 tests/shaders/glsl-uniform-out-of-bounds-2.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 9723b4d..b49722b 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -239,6 +239,7 @@ add_plain_test(shaders, 'glsl-novertexdata')<br>
add_plain_test(shaders, 'glsl-preprocessor-comments')<br>
add_plain_test(shaders, 'glsl-reload-source')<br>
add_plain_test(shaders, 'glsl-uniform-out-of-bounds')<br>
+add_concurrent_test(shaders, 'glsl-uniform-out-of-bounds-2')<br>
add_plain_test(shaders, 'glsl-uniform-update')<br>
add_plain_test(shaders, 'glsl-unused-varying')<br>
add_plain_test(shaders, 'glsl-fs-bug25902')<br>
diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt<br>
index 6ac0230..93cbf7b 100644<br>
--- a/tests/shaders/CMakeLists.gl.txt<br>
+++ b/tests/shaders/CMakeLists.gl.txt<br>
@@ -66,6 +66,7 @@ piglit_add_executable (glsl-reload-source glsl-reload-source.c)<br>
piglit_add_executable (glsl-unused-varying glsl-unused-varying.c)<br>
piglit_add_executable (glsl-uniform-update glsl-uniform-update.c)<br>
piglit_add_executable (glsl-uniform-out-of-bounds glsl-uniform-out-of-bounds.c)<br>
+piglit_add_executable (glsl-uniform-out-of-bounds-2 glsl-uniform-out-of-bounds-2.c)<br>
piglit_add_executable (glsl-fs-bug25902 glsl-fs-bug25902.c)<br>
piglit_add_executable (glsl-fs-color-matrix glsl-fs-color-matrix.c)<br>
piglit_add_executable (glsl-fs-exp2 glsl-fs-exp2.c)<br>
diff --git a/tests/shaders/glsl-uniform-out-of-bounds-2.c b/tests/shaders/glsl-uniform-out-of-bounds-2.c<br>
new file mode 100644<br>
index 0000000..dfe287a<br>
--- /dev/null<br>
+++ b/tests/shaders/glsl-uniform-out-of-bounds-2.c<br>
@@ -0,0 +1,151 @@<br>
+/*<br>
+ * Copyright 2012 Google Inc.<br>
+ *<br>
+ * This library is free software; you can redistribute it and/or<br>
+ * modify it under the terms of the GNU Lesser General Public<br>
+ * License as published by the Free Software Foundation; either<br>
+ * version 2.1 of the License, or (at your option) any later version.<br>
+ *<br>
+ * This library is distributed in the hope that it will be useful,<br>
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>
+ * Lesser General Public License for more details.<br>
+ *<br>
+ * You should have received a copy of the GNU Lesser General Public<br>
+ * License along with this library; if not, write to the Free Software<br>
+ * Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA<br>
+ */<br>
+<br>
+/**<br>
+ * \file glsl-uniform-out-of-bounds-2.c<br>
+ *<br>
+ * glGetUniformLocation should return:<br>
+ * -1 for inactive array elements (as reported by glGetActiveUniform)<br>
+ * not -1 for active array elements (as reported by glGetActiveUniform)<br>
+ * -1 for non-existent array elements (indices outside the array)<br>
+ *<br>
+ * Write and read some invalid locations and check for GL_INVALID_OPERATION.<br>
+ *<br>
+ * \author Frank Henigman <<a href="mailto:fjhenigman@google.com" target="_blank">fjhenigman@google.com</a>><br>
+ */<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 10;<br>
+<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ /* unreached */<br>
+ return PIGLIT_FAIL;<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ GLint prog;<br>
+ GLint vs, fs;<br>
+ int i, j, k;<br>
+ bool pass = true;<br>
+ GLint num_active_uniform;<br>
+ GLint min = -1, max = -1;<br>
+ GLint bogus[99];<br>
+ int num_bogus = 0;<br>
+<br>
+ piglit_require_gl_version(20);<br>
+<br>
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER,<br>
+ "attribute vec4 p;\n"<br>
+ "void main() { gl_Position = p; }\n"<br>
+ );<br>
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER,<br>
+ "uniform vec4 v[4];\n"<br>
+ "uniform mat4 m[4];\n"<br>
+ "void main() { gl_FragColor = v[1] + m[1][1]; }\n"<br>
+ );<br>
+<br>
+ prog = piglit_link_simple_program(vs, fs);<br>
+ glUseProgram(prog);<br>
+ glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &num_active_uniform);<br>
+ printf("active uniforms %d\n", num_active_uniform);<br>
+<br>
+ // for each array in shader<br>
+ for (k = 0; k < num_active_uniform; ++k) {<br>
+ GLchar name[99];<br>
+ GLint num_active_elements;<br>
+ GLenum type;<br>
+ glGetActiveUniform(prog, k, ARRAY_SIZE(name), NULL,<br>
+ &num_active_elements, &type, name);<br>
+ if (!((name[0] == 'v' || name[0] == 'm') && name[1] == 0))<br>
+ continue;<br>
+ printf("array '%s' active elements %d\n", name, num_active_elements);<br>
+<br>
+ // for each index in array, plus some before and after<br>
+ for (i = -2; i < 6; ++i) {<br>
+ bool is_active = 0 <= i && i < num_active_elements;<br>
+ GLchar element[9];<br>
+ GLint loc;<br>
+ sprintf(element, "%s[%d]", name, i);<br>
+ loc = glGetUniformLocation(prog, element);<br>
+<br>
+ // does glGetUniformLocation agree with glGetActiveUniform?<br>
+ if (loc == -1) {<br>
+ if (is_active) {<br>
+ printf("FAIL: no location for active %s\n", element);<br>
+ pass = false;<br>
+ }<br>
+ } else {<br>
+ if (!is_active) {<br>
+ printf("FAIL: got location for inactive %s\n", element);<br>
+ pass = false;<br>
+ }<br>
+<br>
+ // keep track of location min/max<br>
+ if (min == -1 || loc < min)<br>
+ min = loc;<br>
+ if (max == -1 || loc > max)<br>
+ max = loc;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ // make up some bogus locations<br>
+ for (i = 1; i < 6; ++i) {<br>
+ bogus[num_bogus++] = min - i;<br>
+ bogus[num_bogus++] = max + i;<br>
+ // mesa encodes the uniform variable in the upper 16 bits<br>
+ // of a location and puts the array index in the lower 16<br>
+ bogus[num_bogus++] = max + (1<<16) + i - 3;<br>
+ }<br>
+<br>
+ // test writing and reading bogus locations<br>
+ for (i = 0; i < num_bogus; ++i) {<br>
+ GLfloat v[16];<br>
+ if (bogus[i] == -1)<br>
+ continue;<br>
+ printf("trying bogus location %d\n", bogus[i]);<br>
+ glUniform4fv(bogus[i], 1, v);<br>
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {<br>
+ printf("FAIL: wrote vector to bogus location\n");<br>
+ pass = false;<br>
+ }<br>
+ glUniformMatrix4fv(bogus[i], 1, GL_FALSE, v);<br>
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {<br>
+ printf("FAIL: wrote matrix to bogus location\n");<br>
+ pass = false;<br>
+ }<br>
+ glGetUniformfv(prog, bogus[i], v);<br>
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {<br>
+ printf("FAIL: read from bogus location\n");<br>
+ pass = false;<br>
+ }<br>
+ }<br>
+<br>
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
<span><font color="#888888">--<br>
1.7.7.3<br>
<br>
</font></span></blockquote></div><br>
</div>