summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2017-07-05 20:02:44 -0400
committerIlia Mirkin <imirkin@alum.mit.edu>2017-07-05 23:24:44 -0400
commita0d7d1cfc0fdf39c758c903cf790875577c3ec88 (patch)
tree92944b82281af433cadb1693d7b9ddd3b54f5292
parent65f385e7fe6086ddd088c51e767ee60c2344cec8 (diff)
es3: add tests for verifying overloading behavior
An existing bug in mesa made it so that overloads of any functions that might be builtins in any language version or extension would not be overridable in ESSL 3.00 shaders. This adds tests to ensure that builtins available in ESSL 3.00 are rejected properly, but builtins from future versions or non-enabled (or available) extensions are allowed to be specified. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
-rw-r--r--tests/spec/glsl-es-3.00/compiler/overload-builtin.frag14
-rw-r--r--tests/spec/glsl-es-3.00/compiler/overload-future-builtin.frag15
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/spec/glsl-es-3.00/compiler/overload-builtin.frag b/tests/spec/glsl-es-3.00/compiler/overload-builtin.frag
new file mode 100644
index 000000000..8ed837655
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/overload-builtin.frag
@@ -0,0 +1,14 @@
+// [config]
+// expect_result: fail
+// glsl_version: 3.00
+// [end config]
+//
+// Check that builtins may not be overloaded, even with different parameters.
+//
+// From GLSL ES 3.0 spec, chapter 6.1 "Function Definitions", page 71:
+//
+// "A shader cannot redefine or overload built-in functions."
+//
+#version 300 es
+
+int sqrt(int x) { return x; }
diff --git a/tests/spec/glsl-es-3.00/compiler/overload-future-builtin.frag b/tests/spec/glsl-es-3.00/compiler/overload-future-builtin.frag
new file mode 100644
index 000000000..a3b3ae1cf
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/overload-future-builtin.frag
@@ -0,0 +1,15 @@
+// [config]
+// expect_result: pass
+// glsl_version: 3.00
+// [end config]
+//
+// Check that builtins that are not available in ESSL 3.00 may be defined
+// or overloaded as needed.
+//
+#version 300 es
+precision highp float;
+
+int bitfieldExtract(int x) { return x; }
+int imageAtomicAdd(int x) { return x; }
+void barrier() { }
+uint packUnorm4x8(vec4 v) { return uint(v.x); }