<div dir="ltr">On 16 September 2013 09:43, Paul Berry <span dir="ltr"><<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@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"><div dir="ltr"><div>On 12 September 2013 10:47, Nicholas Mack <span dir="ltr"><<a href="mailto:nichmack@gmail.com" target="_blank">nichmack@gmail.com</a>></span> wrote:<br>

</div><div class="gmail_extra"><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
 .../execution/vs-gs-arrays-fail.shader_test        | 63 ++++++++++++++++<br>
 .../vs-gs-arrays-within-blocks-pass.shader_test    | 86 ++++++++++++++++++++++<br>
 2 files changed, 149 insertions(+)<br>
 create mode 100644 tests/spec/glsl-1.50/execution/vs-gs-arrays-fail.shader_test<br>
 create mode 100644 tests/spec/glsl-1.50/execution/vs-gs-arrays-within-blocks-pass.shader_test<br>
<br>
diff --git a/tests/spec/glsl-1.50/execution/vs-gs-arrays-fail.shader_test b/tests/spec/glsl-1.50/execution/vs-gs-arrays-fail.shader_test<br>
new file mode 100644<br>
index 0000000..877b0a6<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/vs-gs-arrays-fail.shader_test<br>
@@ -0,0 +1,63 @@<br>
+# Test that vertex array outputs are not allowed outside of output blocks since<br>
+# 2D arrays are not supported.<br></blockquote><div><br></div></div><div>This comment is a little misleading because vertex array outputs acually *are* allowed.  What you're actually testing is that the linker rejects trying to link a vertex array outputs up to a geometry shader array input.  I'd recommend saying something like:<br>


<br></div><div>"Test that a vertex shader array output (outside an interface block) can't be linked to a geometry shader array input."<br></div><div><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>
+# From the GLSL 1.50 specification, section 4.3.4 ("Inputs"):<br>
+#<br>
+# "If the output of a vertex shader is itself an array to be consumed by a<br>
+#  geometry shader, then it must appear in an output block (see interface blocks<br>
+#  below) in the vertex shader and in an input block in the geometry shader with<br>
+#  a block instance name declared as an array. This is required for arrays<br>
+#  output from a vertex shader because two-dimensional arrays are not<br>
+#  supported."<br>
+<br>
+[require]<br>
+GL >= 3.2<br>
+GLSL >= 1.50<br>
+<br>
+[vertex shader]<br>
+<br>
+in vec4 vertex;<br>
+<br>
+out vec4 pos;<br>
+out float a[3];<br>
+<br>
+void main()<br>
+{<br>
+       gl_Position = vertex;<br>
+       pos = vertex;<br>
+       for(int i = 0; i < 3; i++) {<br>
+               a[i] = i+1;<br>
+       }<br>
+}<br>
+<br>
+[geometry shader]<br>
+<br>
+layout(triangles) in;<br>
+layout(triangle_strip, max_vertices = 3) out;<br>
+<br>
+in vec4 pos[];<br>
+in float a[3];<br>
+<br>
+<br>
+void main()<br>
+{<br>
+}<br>
+<br>
+[fragment shader]<br>
+<br>
+out vec4 color;<br>
+<br>
+void main()<br>
+{<br>
+       color = vec4(1.0, 0.0, 0.0, 1.0);<br>
+}<br>
+<br>
+[vertex data]<br>
+vertex/float/2<br>
+-1.0 -1.0<br>
+ 1.0 -1.0<br>
+ 1.0  1.0<br>
+-1.0  1.0<br>
+<br>
+[test]<br>
+link error<br>
diff --git a/tests/spec/glsl-1.50/execution/vs-gs-arrays-within-blocks-pass.shader_test b/tests/spec/glsl-1.50/execution/vs-gs-arrays-within-blocks-pass.shader_test<br>
new file mode 100644<br>
index 0000000..52b8b00<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/vs-gs-arrays-within-blocks-pass.shader_test<br>
@@ -0,0 +1,86 @@<br>
+# Test that vertex array outputs that are passed to a geometry shader are only<br>
+#  valid if they are declared within an output block.<br></blockquote><div><br></div></div></div><div>I'd drop the word "only" from the test description here, since this partuclar test checks that vertex array outputs work when they are in an interface block; it doesn't check that they don't work when they aren't.<br>


