[Piglit] [PATCH 2/2] GLSL 1.50: Test that struct varyings are passed correctly from GS to FS
Nicholas Mack
nichmack at gmail.com
Fri Aug 23 11:02:13 PDT 2013
---
.../varying-struct-basic-vs-gs-fs.shader_test | 141 +++++++++++++++++++++
1 file changed, 141 insertions(+)
create mode 100644 tests/spec/glsl-1.50/execution/varying-struct-basic-vs-gs-fs.shader_test
diff --git a/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-gs-fs.shader_test b/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-gs-fs.shader_test
new file mode 100644
index 0000000..e59e2b5
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-gs-fs.shader_test
@@ -0,0 +1,141 @@
+# Test that varying structs work properly.
+#
+# From the GLSL 1.50 specification, section 4.3.4 ("Input Variables"):
+#
+# "Fragment inputs can only be signed and unsigned integers and
+# integer vectors, float, floating-point vectors, matrices, or
+# arrays or structures of these."
+#
+# And from section 4.3.6 ("Output Variables"):
+#
+# "Vertex and geometry output variables output per-vertex data and are
+# declared using the out storage qualifier, the centroid out storage
+# qualifier, or the deprecated varying storage qualifier. They can only be
+# float, floating-point vectors, matrices, signed or unsigned integers or
+# integer vectors, or arrays or structures of any these."
+#
+# This test verifies basic functionality of varying structs using a
+# varying struct containing a variety of types.
+
+[require]
+GL >= 3.2
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+
+in vec4 vertex;
+out vec4 pos;
+
+void main()
+{
+ gl_Position = vertex;
+ pos = vertex;
+}
+
+[geometry shader]
+#version 150
+
+uniform float ref;
+
+layout(triangles) in;
+layout(triangles, max_vertices=3) out;
+
+in vec4 pos[];
+
+struct Foo
+{
+ mat4 a;
+ mat3 b;
+ mat2 c;
+ vec4 d;
+ vec3 e;
+ vec2 f;
+ float g;
+};
+out Foo foo;
+
+void main()
+{
+ for(int i = 0; i < 3; i++) {
+ gl_Position = pos[i];
+ foo.a = mat4(ref, ref + 1.0, ref + 2.0, ref + 3.0,
+ ref + 4.0, ref + 5.0, ref + 6.0, ref + 7.0,
+ ref + 8.0, ref + 9.0, ref + 10.0, ref + 11.0,
+ ref + 12.0, ref + 13.0, ref + 14.0, ref + 15.0);
+
+ foo.b = mat3(ref + 16.0, ref + 17.0, ref + 18.0,
+ ref + 19.0, ref + 20.0, ref + 21.0,
+ ref + 22.0, ref + 23.0, ref + 24.0);
+
+ foo.c = mat2(ref + 25.0, ref + 26.0,
+ ref + 27.0, ref + 28.0);
+
+ foo.d = vec4(ref + 29.0, ref + 30.0, ref + 31.0, ref + 32.0);
+ foo.e = vec3(ref + 33.0, ref + 34.0, ref + 35.0);
+ foo.f = vec2(ref + 36.0, ref + 37.0);
+ foo.g = ref + 38.0;
+ EmitVertex();
+ }
+}
+
+[fragment shader]
+#version 150
+
+uniform float ref;
+
+struct Foo
+{
+ mat4 a;
+ mat3 b;
+ mat2 c;
+ vec4 d;
+ vec3 e;
+ vec2 f;
+ float g;
+};
+in Foo foo;
+out vec4 color;
+
+#define CHECK(value, expected) \
+ if (distance(value, expected) > 0.00001) \
+ failed = true
+
+void main()
+{
+ bool failed = false;
+
+ CHECK(foo.a[0], vec4(ref, ref + 1.0, ref + 2.0, ref + 3.0));
+ CHECK(foo.a[1], vec4(ref + 4.0, ref + 5.0, ref + 6.0, ref + 7.0));
+ CHECK(foo.a[2], vec4(ref + 8.0, ref + 9.0, ref + 10.0, ref + 11.0));
+ CHECK(foo.a[3], vec4(ref + 12.0, ref + 13.0, ref + 14.0, ref + 15.0));
+
+ CHECK(foo.b[0], vec3(ref + 16.0, ref + 17.0, ref + 18.0));
+ CHECK(foo.b[1], vec3(ref + 19.0, ref + 20.0, ref + 21.0));
+ CHECK(foo.b[2], vec3(ref + 22.0, ref + 23.0, ref + 24.0));
+
+ CHECK(foo.c[0], vec2(ref + 25.0, ref + 26.0));
+ CHECK(foo.c[1], vec2(ref + 27.0, ref + 28.0));
+
+ CHECK(foo.d, vec4(ref + 29.0, ref + 30.0, ref + 31.0, ref + 32.0));
+ CHECK(foo.e, vec3(ref + 33.0, ref + 34.0, ref + 35.0));
+ CHECK(foo.f, vec2(ref + 36.0, ref + 37.0));
+ CHECK(foo.g, ref + 38.0);
+
+ if (failed)
+ color = vec4(1.0, 0.0, 0.0, 1.0);
+ else
+ color = vec4(0.0, 1.0, 0.0, 1.0);
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+ 1.0 1.0
+-1.0 1.0
+
+[test]
+uniform float ref 137.035999074
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
--
1.8.3.1
More information about the Piglit
mailing list