[Piglit] [PATCH] glsl-es: Verify restrictions on global variable initializers

Ian Romanick idr at freedesktop.org
Tue Oct 6 19:07:24 PDT 2015


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

Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:

    "Declarations of globals without a storage qualifier, or with just
    the const qualifier, may include initializers, in which case they
    will be initialized before the first line of main() is executed.
    Such initializers must be a constant expression."

The GLSL ES 3.00.4 spec has similar language.  Desktop GLSL does not
restrict initializers for global variables.  Now it's okay for Matt to
be irritated.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92304
Cc: Tapani Pälli <tapani.palli at intel.com>
Cc: Mark Janes <mark.a.janes at intel.com>
Cc: Marta Lofstedt <marta.lofstedt at intel.com>
---
 .../global-initializer/from-attribute.vert         | 14 +++++++++
 .../compiler/global-initializer/from-constant.frag | 14 +++++++++
 .../compiler/global-initializer/from-constant.vert | 14 +++++++++
 .../compiler/global-initializer/from-global.frag   | 14 +++++++++
 .../compiler/global-initializer/from-global.vert   | 14 +++++++++
 .../compiler/global-initializer/from-sequence.frag | 14 +++++++++
 .../compiler/global-initializer/from-sequence.vert | 14 +++++++++
 .../compiler/global-initializer/from-uniform.frag  | 14 +++++++++
 .../compiler/global-initializer/from-uniform.vert  | 14 +++++++++
 .../compiler/global-initializer/from-varying.frag  | 14 +++++++++
 .../global-initializer/from-attribute.vert         | 26 ++++++++++++++++
 .../compiler/global-initializer/from-constant.frag | 28 +++++++++++++++++
 .../compiler/global-initializer/from-constant.vert | 26 ++++++++++++++++
 .../compiler/global-initializer/from-global.frag   | 28 +++++++++++++++++
 .../compiler/global-initializer/from-global.vert   | 26 ++++++++++++++++
 .../compiler/global-initializer/from-sequence.frag | 31 +++++++++++++++++++
 .../compiler/global-initializer/from-sequence.vert | 29 ++++++++++++++++++
 .../compiler/global-initializer/from-uniform.frag  | 28 +++++++++++++++++
 .../compiler/global-initializer/from-uniform.vert  | 26 ++++++++++++++++
 .../compiler/global-initializer/from-varying.frag  | 28 +++++++++++++++++
 .../compiler/global-initializer/from-constant.frag | 28 +++++++++++++++++
 .../compiler/global-initializer/from-constant.vert | 25 ++++++++++++++++
 .../compiler/global-initializer/from-global.frag   | 28 +++++++++++++++++
 .../compiler/global-initializer/from-global.vert   | 25 ++++++++++++++++
 .../compiler/global-initializer/from-in.frag       | 28 +++++++++++++++++
 .../compiler/global-initializer/from-in.vert       | 25 ++++++++++++++++
 .../compiler/global-initializer/from-sequence.frag | 35 ++++++++++++++++++++++
 .../compiler/global-initializer/from-sequence.vert | 32 ++++++++++++++++++++
 .../compiler/global-initializer/from-uniform.frag  | 28 +++++++++++++++++
 .../compiler/global-initializer/from-uniform.vert  | 25 ++++++++++++++++
 30 files changed, 695 insertions(+)
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-attribute.vert
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-constant.frag
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-constant.vert
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-global.frag
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-global.vert
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-sequence.frag
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-sequence.vert
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-uniform.frag
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-uniform.vert
 create mode 100644 tests/spec/glsl-1.10/compiler/global-initializer/from-varying.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-attribute.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-constant.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-constant.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-global.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-global.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-sequence.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-sequence.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-uniform.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-uniform.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/global-initializer/from-varying.frag
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-constant.frag
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-constant.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-global.frag
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-global.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-in.frag
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-in.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-sequence.frag
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-sequence.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-uniform.frag
 create mode 100644 tests/spec/glsl-es-3.00/compiler/global-initializer/from-uniform.vert

diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-attribute.vert b/tests/spec/glsl-1.10/compiler/global-initializer/from-attribute.vert
new file mode 100644
index 0000000..dcc8b9a
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-attribute.vert
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+attribute float af;
+float gf1 = 1.0;
+float gf2 = af;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, af, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-constant.frag b/tests/spec/glsl-1.10/compiler/global-initializer/from-constant.frag
new file mode 100644
index 0000000..65d1df1
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-constant.frag
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = cf;
+
+void main()
+{
+    gl_FragColor = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-constant.vert b/tests/spec/glsl-1.10/compiler/global-initializer/from-constant.vert
new file mode 100644
index 0000000..9dbe533
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-constant.vert
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = cf;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-global.frag b/tests/spec/glsl-1.10/compiler/global-initializer/from-global.frag
new file mode 100644
index 0000000..e88258f
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-global.frag
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = gf1;
+
+void main()
+{
+    gl_FragColor = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-global.vert b/tests/spec/glsl-1.10/compiler/global-initializer/from-global.vert
new file mode 100644
index 0000000..0da7bca
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-global.vert
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = gf1;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-sequence.frag b/tests/spec/glsl-1.10/compiler/global-initializer/from-sequence.frag
new file mode 100644
index 0000000..61c92ba
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-sequence.frag
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = (cf, 3.0);
+
+void main()
+{
+    gl_FragColor = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-sequence.vert b/tests/spec/glsl-1.10/compiler/global-initializer/from-sequence.vert
new file mode 100644
index 0000000..06c78ee
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-sequence.vert
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = (cf, 3.0);
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-uniform.frag b/tests/spec/glsl-1.10/compiler/global-initializer/from-uniform.frag
new file mode 100644
index 0000000..5f26d13
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-uniform.frag
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+uniform float uf;
+float gf1 = 1.0;
+float gf2 = uf;
+
+void main()
+{
+    gl_FragColor = vec4(gf1, gf2, uf, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-uniform.vert b/tests/spec/glsl-1.10/compiler/global-initializer/from-uniform.vert
new file mode 100644
index 0000000..b04b345
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-uniform.vert
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+uniform float uf;
+float gf1 = 1.0;
+float gf2 = uf;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, uf, 1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/global-initializer/from-varying.frag b/tests/spec/glsl-1.10/compiler/global-initializer/from-varying.frag
new file mode 100644
index 0000000..e09085b
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/global-initializer/from-varying.frag
@@ -0,0 +1,14 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+varying float af;
+float gf1 = 1.0;
+float gf2 = af;
+
+void main()
+{
+    gl_FragColor = vec4(gf1, gf2, af, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-attribute.vert b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-attribute.vert
new file mode 100644
index 0000000..3dd34af
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-attribute.vert
@@ -0,0 +1,26 @@
+#version 100
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+attribute float af;
+float gf1 = 1.0;
+float gf2 = af;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, af, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-constant.frag b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-constant.frag
new file mode 100644
index 0000000..b1fb3f5
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-constant.frag
@@ -0,0 +1,28 @@
+#version 100
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+precision mediump float;
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = cf;
+
+void main()
+{
+    gl_FragData[0] = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-constant.vert b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-constant.vert
new file mode 100644
index 0000000..24acf79
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-constant.vert
@@ -0,0 +1,26 @@
+#version 100
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = cf;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-global.frag b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-global.frag
new file mode 100644
index 0000000..deaee94
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-global.frag
@@ -0,0 +1,28 @@
+#version 100
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+precision mediump float;
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = gf1;
+
+void main()
+{
+    gl_FragData[0] = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-global.vert b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-global.vert
new file mode 100644
index 0000000..9b90fe9
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-global.vert
@@ -0,0 +1,26 @@
+#version 100
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = gf1;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-sequence.frag b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-sequence.frag
new file mode 100644
index 0000000..858f766
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-sequence.frag
@@ -0,0 +1,31 @@
+#version 100
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ *
+ * 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 cf = 2.0;
+float gf1 = 1.0;
+float gf2 = (cf, 3.0);
+
+void main()
+{
+    gl_FragData[0] = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-sequence.vert b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-sequence.vert
new file mode 100644
index 0000000..dc41a6b
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-sequence.vert
@@ -0,0 +1,29 @@
+#version 100
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ *
+ * 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 cf = 2.0;
+float gf1 = 1.0;
+float gf2 = (cf, 3.0);
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-uniform.frag b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-uniform.frag
new file mode 100644
index 0000000..8f3d7fc
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-uniform.frag
@@ -0,0 +1,28 @@
+#version 100
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+precision mediump float;
+
+uniform float uf;
+float gf1 = 1.0;
+float gf2 = uf;
+
+void main()
+{
+    gl_FragData[0] = vec4(gf1, gf2, uf, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-uniform.vert b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-uniform.vert
new file mode 100644
index 0000000..e6d921f
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-uniform.vert
@@ -0,0 +1,26 @@
+#version 100
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+uniform float uf;
+float gf1 = 1.0;
+float gf2 = uf;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, uf, 1.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/global-initializer/from-varying.frag b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-varying.frag
new file mode 100644
index 0000000..d1f4b28
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/global-initializer/from-varying.frag
@@ -0,0 +1,28 @@
+#version 100
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 1.00.17 spec says:
+ *
+ *     "Declarations of globals without a storage qualifier, or with just the
+ *     const qualifier, may include initializers, in which case they will be
+ *     initialized before the first line of main() is executed.  Such
+ *     initializers must be a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+precision mediump float;
+
+varying float af;
+float gf1 = 1.0;
+float gf2 = af;
+
+void main()
+{
+    gl_FragData[0] = vec4(gf1, gf2, af, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-constant.frag b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-constant.frag
new file mode 100644
index 0000000..cc7b3a2
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-constant.frag
@@ -0,0 +1,28 @@
+#version 300 es
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+precision mediump float;
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = cf;
+out vec4 fragdata;
+
+void main()
+{
+    fragdata = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-constant.vert b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-constant.vert
new file mode 100644
index 0000000..6f887f6
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-constant.vert
@@ -0,0 +1,25 @@
+#version 300 es
+
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = cf;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-global.frag b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-global.frag
new file mode 100644
index 0000000..8c39050
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-global.frag
@@ -0,0 +1,28 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+precision mediump float;
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = gf1;
+out vec4 fragdata;
+
+void main()
+{
+    fragdata = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-global.vert b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-global.vert
new file mode 100644
index 0000000..398abdd
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-global.vert
@@ -0,0 +1,25 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+const float cf = 2.0;
+float gf1 = 1.0;
+float gf2 = gf1;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-in.frag b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-in.frag
new file mode 100644
index 0000000..f4dff6b
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-in.frag
@@ -0,0 +1,28 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+precision mediump float;
+
+in float af;
+float gf1 = 1.0;
+float gf2 = af;
+out vec4 fragdata;
+
+void main()
+{
+    fragdata = vec4(gf1, gf2, af, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-in.vert b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-in.vert
new file mode 100644
index 0000000..5348438
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-in.vert
@@ -0,0 +1,25 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+in float af;
+float gf1 = 1.0;
+float gf2 = af;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, af, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-sequence.frag b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-sequence.frag
new file mode 100644
index 0000000..4ea82a1
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-sequence.frag
@@ -0,0 +1,35 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ *
+ * 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 cf = 2.0;
+float gf1 = 1.0;
+float gf2 = (cf, 3.0);
+out vec4 fragdata;
+
+void main()
+{
+    fragdata = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-sequence.vert b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-sequence.vert
new file mode 100644
index 0000000..4ff22d9
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-sequence.vert
@@ -0,0 +1,32 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ *
+ * 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 cf = 2.0;
+float gf1 = 1.0;
+float gf2 = (cf, 3.0);
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, cf, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-uniform.frag b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-uniform.frag
new file mode 100644
index 0000000..91d7fd3
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-uniform.frag
@@ -0,0 +1,28 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+precision mediump float;
+
+uniform float uf;
+float gf1 = 1.0;
+float gf2 = uf;
+out vec4 fragdata;
+
+void main()
+{
+    fragdata = vec4(gf1, gf2, uf, 1.0);
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/global-initializer/from-uniform.vert b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-uniform.vert
new file mode 100644
index 0000000..7a6c82d
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/global-initializer/from-uniform.vert
@@ -0,0 +1,25 @@
+#version 300 es
+
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ *
+ * Section 4.3 (Storage Qualifiers) of the OpenGL ES 3.00.4 spec says:
+ *
+ *     "Initializers may only be used in declarations of globals with no
+ *     storage qualifier or with a const qualifier.  Such initializers must be
+ *     a constant expression."
+ *
+ * This differs from desktop GLSL.  A compiler that only has to support GLSL
+ * ES could possibly be some amount smaller due to this restriction.
+ */
+
+uniform float uf;
+float gf1 = 1.0;
+float gf2 = uf;
+
+void main()
+{
+    gl_Position = vec4(gf1, gf2, uf, 1.0);
+}
-- 
2.1.0



More information about the Piglit mailing list