[Piglit] [PATCH 08/11] arb_shading_language_420pack: Test non-const expr initializer of const var.

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


---
 .../const-var-non-constant-expr.shader_test        | 47 ++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 tests/spec/arb_shading_language_420pack/execution/const-var-non-constant-expr.shader_test

diff --git a/tests/spec/arb_shading_language_420pack/execution/const-var-non-constant-expr.shader_test b/tests/spec/arb_shading_language_420pack/execution/const-var-non-constant-expr.shader_test
new file mode 100644
index 0000000..f0fac63
--- /dev/null
+++ b/tests/spec/arb_shading_language_420pack/execution/const-var-non-constant-expr.shader_test
@@ -0,0 +1,47 @@
+/* The ARB_shading_language_420pack says:
+ *
+ *     "Named compile-time constants or read-only variables can be declared using
+ *      the const qualifier.  The const qualifier can be used with any of the
+ *      non-void transparent basic data types, as well as with structures and arrays
+ *      of these. It is an error to write to a const variable outside of its
+ *      declaration, so they must be initialized when declared.  For example,
+ *
+ *          const vec3 zAxis = vec3 (0.0, 0.0, 1.0);
+ *          const float ceiling = a + b; // a and b not necessarily constants"
+ *
+ * Verify that const variables can be initialized with non-constant expressions.
+ */
+
+[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
+
+uniform vec4 color;
+
+void main() {
+    const vec4 const_color = color + vec4(-1.0, 1.0, 0.0, 0.0);
+    gl_FragColor = const_color;
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+ 1.0  1.0
+-1.0  1.0
+
+[test]
+uniform vec4 color 1.0 0.0 0.0 1.0
+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