summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Forbes <chrisf@ijw.co.nz>2014-09-07 22:15:07 +1200
committerMarek Olšák <marek.olsak@amd.com>2015-07-27 12:27:41 +0200
commit332ba36d4e9a785bfe9f8045b42dff0a6af75d6b (patch)
treefce6b27d39c258c0371cf08f9c05c945fbcce82c
parenta1c980414bef722a7fc695633cb1338877f8263b (diff)
arb_tessellation_shader: split barrier-switch test
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r--tests/spec/arb_tessellation_shader/compiler/barrier-switch-always.tesc43
-rw-r--r--tests/spec/arb_tessellation_shader/compiler/barrier-switch.tesc2
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/spec/arb_tessellation_shader/compiler/barrier-switch-always.tesc b/tests/spec/arb_tessellation_shader/compiler/barrier-switch-always.tesc
new file mode 100644
index 000000000..ad8baca0b
--- /dev/null
+++ b/tests/spec/arb_tessellation_shader/compiler/barrier-switch-always.tesc
@@ -0,0 +1,43 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_tessellation_shader
+// check_link: true
+// [end config]
+
+/**
+ * From issue 42:
+ *
+ * As a result, we choose a heavy-handed approach in which we only allow
+ * calls to barrier() inside main(). Even within main, barrier() calls are
+ * forbidden inside loops (even those that turn out to have constant loop
+ * counts and don't execute "break" or "continue" statements), if
+ * statements, or after a return statement.
+ *
+ * Further, from the spec text:
+ *
+ * In particular, barrier() may not be called inside
+ * a switch statement, in either sub-statement of an if statement, inside a
+ * do, for, or while loop, or at any point after a return statement in the
+ * function main().
+ *
+ * Technically, we should disallow this usage of barrier() inside the always-taken
+ * default case -- but this is an interesting edge case for Mesa's compiler, which
+ * at this time does not express switch statements in the IR, and so an always-taken
+ * default case is indistinguishable from code outside the switch.
+ */
+
+#version 150
+#extension GL_ARB_tessellation_shader: require
+layout(vertices = 3) out;
+uniform int val;
+
+void main() {
+ gl_out[gl_InvocationID].gl_Position = vec4(0.0);
+ switch (val) {
+ default:
+ barrier();
+ }
+ gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
+ gl_TessLevelInner = float[2](1.0, 1.0);
+}
diff --git a/tests/spec/arb_tessellation_shader/compiler/barrier-switch.tesc b/tests/spec/arb_tessellation_shader/compiler/barrier-switch.tesc
index e08b7e392..2cc2cfdc6 100644
--- a/tests/spec/arb_tessellation_shader/compiler/barrier-switch.tesc
+++ b/tests/spec/arb_tessellation_shader/compiler/barrier-switch.tesc
@@ -30,6 +30,8 @@ uniform int val;
void main() {
gl_out[gl_InvocationID].gl_Position = vec4(0.0);
switch (val) {
+ case 1:
+ break;
default:
barrier();
}