Files
wgpu/tests/out/msl/control-flow.msl
T
Hans Christian Schmitz 8417f849b1 Fix GLSL output for non-fallthrough switch cases (#1310)
* Fix GLSL output for non-fallthrough switch cases

Partially reverts 02c74b5002 and
fixes #1309.

* Fix indentation of control-flow WGSL code

* Clean up glsl-out switch case fallthrough handling

Only insert a break if needed
and if a case is fallthrough, insert a comment indicating this.
2021-08-31 17:48:28 -04:00

104 lines
1.6 KiB
Plaintext

// language: metal1.1
#include <metal_stdlib>
#include <simd/simd.h>
void switch_default_break(
int i
) {
switch(i) {
default: {
break;
}
}
}
void switch_case_break(
) {
switch(0) {
case 0: {
break;
break;
}
default: {
}
}
return;
}
void loop_switch_continue(
int x
) {
while(true) {
switch(x) {
case 1: {
continue;
break;
}
default: {
}
}
}
return;
}
struct main1Input {
};
kernel void main1(
metal::uint3 global_id [[thread_position_in_grid]]
) {
int pos;
metal::threadgroup_barrier(metal::mem_flags::mem_device);
metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup);
switch(1) {
default: {
pos = 1;
}
}
int _e4 = pos;
switch(_e4) {
case 1: {
pos = 0;
break;
break;
}
case 2: {
pos = 1;
break;
}
case 3: {
pos = 2;
}
case 4: {
break;
}
default: {
pos = 3;
}
}
int _e9 = pos;
switch(_e9) {
case 1: {
pos = 0;
break;
break;
}
case 2: {
pos = 1;
return;
break;
}
case 3: {
pos = 2;
}
case 4: {
return;
break;
}
default: {
pos = 3;
return;
}
}
}