From 6aacf6f370846879cc7d80b25235420c666ae1b2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Oct 2015 16:23:17 -0700 Subject: glsl-es: Additional constant initializer tests. 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 --- .../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 000000000..fe0268c22 --- /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 000000000..b96fcf800 --- /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 000000000..0e398173d --- /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 000000000..ffebd6bac --- /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 000000000..8a90994e5 --- /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 000000000..851ba76ef --- /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 000000000..84ed272ac --- /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 000000000..5dad4194f --- /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); +} -- cgit v1.2.3