<div dir="ltr">On 21 October 2013 16:04, Nicholas Mack <span dir="ltr"><<a href="mailto:nichmack@gmail.com" target="_blank">nichmack@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">
v2: Add checks to also test invalid names<br>
---<br>
tests/all.tests | 1 +<br>
tests/spec/glsl-1.50/execution/CMakeLists.gl.txt | 1 +<br>
.../interface-blocks-api-access-members.c | 173 +++++++++++++++++++++<br>
3 files changed, 175 insertions(+)<br>
create mode 100644 tests/spec/glsl-1.50/execution/interface-blocks-api-access-members.c<br></blockquote><div><br></div><div>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>
diff --git a/tests/all.tests b/tests/all.tests<br>
index c919f19..d2e685c 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -966,6 +966,7 @@ import_glsl_parser_tests(spec['glsl-1.50'],<br>
add_shader_test_dir(spec['glsl-1.50'],<br>
os.path.join(testsDir, 'spec', 'glsl-1.50'),<br>
recursive=True)<br>
+spec['glsl-1.50']['execution']['interface-blocks-api-access-members'] = concurrent_test('glsl-1.50-interface-blocks-api-access-members')<br>
spec['glsl-1.50']['execution']['get-active-attrib-array'] = concurrent_test('glsl-1.50-get-active-attrib-array')<br>
spec['glsl-1.50']['execution']['vs-input-arrays'] = concurrent_test('glsl-1.50-vs-input-arrays')<br>
spec['glsl-1.50']['execution']['vs-named-block-no-modify'] = concurrent_test('glsl-1.50-vs-named-block-no-modify')<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 693f69a..114867b 100644<br>
--- a/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt<br>
+++ b/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt<br>
@@ -13,3 +13,4 @@ ${OPENGL_glu_LIBRARY}<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>
piglit_add_executable (glsl-1.50-vs-named-block-no-modify vs-named-block-no-modify.c)<br>
+piglit_add_executable (glsl-1.50-interface-blocks-api-access-members interface-blocks-api-access-members.c)<br>
diff --git a/tests/spec/glsl-1.50/execution/interface-blocks-api-access-members.c b/tests/spec/glsl-1.50/execution/interface-blocks-api-access-members.c<br>
new file mode 100644<br>
index 0000000..77089f8<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/interface-blocks-api-access-members.c<br>
@@ -0,0 +1,173 @@<br>
+/**<br>
+ * Copyright © 2013 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>
+ * Test the syntax for accessing interface block members through the API<br>
+ *<br>
+ * From the GLSL 1.50 core spec, section 4.3.7 (Interface Blocks):<br>
+ * "Outside the shading language (i.e., in the API), members are similarly<br>
+ * identified except the block name is always used in place of the instance<br>
+ * name (API accesses are to interfaces, not to shaders). If there is no<br>
+ * instance name, then the API does not use the block name to access a member,<br>
+ * just the member name."<br>
+ *<br>
+ * "For blocks declared as arrays, the array index must also be included when<br>
+ * accessing members"<br>
+ */<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 32;<br>
+ config.supports_gl_core_version = 32;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static const char *vstext =<br>
+ "#version 150\n"<br>
+ "in vec4 vertex;\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = vertex;\n"<br>
+ "}\n";<br>
+<br>
+static const char *gstext =<br>
+ "#version 150\n"<br>
+ "layout(points) in;\n"<br>
+ "layout(points, max_vertices = 3) out;\n"<br>
+ "out NoInst {\n"<br>
+ " float a;\n"<br>
+ " vec3 b;\n"<br>
+ "};\n"<br>
+ "out WithInst {\n"<br>
+ " float c;\n"<br>
+ " vec3 d;\n"<br>
+ "} inst;\n"<br>
+ "out WithInstArray {\n"<br>
+ " float e;\n"<br>
+ " vec3 f;\n"<br>
+ "} instArray[3];\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " a = 1.0;\n"<br>
+ " b = vec3(2.0);\n"<br>
+ " inst.c = 3.0;\n"<br>
+ " inst.d = vec3(4.0);\n"<br>
+ " for(int i = 0; i < 3; i++) {\n"<br>
+ " instArray[i].e = 5.0 + 2 * i;\n"<br>
+ " instArray[i].f = vec3(6.0 + 2 * i);\n"<br>
+ " }\n"<br>
+ "}\n";<br>
+<br>
+static GLuint prog;<br>
+<br>
+static const char *valid_varying_names[] = {<br>
+ /* correct names to access block members */<br>
+ "a", "b",<br>
+ "WithInst.c", "WithInst.d",<br>
+ "WithInstArray[0].e", "WithInstArray[0].f",<br>
+ "WithInstArray[1].e", "WithInstArray[1].f",<br>
+ "WithInstArray[2].e", "WithInstArray[2].f"<br>
+};<br>
+<br>
+static const char *invalid_varying_names[] = {<br>
+ /* incorrect names to access block members */<br>
+ "c", "d",<br>
+ "inst.c", "inst.d",<br>
+ "e", "f",<br>
+ "instArray.e", "instArray.f",<br>
+ "WithInstArray.e", "WithInstArray.f",<br>
+ "instArray[0].e", "instArray[0].f",<br>
+ "instArray[1].e", "instArray[1].f",<br>
+ "instArray[2].e", "instArray[2].f"<br>
+};<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ bool pass = true;<br>
+ GLuint vs = 0, gs = 0;<br>
+ int i;<br>
+<br>
+ prog = glCreateProgram();<br>
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);<br>
+ gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gstext);<br>
+ glAttachShader(prog, vs);<br>
+ glAttachShader(prog, gs);<br>
+<br>
+ /* check that invalid_varying_names fail to link */<br>
+ for (i = 0; i < ARRAY_SIZE(invalid_varying_names); i++) {<br>
+ glTransformFeedbackVaryings(prog,<br>
+ 1,<br>
+ &invalid_varying_names[i],<br>
+ GL_INTERLEAVED_ATTRIBS);<br>
+ glLinkProgram(prog);<br>
+ if (piglit_link_check_status(prog)) {<br>
+ printf("%s is not valid but it was allowed.\n",<br>
+ invalid_varying_names[i]);<br>
+ pass = false;<br>
+ }<br>
+ }<br>
+<br>
+ /* check that valid_varying_names link properly */<br>
+ glTransformFeedbackVaryings(prog,<br>
+ ARRAY_SIZE(valid_varying_names),<br>
+ valid_varying_names,<br>
+ GL_INTERLEAVED_ATTRIBS);<br>
+ glLinkProgram(prog);<br>
+ if (!piglit_link_check_status(prog)) {<br>
+ glDeleteProgram(prog);<br>
+ printf("Transform feedback varyings failed to link properly"<br>
+ " with valid names.\n");<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+ }<br>
+<br>
+ glUseProgram(prog);<br>
+<br>
+ for (i = 0; i < ARRAY_SIZE(valid_varying_names); i++) {<br>
+ char varName[50];<br>
+ GLsizei nameLength = 0, varSize = 0;<br>
+ GLenum varType = GL_NONE;<br>
+ glGetTransformFeedbackVarying( prog,<br>
+ i,<br>
+ sizeof(varName),<br>
+ &nameLength,<br>
+ &varSize,<br>
+ &varType,<br>
+ varName);<br>
+ printf("Name: %s\t\tType: %s\n",<br>
+ varName, piglit_get_gl_enum_name(varType));<br>
+ }<br>
+<br>
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+<br>
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ /* DIES IN A FIRE */<br>
+ return 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>