<div dir="ltr">On 1 June 2013 11:51, Fabian Bieler <span dir="ltr"><<a href="mailto:fabianbieler@fastmail.fm" target="_blank">fabianbieler@fastmail.fm</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">Add some tests that basically check that the compiler doesn't confuse the two<br>
array dimensions.<br>
---<br>
.../arb_geometry_shader4/compiler/2darray02.geom | 29 ++++++++<br>
.../arb_geometry_shader4/compiler/2darray03.geom | 29 ++++++++<br>
.../arb_geometry_shader4/compiler/2darray04.geom | 30 ++++++++<br>
.../linker/2darray02.shader_test | 85 ++++++++++++++++++++++<br>
.../linker/2darray03.shader_test | 62 ++++++++++++++++<br>
5 files changed, 235 insertions(+)<br>
create mode 100644 tests/spec/arb_geometry_shader4/compiler/2darray02.geom<br>
create mode 100644 tests/spec/arb_geometry_shader4/compiler/2darray03.geom<br>
create mode 100644 tests/spec/arb_geometry_shader4/compiler/2darray04.geom<br>
create mode 100644 tests/spec/arb_geometry_shader4/linker/2darray02.shader_test<br>
create mode 100644 tests/spec/arb_geometry_shader4/linker/2darray03.shader_test<br>
<br>
diff --git a/tests/spec/arb_geometry_shader4/compiler/2darray02.geom b/tests/spec/arb_geometry_shader4/compiler/2darray02.geom<br>
new file mode 100644<br>
index 0000000..03ef6b4<br>
--- /dev/null<br>
+++ b/tests/spec/arb_geometry_shader4/compiler/2darray02.geom<br>
@@ -0,0 +1,29 @@<br>
+// [config]<br>
+// expect_result: fail<br>
+// glsl_version: 1.20<br>
+// require_extensions: GL_ARB_geometry_shader4<br>
+// [end config]<br>
+<br>
+#version 120<br>
+#extension GL_ARB_geometry_shader4: enable<br>
+<br>
+varying in float gs_input[3][1];<br>
+<br>
+varying out float gs_out;<br>
+<br>
+void main()<br>
+{<br>
+ /* Constant indexing of arrays with known size should do a bounds check.<br>
+ * The bounds check on this to operation would fail if the compiler<br></blockquote><div><br></div><div>I think you mean "would pass" instead of "would fail" both here and in 2darray03.geom.<br>
<br>With that fixed, and with more descriptive test names, 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">
+ * checked the index against the wrong array dimension.<br>
+ */<br>
+ float s = gs_input[0][1];<br>
+<br>
+ for (int i = 0; i < gl_VerticesIn; i++) {<br>
+ gs_out = s;<br>
+<br>
+ gl_Position = gl_PositionIn[i];<br>
+ EmitVertex();<br>
+ }<br>
+}<br>
+<br>
diff --git a/tests/spec/arb_geometry_shader4/compiler/2darray03.geom b/tests/spec/arb_geometry_shader4/compiler/2darray03.geom<br>
new file mode 100644<br>
index 0000000..14e2824<br>
--- /dev/null<br>
+++ b/tests/spec/arb_geometry_shader4/compiler/2darray03.geom<br>
@@ -0,0 +1,29 @@<br>
+// [config]<br>
+// expect_result: fail<br>
+// glsl_version: 1.20<br>
+// require_extensions: GL_ARB_geometry_shader4<br>
+// [end config]<br>
+<br>
+#version 120<br>
+#extension GL_ARB_geometry_shader4: enable<br>
+<br>
+varying in float gs_input[3][4];<br>
+<br>
+varying out float gs_out;<br>
+<br>
+void main()<br>
+{<br>
+ /* Constant indexing of arrays with known size should do a bounds check.<br>
+ * The bounds check on this to operation would fail if the compiler<br>
+ * checked the index against the wrong array dimension.<br>
+ */<br>
+ float s = gs_input[3][0];<br>
+<br>
+ for (int i = 0; i < gl_VerticesIn; i++) {<br>
+ gs_out = s;<br>
+<br>
+ gl_Position = gl_PositionIn[i];<br>
+ EmitVertex();<br>
+ }<br>
+}<br>
+<br>
diff --git a/tests/spec/arb_geometry_shader4/compiler/2darray04.geom b/tests/spec/arb_geometry_shader4/compiler/2darray04.geom<br>
new file mode 100644<br>
index 0000000..9c268e3<br>
--- /dev/null<br>
+++ b/tests/spec/arb_geometry_shader4/compiler/2darray04.geom<br>
@@ -0,0 +1,30 @@<br>
+// [config]<br>
+// expect_result: fail<br>
+// glsl_version: 1.20<br>
+// require_extensions: GL_ARB_geometry_shader4<br>
+// [end config]<br>
+<br>
+#version 120<br>
+#extension GL_ARB_geometry_shader4: enable<br>
+<br>
+varying in float gs_input[3][1];<br>
+<br>
+varying out float gs_out;<br>
+<br>
+void main()<br>
+{<br>
+ /* Assignment operations of arrays should fail if the arrays don't have<br>
+ * the same size.<br>
+ * This check would pass if the compiler incorrectly checked the size<br>
+ * a against the outer dimension of gs_input (both 3).<br>
+ */<br>
+ float a[3] = gs_input[0];<br>
+<br>
+ for (int i = 0; i < gl_VerticesIn; i++) {<br>
+ gs_out = a[0];<br>
+<br>
+ gl_Position = gl_PositionIn[i];<br>
+ EmitVertex();<br>
+ }<br>
+}<br>
+<br>
diff --git a/tests/spec/arb_geometry_shader4/linker/2darray02.shader_test b/tests/spec/arb_geometry_shader4/linker/2darray02.shader_test<br>
new file mode 100644<br>
index 0000000..1d20aec<br>
--- /dev/null<br>
+++ b/tests/spec/arb_geometry_shader4/linker/2darray02.shader_test<br>
@@ -0,0 +1,85 @@<br>
+#Test bounds checking of 2d array indexing.<br>
+#Also test length validation of the inner array of 2d arrays.<br>
+[require]<br>
+GL >= 2.0<br>
+GLSL >= 1.20<br>
+GL_ARB_geometry_shader4<br>
+<br>
+[vertex shader]<br>
+#version 120<br>
+<br>
+attribute vec4 vertex;<br>
+<br>
+varying float gs_input1[1];<br>
+varying float gs_input4[4];<br>
+<br>
+void main()<br>
+{<br>
+ gs_input1[0] = 0.5;<br>
+ for (int i = 0; i < 4; i++)<br>
+ gs_input4[i] = 0.5;<br>
+ gl_Position = vertex;<br>
+}<br>
+<br>
+[geometry shader]<br>
+#version 120<br>
+#extension GL_ARB_geometry_shader4: enable<br>
+<br>
+varying in float gs_input1[3][1];<br>
+varying in float gs_input4[3][4];<br>
+<br>
+varying out vec4 gs_out;<br>
+<br>
+void main()<br>
+{<br>
+ /* Constant indexing of arrays with known size should do a bounds check.<br>
+ * The bounds check on these to operations would fail if the compiler<br>
+ * checked the index against the wrong array dimension.<br>
+ */<br>
+ float s1 = gs_input1[1][0];<br>
+ float s2 = gs_input4[0][3];<br>
+<br>
+ /* Assignment operations of arrays should fail if the arrays don't have<br>
+ * the same size.<br>
+ * The assignment operations would fail if the compiler incorrectly<br>
+ * compared the size of the local arrays a* (1 and 4, respectively) to<br>
+ * the size of the outer dimension of the input arrays gs_input* (3).<br>
+ */<br>
+ float a1[1] = gs_input1[0];<br>
+ float a4[4] = gs_input4[0];<br>
+<br>
+ for (int i = 0; i < gl_VerticesIn; i++) {<br>
+ gs_out = vec4(s1, s2, a1[0], a4[0]);<br>
+<br>
+ gl_Position = gl_PositionIn[i];<br>
+ EmitVertex();<br>
+ }<br>
+}<br>
+<br>
+[geometry layout]<br>
+input type GL_TRIANGLES<br>
+output type GL_TRIANGLE_STRIP<br>
+vertices out 3<br>
+<br>
+[fragment shader]<br>
+#version 120<br>
+<br>
+const int gs_VerticesIn = 3;<br>
+<br>
+varying vec4 gs_out;<br>
+<br>
+void main()<br>
+{<br>
+ gl_FragColor = gs_out;<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.5 0.5 0.5 0.5<br>
diff --git a/tests/spec/arb_geometry_shader4/linker/2darray03.shader_test b/tests/spec/arb_geometry_shader4/linker/2darray03.shader_test<br>
new file mode 100644<br>
index 0000000..f4c807a<br>
--- /dev/null<br>
+++ b/tests/spec/arb_geometry_shader4/linker/2darray03.shader_test<br>
@@ -0,0 +1,62 @@<br>
+#Test that constant array indexing of gs input arrays is bounds checked at link time.<br>
+[require]<br>
+GL >= 2.0<br>
+GLSL >= 1.20<br>
+GL_ARB_geometry_shader4<br>
+<br>
+[vertex shader]<br>
+#version 120<br>
+<br>
+attribute vec4 vertex;<br>
+<br>
+varying float gs_input[4];<br>
+<br>
+void main()<br>
+{<br>
+ for (int i = 0; i < 4; i++)<br>
+ gs_input[i] = 0.5;<br>
+ gl_Position = vertex;<br>
+}<br>
+<br>
+[geometry shader]<br>
+#version 120<br>
+#extension GL_ARB_geometry_shader4: enable<br>
+<br>
+varying in float gs_input[][4];<br>
+<br>
+varying out float gs_out;<br>
+<br>
+void main()<br>
+{<br>
+ /* This sould fail at link time once the size of the outer dimension of<br>
+ * gs_input (3) is known.<br>
+ */<br>
+ float s = gs_input[3][0];<br>
+<br>
+ for (int i = 0; i < gl_VerticesIn; i++) {<br>
+ gs_out = s;<br>
+<br>
+ gl_Position = gl_PositionIn[i];<br>
+ EmitVertex();<br>
+ }<br>
+}<br>
+<br>
+[geometry layout]<br>
+input type GL_TRIANGLES<br>
+output type GL_TRIANGLE_STRIP<br>
+vertices out 3<br>
+<br>
+[fragment shader]<br>
+#version 120<br>
+<br>
+const int gs_VerticesIn = 3;<br>
+<br>
+varying float gs_out;<br>
+<br>
+void main()<br>
+{<br>
+ gl_FragColor = vec4(gs_out);<br>
+}<br>
+<br>
+[test]<br>
+link error<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.2<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>