diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2013-08-09 15:19:28 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2013-08-15 15:24:00 -0700 |
commit | fb7bc989f211fe30c02ff687cbf53c01ad7970db (patch) | |
tree | 1fedaa189a9bc5aa64cccf9092d627eaec3f740e | |
parent | 898db0c7e535f7471fef41652e82f37a655acc8f (diff) |
glsl-es-1.00: Verify that the default precision is properly scoped
The GLSL ES 1.00 spec says that the default precision for a type is
scoped the same way as variables (see the tests for the actual spec
qutotation). These tests verify that the compiler implements those
rules for the fragment shader.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
4 files changed, 126 insertions, 0 deletions
diff --git a/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-01.frag b/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-01.frag new file mode 100644 index 000000000..b5732433f --- /dev/null +++ b/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-01.frag @@ -0,0 +1,30 @@ +// [config] +// expect_result: pass +// glsl_version: 1.00 +// [end config] +// +// Section 4.5.3 (Default Precision Qualifiers) of the GLSL ES 1.00 spec says: +// +// "Non-precision qualified declarations will use the precision qualifier +// specified in the most recent precision statement that is still in +// scope. The precision statement has the same scoping rules as variable +// declarations. If it is declared inside a compound statement, its effect +// stops at the end of the innermost statement it was declared +// in. Precision statements in nested scopes override precision statements +// in outer scopes. Multiple precision statements for the same basic type +// can appear inside the same scope, with later statements overriding +// earlier statements within that scope." +// +// The declaration inside the function should use the precision set at global +// scope. + +#version 100 + +precision mediump float; + +void f() +{ + float x; +} + +float y; diff --git a/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-02.frag b/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-02.frag new file mode 100644 index 000000000..bd2a4ea57 --- /dev/null +++ b/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-02.frag @@ -0,0 +1,29 @@ +// [config] +// expect_result: fail +// glsl_version: 1.00 +// [end config] +// +// Section 4.5.3 (Default Precision Qualifiers) of the GLSL ES 1.00 spec says: +// +// "Non-precision qualified declarations will use the precision qualifier +// specified in the most recent precision statement that is still in +// scope. The precision statement has the same scoping rules as variable +// declarations. If it is declared inside a compound statement, its effect +// stops at the end of the innermost statement it was declared +// in. Precision statements in nested scopes override precision statements +// in outer scopes. Multiple precision statements for the same basic type +// can appear inside the same scope, with later statements overriding +// earlier statements within that scope." +// +// The default precision set inside the function is no longer in scope when y +// is declared. + +#version 100 + +void f() +{ + precision mediump float; + float x; +} + +float y; diff --git a/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-03.frag b/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-03.frag new file mode 100644 index 000000000..1cd09e4a6 --- /dev/null +++ b/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-03.frag @@ -0,0 +1,34 @@ +// [config] +// expect_result: fail +// glsl_version: 1.00 +// [end config] +// +// Section 4.5.3 (Default Precision Qualifiers) of the GLSL ES 1.00 spec says: +// +// "Non-precision qualified declarations will use the precision qualifier +// specified in the most recent precision statement that is still in +// scope. The precision statement has the same scoping rules as variable +// declarations. If it is declared inside a compound statement, its effect +// stops at the end of the innermost statement it was declared +// in. Precision statements in nested scopes override precision statements +// in outer scopes. Multiple precision statements for the same basic type +// can appear inside the same scope, with later statements overriding +// earlier statements within that scope." +// +// The default precision set inside the if-statement in the function is no +// longer in scope when x is declared. + +#version 100 + +uniform bool b; + +void f() +{ + if (b) { + precision mediump float; + } + + float x; +} + +mediump float y; diff --git a/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-04.frag b/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-04.frag new file mode 100644 index 000000000..2abc8b536 --- /dev/null +++ b/tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-04.frag @@ -0,0 +1,33 @@ +// [config] +// expect_result: pass +// glsl_version: 1.00 +// [end config] +// +// Section 4.5.3 (Default Precision Qualifiers) of the GLSL ES 1.00 spec says: +// +// "Non-precision qualified declarations will use the precision qualifier +// specified in the most recent precision statement that is still in +// scope. The precision statement has the same scoping rules as variable +// declarations. If it is declared inside a compound statement, its effect +// stops at the end of the innermost statement it was declared +// in. Precision statements in nested scopes override precision statements +// in outer scopes. Multiple precision statements for the same basic type +// can appear inside the same scope, with later statements overriding +// earlier statements within that scope." + +#version 100 + +uniform bool b; + +void f() +{ + precision lowp float; + if (b) { + precision mediump float; + float a; + } + + float x; +} + +mediump float y; |