[Piglit] [PATCH 3/4] glsl-es-1.00: Verify that the default precision is properly scoped
Ian Romanick
idr at freedesktop.org
Fri Aug 9 15:40:08 PDT 2013
From: Ian Romanick <ian.d.romanick at intel.com>
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 at intel.com>
---
.../default-precision-nested-scope-01.frag | 30 +++++++++++++++++++
.../default-precision-nested-scope-02.frag | 29 ++++++++++++++++++
.../default-precision-nested-scope-03.frag | 34 ++++++++++++++++++++++
.../default-precision-nested-scope-04.frag | 33 +++++++++++++++++++++
4 files changed, 126 insertions(+)
create mode 100644 tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-01.frag
create mode 100644 tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-02.frag
create mode 100644 tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-03.frag
create mode 100644 tests/spec/glsl-es-1.00/compiler/precision-qualifiers/default-precision-nested-scope-04.frag
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 0000000..b573243
--- /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 0000000..bd2a4ea
--- /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 0000000..1cd09e4
--- /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 0000000..2abc8b5
--- /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;
--
1.8.1.4
More information about the Piglit
mailing list