[Piglit] [PATCH 1/2] glsl-es: Additional constant initializer tests.

Ian Romanick idr at freedesktop.org
Wed Oct 7 19:55:03 PDT 2015


From: Ian Romanick <ian.d.romanick at intel.com>

Most built-in functions with constant-expression parameters are also
constant expressions.  GLSL ES 1.00 and 3.00 differ as to whether or not
the sequence operator is a constant expression.

Note: spec/glsl-es-1.00/compiler/const-initializer/from-function.* and
spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.*
currently fail on Mesa.  This is very confusing because the nearly
identical spec/glsl-es-3.00/compiler/const-initializer/from-function.*
tests both pass!

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 .../compiler/const-initializer/from-function.frag  | 25 +++++++++++++++++++
 .../compiler/const-initializer/from-function.vert  | 23 ++++++++++++++++++
 .../from-sequence-in-function.frag                 | 28 ++++++++++++++++++++++
 .../from-sequence-in-function.vert                 | 26 ++++++++++++++++++++
 .../compiler/const-initializer/from-function.frag  | 17 +++++++++++++
 .../compiler/const-initializer/from-function.vert  | 14 +++++++++++
 .../from-sequence-in-function.frag                 | 24 +++++++++++++++++++
 .../from-sequence-in-function.vert                 | 21 ++++++++++++++++
 8 files changed, 178 insertions(+)
 create mode 100644 tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/const-initializer/from-function.frag
 create mode 100644 tests/spec/glsl-es-3.00/compiler/const-initializer/from-function.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/const-initializer/from-sequence-in-function.frag
 create mode 100644 tests/spec/glsl-es-3.00/compiler/const-initializer/from-sequence-in-function.vert

diff --git a/tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.frag b/tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.frag
new file mode 100644
index 0000000..fe0268c
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.frag
@@ -0,0 +1,25 @@
+#version 100
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 5.10 (Constant Expressions) of the GLSL ES 1.00.17 spec says:
+ *
+ *     "A constant expression is one of
+ *
+ *         ...
+ *
+ *         - a built-in function call whose arguments are all constant
+ *           expressions, with the exception of the texture lookup functions."
+ */
+
+precision mediump float;
+
+const float f = cos(0.0);
+
+void main()
+{
+    gl_FragData[0] = vec4(f);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.vert b/tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.vert
new file mode 100644
index 0000000..b96fcf8
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.vert
@@ -0,0 +1,23 @@
+#version 100
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 5.10 (Constant Expressions) of the GLSL ES 1.00.17 spec says:
+ *
+ *     "A constant expression is one of
+ *
+ *         ...
+ *
+ *         - a built-in function call whose arguments are all constant
+ *           expressions, with the exception of the texture lookup functions."
+ */
+
+const float f = cos(0.0);
+
+void main()
+{
+    gl_Position = vec4(f);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.frag b/tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.frag
new file mode 100644
index 0000000..0e39817
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.frag
@@ -0,0 +1,28 @@
+#version 100
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 5.10 (Constant Expressions) of the GLSL ES 1.00.17 spec says:
+ *
+ *     "A constant expression is one of
+ *
+ *         ...
+ *
+ *         - a built-in function call whose arguments are all constant
+ *           expressions, with the exception of the texture lookup functions."
+ *
+ * While the sequence operator is specifically disallowed as a constant
+ * expression in GLSL ES 3.0 and later, it is allowed in GLSL ES 1.00.
+ */
+
+precision mediump float;
+
+const float f = cos((1.0, 2.0));
+
+void main()
+{
+    gl_FragData[0] = vec4(f);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.vert b/tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.vert
new file mode 100644
index 0000000..ffebd6b
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.vert
@@ -0,0 +1,26 @@
+#version 100
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 5.10 (Constant Expressions) of the GLSL ES 1.00.17 spec says:
+ *
+ *     "A constant expression is one of
+ *
+ *         ...
+ *
+ *         - a built-in function call whose arguments are all constant
+ *           expressions, with the exception of the texture lookup functions."
+ *
+ * While the sequence operator is specifically disallowed as a constant
+ * expression in GLSL ES 3.0 and later, it is allowed in GLSL ES 1.00.
+ */
+
+const float f = cos((1.0, 2.0));
+
+void main()
+{
+    gl_Position = vec4(f);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/const-initializer/from-function.frag b/tests/spec/glsl-es-3.00/compiler/const-initializer/from-function.frag
new file mode 100644
index 0000000..8a90994
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/const-initializer/from-function.frag
@@ -0,0 +1,17 @@
+#version 300 es
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00
+ * [end config]
+ */
+
+precision mediump float;
+
+const float f = cos(0.0);
+out vec4 fragdata;
+
+void main()
+{
+    fragdata = vec4(f);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/const-initializer/from-function.vert b/tests/spec/glsl-es-3.00/compiler/const-initializer/from-function.vert
new file mode 100644
index 0000000..851ba76
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/const-initializer/from-function.vert
@@ -0,0 +1,14 @@
+#version 300 es
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00
+ * [end config]
+ */
+
+const float f = cos(0.0);
+
+void main()
+{
+    gl_Position = vec4(f);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/const-initializer/from-sequence-in-function.frag b/tests/spec/glsl-es-3.00/compiler/const-initializer/from-sequence-in-function.frag
new file mode 100644
index 0000000..84ed272
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/const-initializer/from-sequence-in-function.frag
@@ -0,0 +1,24 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3.3 "Constant Expressions" of the OpenGL GLSL ES 3.00.4 spec
+ * says:
+ *
+ *     "However, the sequence operator ( , ) and the assignment operators ( =,
+ *     +=, ...)  are not included in the operators that can create a constant
+ *     expression."
+ */
+
+precision mediump float;
+
+const float f = cos((1.0, 2.0));
+out vec4 fragdata;
+
+void main()
+{
+    fragdata = vec4(f);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/const-initializer/from-sequence-in-function.vert b/tests/spec/glsl-es-3.00/compiler/const-initializer/from-sequence-in-function.vert
new file mode 100644
index 0000000..5dad419
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/const-initializer/from-sequence-in-function.vert
@@ -0,0 +1,21 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3.3 "Constant Expressions" of the OpenGL GLSL ES 3.00.4 spec
+ * says:
+ *
+ *     "However, the sequence operator ( , ) and the assignment operators ( =,
+ *     +=, ...)  are not included in the operators that can create a constant
+ *     expression."
+ */
+
+const float f = cos((1.0, 2.0));
+
+void main()
+{
+    gl_Position = vec4(f);
+}
-- 
2.1.0



More information about the Piglit mailing list