[Piglit] [PATCH 2/2] arb_gpu_shader5: Add tests for new overload resolution rules

Chris Forbes chrisf at ijw.co.nz
Fri May 16 01:20:01 PDT 2014


Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 .../arb_gpu_shader5/compiler/overloads-01.vert     | 13 +++++++++++
 .../arb_gpu_shader5/compiler/overloads-02.vert     | 14 ++++++++++++
 .../arb_gpu_shader5/compiler/overloads-03.vert     | 14 ++++++++++++
 .../arb_gpu_shader5/compiler/overloads-04.vert     | 14 ++++++++++++
 .../arb_gpu_shader5/compiler/overloads-05.vert     | 24 +++++++++++++++++++++
 .../arb_gpu_shader5/compiler/overloads-06.vert     | 25 ++++++++++++++++++++++
 .../arb_gpu_shader5/compiler/overloads-07.vert     | 24 +++++++++++++++++++++
 7 files changed, 128 insertions(+)
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/overloads-01.vert
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/overloads-02.vert
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/overloads-03.vert
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/overloads-04.vert
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/overloads-05.vert
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/overloads-06.vert
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/overloads-07.vert

diff --git a/tests/spec/arb_gpu_shader5/compiler/overloads-01.vert b/tests/spec/arb_gpu_shader5/compiler/overloads-01.vert
new file mode 100644
index 0000000..b2911e7
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/overloads-01.vert
@@ -0,0 +1,13 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// [end config]
+
+// Test that overloads which differ only by return type are not allowed.
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+int foo(int x) { return 0; }
+float foo(int x) { return 0; }		/* differs only by return type. */
diff --git a/tests/spec/arb_gpu_shader5/compiler/overloads-02.vert b/tests/spec/arb_gpu_shader5/compiler/overloads-02.vert
new file mode 100644
index 0000000..1ec6ce5
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/overloads-02.vert
@@ -0,0 +1,14 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// [end config]
+
+// If a function name is declared twice with the same parameter types,
+// then the return types _and all qualifiers_ must match.
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+void foo(int x) {}
+void foo(out int x) {}
diff --git a/tests/spec/arb_gpu_shader5/compiler/overloads-03.vert b/tests/spec/arb_gpu_shader5/compiler/overloads-03.vert
new file mode 100644
index 0000000..afead60
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/overloads-03.vert
@@ -0,0 +1,14 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// [end config]
+
+// If a function name is declared twice with the same parameter types,
+// then the return types _and all qualifiers_ must match.
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+void foo(int x) {}
+void foo(const int x) {}	/* `const` is mismatched. */
diff --git a/tests/spec/arb_gpu_shader5/compiler/overloads-04.vert b/tests/spec/arb_gpu_shader5/compiler/overloads-04.vert
new file mode 100644
index 0000000..fb0a6c9
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/overloads-04.vert
@@ -0,0 +1,14 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// [end config]
+
+// If a function name is declared twice with the same parameter types,
+// then the return types _and all qualifiers_ must match.
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+void foo(int x) {}
+void foo(precise int x) {}	/* `precise` is mismatched. */
diff --git a/tests/spec/arb_gpu_shader5/compiler/overloads-05.vert b/tests/spec/arb_gpu_shader5/compiler/overloads-05.vert
new file mode 100644
index 0000000..1486bf9
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/overloads-05.vert
@@ -0,0 +1,24 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// [end config]
+
+// Test overload resolution where all candidates require implicit
+// conversions. Under unextended GLSL 1.50, resolution is ambiguous,
+// since both functions require implicit conversions.
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+void foo(float x, int y, float z) {}
+void foo(float x, int y, int z) {}	/* better for `z` */
+
+void bar()
+{
+	int a = 0;
+	int b = 1;
+	int c = 2;
+
+	foo(a, b, c);
+}
diff --git a/tests/spec/arb_gpu_shader5/compiler/overloads-06.vert b/tests/spec/arb_gpu_shader5/compiler/overloads-06.vert
new file mode 100644
index 0000000..3cfeb95
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/overloads-06.vert
@@ -0,0 +1,25 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// [end config]
+
+// Test overload resolution where all candidates require implicit
+// conversions. Under unextended GLSL 1.50, resolution is ambiguous,
+// since both functions require implicit conversions. With ARB_gpu_shader5,
+// this case is still ambiguous, since neither function is better than the other.
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+void foo(float x, int y, float z) {}	/* better for `y` */
+void foo(float x, float y, int z) {}	/* better for `z` */
+
+void bar()
+{
+	int a = 0;
+	int b = 1;
+	int c = 2;
+
+	foo(a, b, c);
+}
diff --git a/tests/spec/arb_gpu_shader5/compiler/overloads-07.vert b/tests/spec/arb_gpu_shader5/compiler/overloads-07.vert
new file mode 100644
index 0000000..308ed4d
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/overloads-07.vert
@@ -0,0 +1,24 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// [end config]
+
+// Test overload resolution where all candidates require implicit
+// conversions. Under unextended GLSL 1.50, resolution is ambiguous,
+// since both functions require implicit conversions. With ARB_gpu_shader5,
+// this case is still ambiguous, since int->float conversion is not
+// considered better or worse than int->uint conversion.
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+void foo(float x) {}
+void foo(uint x) {}
+
+void bar()
+{
+	int x = 0;
+	foo(x);
+}
+
-- 
1.9.2



More information about the Piglit mailing list