2022-04-15 09:54:15 +00:00
|
|
|
@compute @workgroup_size(1)
|
2022-01-19 15:33:06 +00:00
|
|
|
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
2021-08-31 21:48:28 +00:00
|
|
|
//TODO: execution-only barrier?
|
|
|
|
storageBarrier();
|
|
|
|
workgroupBarrier();
|
2021-08-23 02:30:22 +00:00
|
|
|
|
2021-08-31 21:48:28 +00:00
|
|
|
var pos: i32;
|
|
|
|
// switch without cases
|
2022-02-15 10:05:21 +00:00
|
|
|
switch 1 {
|
2021-08-23 02:30:22 +00:00
|
|
|
default: {
|
2021-08-31 21:48:28 +00:00
|
|
|
pos = 1;
|
|
|
|
}
|
2021-08-23 02:30:22 +00:00
|
|
|
}
|
|
|
|
|
2021-08-31 21:48:28 +00:00
|
|
|
// non-empty switch *not* in last-statement-in-function position
|
|
|
|
// (return statements might be inserted into the switch cases otherwise)
|
2022-02-15 10:05:21 +00:00
|
|
|
switch pos {
|
2021-08-31 21:48:28 +00:00
|
|
|
case 1: {
|
|
|
|
pos = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
pos = 1;
|
|
|
|
}
|
2022-11-15 13:29:11 +00:00
|
|
|
case 3, 4: {
|
2021-08-31 21:48:28 +00:00
|
|
|
pos = 2;
|
|
|
|
}
|
2022-11-15 13:29:11 +00:00
|
|
|
case 5: {
|
2021-08-31 21:48:28 +00:00
|
|
|
pos = 3;
|
2022-05-14 14:46:08 +00:00
|
|
|
}
|
2022-11-15 13:29:11 +00:00
|
|
|
case default, 6: {
|
2022-05-14 14:46:08 +00:00
|
|
|
pos = 4;
|
2021-08-31 21:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-19 21:31:38 +00:00
|
|
|
// switch with unsigned integer selectors
|
|
|
|
switch(0u) {
|
|
|
|
case 0u: {
|
|
|
|
}
|
2021-11-15 00:07:55 +00:00
|
|
|
default: {
|
|
|
|
}
|
2021-09-19 21:31:38 +00:00
|
|
|
}
|
|
|
|
|
2021-08-31 21:48:28 +00:00
|
|
|
// non-empty switch in last-statement-in-function position
|
2022-02-15 10:05:21 +00:00
|
|
|
switch pos {
|
2021-08-31 21:48:28 +00:00
|
|
|
case 1: {
|
|
|
|
pos = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
pos = 1;
|
|
|
|
}
|
|
|
|
case 3: {
|
|
|
|
pos = 2;
|
|
|
|
}
|
|
|
|
case 4: {}
|
|
|
|
default: {
|
|
|
|
pos = 3;
|
|
|
|
}
|
2021-08-23 02:30:22 +00:00
|
|
|
}
|
2021-05-03 04:18:35 +00:00
|
|
|
}
|
2021-08-27 22:44:57 +00:00
|
|
|
|
|
|
|
fn switch_default_break(i: i32) {
|
2022-02-15 10:05:21 +00:00
|
|
|
switch i {
|
2021-08-31 21:48:28 +00:00
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
2021-08-27 22:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn switch_case_break() {
|
2021-08-31 21:48:28 +00:00
|
|
|
switch(0) {
|
|
|
|
case 0: {
|
|
|
|
break;
|
|
|
|
}
|
2021-11-15 00:07:55 +00:00
|
|
|
default: {}
|
2021-08-27 22:44:57 +00:00
|
|
|
}
|
2021-08-31 21:48:28 +00:00
|
|
|
return;
|
2021-08-27 22:44:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn loop_switch_continue(x: i32) {
|
2021-08-31 21:48:28 +00:00
|
|
|
loop {
|
2022-02-15 10:05:21 +00:00
|
|
|
switch x {
|
2021-08-31 21:48:28 +00:00
|
|
|
case 1: {
|
|
|
|
continue;
|
|
|
|
}
|
2021-11-15 00:07:55 +00:00
|
|
|
default: {}
|
2021-08-31 21:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-27 22:44:57 +00:00
|
|
|
}
|