[Piglit] [PATCH 03/11] arb_shading_language_420pack: Add vec.length() test.

Matt Turner mattst88 at gmail.com
Fri May 24 18:28:00 PDT 2013


---
 .../execution/length-vector.shader_test            | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 tests/spec/arb_shading_language_420pack/execution/length-vector.shader_test

diff --git a/tests/spec/arb_shading_language_420pack/execution/length-vector.shader_test b/tests/spec/arb_shading_language_420pack/execution/length-vector.shader_test
new file mode 100644
index 0000000..0e9e231
--- /dev/null
+++ b/tests/spec/arb_shading_language_420pack/execution/length-vector.shader_test
@@ -0,0 +1,54 @@
+/* The ARB_shading_language_420pack says:
+ *
+ *     "The *length* method may be applied to vectors (but not scalars). The
+ *      result is the number of components in the vector. For example,
+ *
+ *           vec3 v;
+ *           const int L = v.length();
+ *
+ *      sets the constant L to 3. The type returned by .length() on a vector is
+ *      *int*."
+ *
+ * Verify that vec.length() returns the number of elements and that the type is
+ * int.
+ */
+
+[require]
+GLSL >= 1.30
+GL_ARB_shading_language_420pack
+
+[vertex shader]
+attribute vec4 vertex;
+
+void main()
+{
+    gl_Position = vertex;
+}
+
+[fragment shader]
+#extension GL_ARB_shading_language_420pack: enable
+
+void main() {
+    vec2 v2;
+    vec3 v3;
+    vec4 v4;
+
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+
+    if (v2.length() != 2 ||
+        v3.length() != 3 ||
+        v4.length() != 4) {
+        gl_FragColor = vec4(1.0, 0.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]
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.8.1.5



More information about the Piglit mailing list