<div dir="ltr">On 1 August 2013 15:52, Jacob Penner <span dir="ltr"><<a href="mailto:jkpenner91@gmail.com" target="_blank">jkpenner91@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Test the size returned from glGetActiveAttrib is correct<br>
for arrays of various sizes.<br>
<br>
Version 2: restructured code and syntax fixes.<br></blockquote><div><br></div><div>Thanks for making the fixes.  Sorry I didn't get to reviewing this earlier.<br><br></div><div>A few lines in this file have extraneous trailing whitespace.  Also, the new test needs to be added to all.tests.<br>
<br></div><div>With those to things fixed, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

---<br>
 tests/spec/glsl-1.50/execution/CMakeLists.gl.txt   |   1 +<br>
 .../glsl-1.50/execution/get-active-attrib-array.c  | 140 +++++++++++++++++++++<br>
 2 files changed, 141 insertions(+)<br>
 create mode 100644 tests/spec/glsl-1.50/execution/get-active-attrib-array.c<br>
<br>
diff --git a/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt b/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt<br>
index 80c6b42..67a5e00 100644<br>
--- a/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt<br>
+++ b/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt<br>
@@ -11,3 +11,4 @@ ${OPENGL_glu_LIBRARY}<br>
 )<br>
<br>
 piglit_add_executable (glsl-1.50-vs-input-arrays vs-input-arrays.c)<br>
+piglit_add_executable (glsl-1.50-get-active-attrib-array get-active-attrib-array.c)<br>
diff --git a/tests/spec/glsl-1.50/execution/get-active-attrib-array.c b/tests/spec/glsl-1.50/execution/get-active-attrib-array.c<br>
new file mode 100644<br>
index 0000000..b900ef4<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/get-active-attrib-array.c<br>
@@ -0,0 +1,140 @@<br>
+/*<br>
+ * Copyright © 2012 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/*<br>
+ * Check that glGetActiveAttrib returns the correct size values,<br>
+ * for arrays of various sizes.<br>
+ */<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+       config.supports_gl_core_version = 32;<br>
+       config.supports_gl_compat_version = 32;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static const char *vs_source =<br>
+       "#version 150\n"<br>
+       "in int a[1];\n"<br>
+       "in int b[2];\n"<br>
+       "in int c[3];\n"<br>
+       "in int d[4];\n"<br>
+       "in int e[5];\n"<br>
+       "\n"<br>
+       "out vec4 color;\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "       color = vec4(a[0] + b[0] + b[1],\n"<br>
+       "                    c[0] + c[1] + c[2],\n"<br>
+       "                    d[0] + d[1] + d[2] + d[3],\n"<br>
+       "                    e[0] + e[1] + e[2] + e[3] + e[4]);\n"<br>
+       "}\n";<br>
+<br>
+static const char *fs_source =<br>
+       "#version 150\n"<br>
+       "in vec4 color;\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "       gl_FragColor = color;\n"<br>
+       "}\n";<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       /* UNREACHED */<br>
+       return PIGLIT_FAIL;<br>
+}<br>
+<br>
+/*<br>
+ * Find the given attribute size then, check if the passed expected size<br>
+ * is equal to the actual size.<br>
+ */<br>
+bool<br>
+getAttribLocTest(GLint program, int active_attribs, int max_name_length,<br>
+               char *attrib_name, int expected_size)<br>
+{<br>
+       bool pass = true;<br>
+       int size = -1;<br>
+       GLenum type = GL_NONE;<br>
+       char *name = malloc(max_name_length-1);<br>
+<br>
+       int i;<br>
+       for(i = 0; i < active_attribs; i++) {<br>
+               glGetActiveAttrib(program, i, max_name_length,<br>
+                                 NULL, &size, &type, name);<br>
+<br>
+               if(strcmp(attrib_name, name) == 0) {<br>
+                       break;<br>
+               }<br>
+       }<br>
+<br>
+       /* Check if no attrib was found */<br>
+       if(i == active_attribs) {<br>
+               pass = false;<br>
+               printf("Attribute '%s' not found\n", attrib_name);<br>
+       }<br>
+<br>
+       /* Check for non-matching sizes */<br>
+       if(size != expected_size) {<br>
+               pass = false;<br>
+               printf("Attribute '%s': size %d; expected %d\n",<br>
+                       name, size, expected_size);<br>
+       }<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       bool pass = true;<br>
+<br>
+       GLint prog = 0;<br>
+<br>
+       GLint active_attribs = 0;<br>
+       GLint max_length = 0;<br>
+<br>
+       piglit_require_GLSL_version(150);<br>
+<br>
+       prog = piglit_build_simple_program(vs_source, fs_source);<br>
+       glUseProgram(prog);<br>
+<br>
+       glGetProgramiv(prog, GL_ACTIVE_ATTRIBUTES, &active_attribs);<br>
+       glGetProgramiv(prog, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_length);<br>
+<br>
+       /*<br>
+        * Check the size of the given attribute with the<br>
+        * corresponding expected array size.<br>
+        */<br>
+       pass = getAttribLocTest(prog, active_attribs, max_length, "a", 1) && pass;<br>
+       pass = getAttribLocTest(prog, active_attribs, max_length, "b", 2) && pass;<br>
+       pass = getAttribLocTest(prog, active_attribs, max_length, "c", 3) && pass;<br>
+       pass = getAttribLocTest(prog, active_attribs, max_length, "d", 4) && pass;<br>
+       pass = getAttribLocTest(prog, active_attribs, max_length, "e", 5) && pass;<br>
+<br>
+       glDeleteProgram(prog);<br>
+<br>
+       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.1<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>