[Piglit] [PATCH 3/3] glsl-1.50 execution: Test shaders for struct capability
Nicholas Mack
nichmack at gmail.com
Tue Jul 16 08:49:32 PDT 2013
---
.../varying-struct-basic-vs-fs.shader_test | 121 +++++++++++++++++++++
1 file changed, 121 insertions(+)
create mode 100644 tests/spec/glsl-1.50/execution/varying-struct-basic-vs-fs.shader_test
diff --git a/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-fs.shader_test b/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-fs.shader_test
new file mode 100644
index 0000000..b10bb69
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-fs.shader_test
@@ -0,0 +1,121 @@
+# 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 output variables ... 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
+
+uniform float ref;
+
+in vec4 vertex;
+struct Foo
+{
+ mat4 a;
+ mat3 b;
+ mat2 c;
+ vec4 d;
+ vec3 e;
+ vec2 f;
+ float g;
+};
+out Foo foo;
+
+void main()
+{
+ gl_Position = vertex;
+
+ 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;
+}
+
+[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