wgpu/naga/tests/in/control-flow.wgsl

91 lines
1.5 KiB
WebGPU Shading Language
Raw Normal View History

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