<br></div><div>With those two minor comment changes, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>><br></div></div></div></div></blockquote>

<div><br></div><div>Wait, sorry, I take that back.  I have one more comment, which I think needs to be addressed before we can go forward with the patch.<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">

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div><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>
+# From the GLSL 1.50 specification, section 4.3.4 ("Inputs"):<br>
+#<br>
+# "If the output of a vertex shader is itself an array to be consumed by a<br>
+#  geometry shader, then it must appear in an output block (see interface blocks<br>
+#  below) in the vertex shader and in an input block in the geometry shader with<br>
+#  a block instance name declared as an array. This is required for arrays<br>
+#  output from a vertex shader because two-dimensional arrays are not<br>
+#  supported."<br>
+<br>
+[require]<br>
+GL >= 3.2<br>
+GLSL >= 1.50<br>
+<br>
+[vertex shader]<br>
+<br>
+in vec4 vertex;<br>
+<br>
+out vec4 pos;<br>
+out block {<br>
+       float a[4];<br>
+};<br>
+<br>
+void main()<br>
+{<br>
+       gl_Position = vertex;<br>
+       pos = vertex;<br>
+       for(int i = 0; i < 4; i++) {<br>
+               a[i] = i+1;<br>
+       }<br>
+}<br>
+<br>
+[geometry shader]<br>
+<br>
+layout(triangles) in;<br>
+layout(triangle_strip, max_vertices = 3) out;<br>
+<br>
+in vec4 pos[];<br>
+in block {<br>
+       float a[4];<br>
+} b[];<br>
+<br>
+out float aa[4];<br>
+<br>
+void main()<br>
+{<br>
+       for(int i = 0; i < 3; i++) {<br>
+               gl_Position = pos[i];<br>
+               for(int j = 0; j < 4; j++) {<br>
+                       aa[j] = b[i].a[j];<br></blockquote></div></div></div></div></div></blockquote><div><br></div><div>The vertex shader always outputs the same data to each element of the "a" array, regardless of which vertex is being processed.  As a result, when the geometry shader gets to this line, we really aren't testing that the array indexing works correctly.  For instance, if the compiler accidentally compiled this as:<br>

<br></div><div>aa[j] = b[0].a[j]<br><br></div><div>The test would still pass.<br><br></div><div>I'd recommend changing the test so that the vertex shader outputs different values on each vertex, and so that the geometry shader checks that the expected values are received.  For an example of one way to do this, see "[PATCH] gs: Test core GS inputs on GLSL 1.50" (<a href="http://lists.freedesktop.org/archives/piglit/2013-September/007340.html">http://lists.freedesktop.org/archives/piglit/2013-September/007340.html</a>), which I sent to the piglit list on 9/14.<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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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>
+               EmitVertex();<br>
+       }<br>
+}<br>
+<br>
+[fragment shader]<br>
+<br>
+in float aa[4];<br>
+<br>
+out vec4 color;<br>
+<br>
+void main()<br>
+{<br>
+       bool fail = false;<br>
+       for(int i = 0; i < 4; i++) {<br>
+               if(aa[i] != i + 1) fail = true;<br>
+       }<br>
+<br>
+       if (fail)<br>
+               color = vec4(1.0, 0.0, 0.0, 1.0);<br>
+       else<br>
+               color = vec4(0.0, 1.0, 0.0, 1.0);<br>
+}<br>
+<br>
+[vertex data]<br>
+vertex/float/2<br>
+-1.0 -1.0<br>
+ 1.0 -1.0<br>
+ 1.0  1.0<br>
+-1.0  1.0<br>
+<br>
+[test]<br>
+draw arrays GL_TRIANGLE_FAN 0 4<br>
+probe all rgba 0.0 1.0 0.0 1.0<br>
<span><font color="#888888">--<br>
1.8.3.1<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org" target="_blank">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></div></div><br></div></div>
</blockquote></div><br></div></div>