SPIRV-Cross/reference/shaders/frag/switch-unreachable-break.frag
Hans-Kristian Arntzen d08ce828f4 Promote Unreachable cases into break to avoid fallthrough.
HLSL is very fussy about fallthrough in switch blocks, so promote
Unreachable blocks to breaks if they are inside a switch construct.

Some false positives are possible in weird multi-break scenarios, but
this is benign.
2022-05-18 18:36:32 +02:00

37 lines
582 B
GLSL

#version 450
layout(binding = 0, std140) uniform UBO
{
int cond;
int cond2;
} _13;
layout(location = 0) out vec4 FragColor;
void main()
{
bool frog = false;
switch (_13.cond)
{
case 1:
{
if (_13.cond2 < 50)
{
break;
}
else
{
discard;
}
break; // unreachable workaround
}
default:
{
frog = true;
break;
}
}
FragColor = mix(vec4(20.0), vec4(10.0), bvec4(frog));
}