<div dir="ltr">On 24 July 2013 15:02, Steve Miller <span dir="ltr"><<a href="mailto:dervishx@gmail.com" target="_blank">dervishx@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
* GLSLLangSpec.1.50.09 4.3.4 Inputs:<br>
* Vertex shader inputs can only be float, floating-point vectors, matrices,<br>
* signed and unsigned integers and integer vectors.Vertex shader inputs can<br>
* also form arrays of these types, but not structures.<br>
*<br>
* This test verifies basic functionality of vertex shader inputs using<br>
* arrays of float, int, and vec3 respectively<br></blockquote><div><br></div><div>As with the previous patch, I recommend rephrasing this to "Section 4.3.4 (Inputs) of the GLSL 1.50 spec says:" and removing the leading asterisks.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
tests/spec/CMakeLists.txt | 1 +<br>
tests/spec/glsl-1.50/CMakeLists.txt | 1 +<br>
tests/spec/glsl-1.50/execution/CMakeLists.gl.txt | 13 ++<br>
tests/spec/glsl-1.50/execution/CMakeLists.txt | 1 +<br>
tests/spec/glsl-1.50/execution/vs-input-arrays.c | 234 +++++++++++++++++++++++ <br></blockquote><div><br></div><div>Trailing whitespace in this file.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
5 files changed, 250 insertions(+)<br>
create mode 100644 tests/spec/glsl-1.50/CMakeLists.txt<br>
create mode 100644 tests/spec/glsl-1.50/execution/CMakeLists.gl.txt<br>
create mode 100644 tests/spec/glsl-1.50/execution/CMakeLists.txt<br>
create mode 100644 tests/spec/glsl-1.50/execution/vs-input-arrays.c<br></blockquote><div><br></div><div>I don't see any changes to tests/all.tests. That needs to be updated, otherwise the new test won't get run.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt<br>
index 1e17e33..7c5cdf5 100644<br>
--- a/tests/spec/CMakeLists.txt<br>
+++ b/tests/spec/CMakeLists.txt<br>
@@ -56,6 +56,7 @@ add_subdirectory (glsl-1.10)<br>
add_subdirectory (glsl-1.20)<br>
add_subdirectory (glsl-1.30)<br>
add_subdirectory (glsl-1.40)<br>
+add_subdirectory (glsl-1.50)<br>
add_subdirectory (glsl-es-3.00)<br>
add_subdirectory (gl-1.0)<br>
add_subdirectory (gl-2.0)<br>
diff --git a/tests/spec/glsl-1.50/CMakeLists.txt b/tests/spec/glsl-1.50/CMakeLists.txt<br>
new file mode 100644<br>
index 0000000..bb76f08<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/CMakeLists.txt<br>
@@ -0,0 +1 @@<br>
+add_subdirectory (execution)<br>
diff --git a/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt b/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt<br>
new file mode 100644<br>
index 0000000..80c6b42<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt<br>
@@ -0,0 +1,13 @@<br>
+include_directories(<br>
+${GLEXT_INCLUDE_DIR}<br>
+${OPENGL_INCLUDE_PATH}<br>
+${piglit_SOURCE_DIR}/tests/util<br>
+)<br>
+<br>
+link_libraries (<br>
+piglitutil_${piglit_target_api}<br>
+${OPENGL_gl_LIBRARY}<br>
+${OPENGL_glu_LIBRARY}<br>
+)<br>
+<br>
+piglit_add_executable (glsl-1.50-vs-input-arrays vs-input-arrays.c)<br>
diff --git a/tests/spec/glsl-1.50/execution/CMakeLists.txt b/tests/spec/glsl-1.50/execution/CMakeLists.txt<br>
new file mode 100644<br>
index 0000000..144a306<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/CMakeLists.txt<br>
@@ -0,0 +1 @@<br>
+piglit_include_target_api()<br>
diff --git a/tests/spec/glsl-1.50/execution/vs-input-arrays.c b/tests/spec/glsl-1.50/execution/vs-input-arrays.c<br>
new file mode 100644<br>
index 0000000..ba6d48b<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/vs-input-arrays.c<br>
@@ -0,0 +1,234 @@<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<br>
+ * DEALINGS IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/**<br>
+ * \file vs-input-arrays.c<br>
+ *<br>
+ * Test that vertex shader inputs can be arrays<br>
+ *<br>
+ * GLSLLangSpec.1.50.09 4.3.4 Inputs:<br>
+ * Vertex shader inputs can only be float, floating-point vectors, matrices,<br>
+ * signed and unsigned integers and integer vectors.Vertex shader inputs can<br>
+ * also form arrays of these types, but not structures.<br>
+ *<br>
+ * This test verifies basic functionality of vertex shader inputs using<br>
+ * arrays of float, int, and vec3 respectively<br>
+<br>
+<br>
+ *<br></blockquote><div><br></div><div>Blank space seems odd here. Did you intend to say more?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ * The test functions as follows:<br>
+ * Pass four different verts to VS, each with different values. Values increment<br>
+ * by one. VS uses gl_VertexID to test that each is (expected value +<br>
+ * gl_VertexID). VS emits a float, 0 for pass, 1 for fail. This is done because<br>
+ * bool cannot be sent as a varying, and using flat shading for sending an int<br>
+ * results in additional vertex info being discarded. FS draws GREEN if it<br>
+ * received the expeced 0 from the VS, RED if !0.<br>
+ */<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+ config.supports_gl_core_version = 32;<br>
+<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static const char vs_text[] =<br>
+ "#version 150\n"<br>
+ "\n"<br>
+ "in vec4 vertex;\n"<br>
+ "\n"<br>
+ "in float a[2];\n"<br>
+ "in int b[2];\n"<br>
+ "in vec3 c[2];\n"<br>
+ "\n"<br>
+ "out float i_failed;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = vertex;\n"<br>
+ "\n"<br>
+ " //check expected values against incoming\n"<br>
+ "\n"<br>
+ " bool failed = false;\n"<br>
+ "\n"<br>
+ " if( a[0] != 10.0 + float(gl_VertexID) ) failed = true;\n"<br>
+ " if( a[1] != 20.0 + float(gl_VertexID) ) failed = true;\n"<br>
+ "\n"<br>
+ " if( b[0] != 30 + gl_VertexID ) failed = true;\n"<br>
+ " if( b[1] != 40 + gl_VertexID ) failed = true;\n"<br>
+ "\n"<br>
+ " if( c[0].x != 1.0 + float(gl_VertexID) ) failed = true;\n"<br>
+ " if( c[0].y != 2.0 + float(gl_VertexID) ) failed = true;\n"<br>
+ " if( c[0].z != 3.0 + float(gl_VertexID) ) failed = true;\n"<br>
+ " if( c[1].x != 4.0 + float(gl_VertexID) ) failed = true;\n"<br>
+ " if( c[1].y != 5.0 + float(gl_VertexID) ) failed = true;\n"<br>
+ " if( c[1].z != 6.0 + float(gl_VertexID) ) failed = true;\n"<br>
+ " \n"<br>
+ " if (failed)\n"<br>
+ " i_failed = 1;\n"<br>
+ " else\n"<br>
+ " i_failed = 0;\n"<br>
+ "\n"<br>
+ "}\n";<br>
+<br>
+static const char fs_text[] =<br>
+ "#version 150\n"<br>
+ "\n"<br>
+ "in float i_failed;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ "\n"<br>
+ " bool failed = bool(i_failed);\n"<br>
+ "\n"<br>
+ " if (failed)\n"<br>
+ " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"<br>
+ " else\n"<br>
+ " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"<br>
+ "}\n";<br>
+<br>
+static GLuint prog;<br>
+<br>
+static GLuint vao;<br>
+static GLuint vbo;<br>
+<br>
+struct vertex_inputs {<br>
+ GLfloat vertex[3];<br></blockquote><div><br></div><div>Extra indentation here<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ GLfloat a[2];<br>
+ GLint b[2];<br>
+ GLfloat c[2][3];<br>
+} vertex_data[] = {<br>
+ { { -1.0, -1.0, 0.0 },<br>
+ { 10.0, 20.0 },<br>
+ { 30, 40 },<br>
+ { { 1.0, 2.0, 3.0 },<br>
+ { 4.0, 5.0, 6.0 } }<br>
+ },<br>
+<br>
+ { { -1.0, 1.0, 0.0 },<br>
+ { 11.0, 21.0 },<br>
+ { 31, 41 },<br>
+ { { 2.0, 3.0, 4.0 },<br>
+ { 5.0, 6.0, 7.0 } }<br>
+ },<br>
+<br>
+ { { 1.0, 1.0, 0.0 },<br>
+ { 12.0, 22.0 },<br>
+ { 32, 42 },<br>
+ { { 3.0, 4.0, 5.0 },<br>
+ { 6.0, 7.0, 8.0 } }<br>
+ },<br>
+<br>
+ { { 1.0, -1.0, 0.0 },<br>
+ { 13.0, 23.0 },<br>
+ { 33, 43 },<br>
+ { { 4.0, 5.0, 6.0 },<br>
+ { 7.0, 8.0, 9.0 } }<br>
+ }<br>
+};<br>
+<br>
+typedef struct vertex_inputs vertex_inputs;<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ prog = piglit_build_simple_program(vs_text, fs_text);<br>
+<br>
+ glLinkProgram( prog );<br>
+<br>
+ glUseProgram( prog );<br>
+<br>
+ glGenVertexArrays( 1, &vao );<br>
+ glBindVertexArray( vao );<br>
+<br>
+ /* stride */<br>
+ size_t stride = sizeof( vertex_data[0] );<br>
+<br>
+ /* get locations */<br>
+ GLint vertex_index = glGetAttribLocation( prog, "vertex" );<br>
+ GLint a_index = glGetAttribLocation( prog, "a" );<br>
+ GLint b_index = glGetAttribLocation( prog, "b" );<br>
+ GLint c_index = glGetAttribLocation( prog, "c" );<br>
+<br>
+ /* create buffers */<br>
+ glGenBuffers( 1, &vbo );<br>
+ glBindBuffer( GL_ARRAY_BUFFER, vbo );<br>
+ glBufferData( GL_ARRAY_BUFFER, sizeof( vertex_data ), &vertex_data,<br>
+ GL_STATIC_DRAW);<br>
+<br>
+ /* attrib pointers: */<br>
+ /* GLfloat vertex[3] */<br>
+ glVertexAttribPointer( vertex_index, 3, GL_FLOAT, GL_FALSE, stride,<br>
+ (void*) offsetof( vertex_inputs, vertex[0] ));<br>
+ /* GLfloat a[2] */<br>
+ glVertexAttribPointer( a_index, 1, GL_FLOAT, GL_FALSE, stride,<br>
+ (void*) offsetof( vertex_inputs, a[0] ));<br>
+ glVertexAttribPointer( a_index + 1, 1, GL_FLOAT, GL_FALSE, stride,<br>
+ (void*) offsetof( vertex_inputs, a[1] ));<br>
+ /* GLint b[2] */<br>
+ glVertexAttribIPointer( b_index, 1, GL_INT, stride,<br>
+ (void*) offsetof( vertex_inputs, b[0] ));<br>
+ glVertexAttribIPointer( b_index + 1, 1, GL_INT, stride,<br>
+ (void*) offsetof( vertex_inputs, b[1] ));<br>
+ /* GLfloat c[2][3] */<br>
+ glVertexAttribPointer( c_index, 3, GL_FLOAT, GL_FALSE, stride,<br>
+ (void*) offsetof( vertex_inputs, c[0] ));<br>
+ glVertexAttribPointer( c_index + 1, 3, GL_FLOAT, GL_FALSE, stride,<br>
+ (void*) offsetof( vertex_inputs, c[1] ));<br>
+<br>
+ /* enable vertex attrib arrays */<br>
+ glEnableVertexAttribArray( vertex_index );<br>
+ glEnableVertexAttribArray( a_index );<br>
+ glEnableVertexAttribArray( a_index + 1 );<br>
+ glEnableVertexAttribArray( b_index );<br>
+ glEnableVertexAttribArray( b_index + 1 );<br>
+ glEnableVertexAttribArray( c_index );<br>
+ glEnableVertexAttribArray( c_index + 1 );<br>
+<br>
+ if (!piglit_check_gl_error(GL_NO_ERROR))<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+}<br>
+<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ glClearColor( 0.5, 0.5, 0.5, 1.0 );<br>
+<br>
+ glClear( GL_COLOR_BUFFER_BIT |<br>
+ GL_DEPTH_BUFFER_BIT |<br>
+ GL_STENCIL_BUFFER_BIT );<br></blockquote><div><br></div><div>It seems strange to clear the depth and stencil buffers, since your test only uses the color buffer. I recommend just "glClear(GL_COLOR_BUFFER_BIT);".<br>
<br></div><div>With the exception of my comment about all.tests, all of my comments are nit-picks. With those 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+ bool pass = true;<br>
+<br>
+ float expected_color[3] = { 0.0, 1.0, 0.0 };<br>
+<br>
+ glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );<br>
+<br>
+ pass = piglit_probe_pixel_rgb( 0.5, 0.5, expected_color );<br>
+<br>
+ piglit_present_results();<br>
+<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
<span class=""><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>