[Piglit] [PATCH 3/4] More tests for vs-gs interface block array matching rules.

Paul Berry stereotype441 at gmail.com
Wed Oct 30 22:27:58 CET 2013


---
 .../interface-vs-named-to-gs-array.shader_test     | 77 ++++++++++++++++++++++
 ...nterface-vs-array-to-gs-array-sized.shader_test | 52 +++++++++++++++
 2 files changed, 129 insertions(+)
 create mode 100644 tests/spec/glsl-1.50/execution/interface-vs-named-to-gs-array.shader_test
 create mode 100644 tests/spec/glsl-1.50/linker/interface-vs-array-to-gs-array-sized.shader_test

diff --git a/tests/spec/glsl-1.50/execution/interface-vs-named-to-gs-array.shader_test b/tests/spec/glsl-1.50/execution/interface-vs-named-to-gs-array.shader_test
new file mode 100644
index 0000000..364ca61
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/interface-vs-named-to-gs-array.shader_test
@@ -0,0 +1,77 @@
+# From the GLSL 1.50 spec, section 4.3.7 (Interface Blocks):
+#
+#     Matched block names within an interface (as defined above) must
+#     match in terms of having the same number of declarations with
+#     the same sequence of types and the same sequence of member
+#     names, as well as having the same member-wise layout
+#     qualification (see next section). Furthermore, if a matching
+#     block is declared as an array, then the array sizes must also
+#     match (or follow array matching rules for the interface between
+#     a vertex and a geometry shader).
+#
+# This test verifies that trying to link a named VS output interface
+# to a GS input interface array succeeds, even if the instance names
+# differ.
+
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+out block {
+  vec4 a;
+  vec4 b;
+} vs_block;
+
+void main()
+{
+  vs_block.a = vec4(0.0, 1.0, 2.0, 3.0) + 10.0 * float(gl_VertexID);
+  vs_block.b = vec4(4.0, 5.0, 6.0, 7.0) + 10.0 * float(gl_VertexID);
+}
+
+[geometry shader]
+layout(triangles) in;
+layout(triangle_strip, max_vertices = 4) out;
+
+in block {
+  vec4 a;
+  vec4 b;
+} gs_block[3];
+out vec4 color;
+
+void main()
+{
+  const vec4 vertices[4] = vec4[4](
+    vec4(-1.0, -1.0, 0.0, 1.0),
+    vec4(-1.0,  1.0, 0.0, 1.0),
+    vec4( 1.0, -1.0, 0.0, 1.0),
+    vec4( 1.0,  1.0, 0.0, 1.0)
+  );
+
+  bool ok = true;
+  for (int i = 0; i < 3; i++) {
+    if (gs_block[i].a != vec4(0.0, 1.0, 2.0, 3.0) + 10.0 * float(i))
+      ok = false;
+    if (gs_block[i].b != vec4(4.0, 5.0, 6.0, 7.0) + 10.0 * float(i))
+      ok = false;
+  }
+
+  for (int i = 0; i < 4; i++) {
+    color = ok ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
+    gl_Position = vertices[i];
+    EmitVertex();
+  }
+}
+
+[fragment shader]
+in vec4 color;
+
+void main()
+{
+  gl_FragColor = color;
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw arrays GL_TRIANGLES 0 3
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.50/linker/interface-vs-array-to-gs-array-sized.shader_test b/tests/spec/glsl-1.50/linker/interface-vs-array-to-gs-array-sized.shader_test
new file mode 100644
index 0000000..080235c
--- /dev/null
+++ b/tests/spec/glsl-1.50/linker/interface-vs-array-to-gs-array-sized.shader_test
@@ -0,0 +1,52 @@
+# From the GLSL 1.50 spec, section 4.3.7 (Interface Blocks):
+#
+#     Matched block names within an interface (as defined above) must
+#     match in terms of having the same number of declarations with
+#     the same sequence of types and the same sequence of member
+#     names, as well as having the same member-wise layout
+#     qualification (see next section). Furthermore, if a matching
+#     block is declared as an array, then the array sizes must also
+#     match (or follow array matching rules for the interface between
+#     a vertex and a geometry shader).
+#
+# This test verifies that trying to link a VS output interface array
+# to a sized GS input interface array fails, even if the size of the
+# GS input interface array matches the size of the VS output interface
+# array.
+
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+out block {
+    vec4 a;
+    vec4 b;
+} vs_block[3];
+
+void main()
+{
+	for(int i = 0; i < 3; i++) {
+		vs_block[i].a = vec4(1., 0., 0., 1.);
+	}
+}
+
+[geometry shader]
+layout(triangles) in;
+layout(triangle_strip, max_vertices=3) out;
+
+in block {
+    vec4 a;
+    vec4 b;
+} vs_block[3];
+
+out vec4 color;
+
+void main()
+{
+	for(int i = 0; i < 2; i++) {
+		color = vs_block[i].a;
+	}
+}
+
+[test]
+link error
-- 
1.8.4.2



More information about the Piglit mailing list