diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2015-10-06 15:46:33 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2015-10-13 16:30:11 -0700 |
commit | de21e2443f6135cac6adab51dd6dfcf32ad6f099 (patch) | |
tree | 48896eb2e061bb3761c79e0b869d7e30e1102a84 /tests | |
parent | 9a917d448b37faf595317a99c0b493dbc3853a85 (diff) |
glsl-es: Verify restrictions on global variable initializers
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@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92304
Reviewed-by: Mark Janes <mark.a.janes@intel.com>
Tested-by: Mark Janes <mark.a.janes@intel.com>
Cc: Tapani Pälli <tapani.palli@intel.com>
Cc: Mark Janes <mark.a.janes@intel.com>
Cc: Marta Lofstedt <marta.lofstedt@intel.com>
Diffstat (limited to 'tests')
30 files changed, 695 insertions, 0 deletions
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 000000000..dcc8b9ac5 --- /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 000000000..65d1df117 --- /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 000000000..9dbe533c3 --- /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 000000000..e88258f21 --- /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 000000000..0da7bca04 --- /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 000000000..61c92ba03 --- /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 000000000..06c78eec1 --- /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 000000000..5f26d13be --- /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 000000000..b04b34579 --- /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 000000000..e09085b7a --- /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 000000000..3dd34af4d --- /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 000000000..b1fb3f507 --- /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 000000000..24acf7961 --- /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 000000000..deaee9446 --- /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 000000000..9b90fe9e5 --- /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 000000000..858f766cd --- /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 000000000..dc41a6bdd --- /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 000000000..8f3d7fc57 --- /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 000000000..e6d921f9d --- /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 000000000..d1f4b28ea --- /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 000000000..cc7b3a27d --- /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 000000000..6f887f6d5 --- /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 000000000..8c3905056 --- /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 000000000..398abdd67 --- /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 000000000..f4dff6b01 --- /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 000000000..53484383e --- /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 000000000..4ea82a1c9 --- /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 000000000..4ff22d933 --- /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 000000000..91d7fd393 --- /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 000000000..7a6c82d98 --- /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); +} |