skia2/resources/sksl/folding/SwitchCaseFolding.sksl
John Stiles 866db186fa Simplify control flow in switch test to unbreak iOS.
This looks like the GLSL driver in iOS generates wrong results when
returning a value from inside a switch.

Change-Id: I478a045c64c3dae9824f86f52e0c7f8f9685c9af
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/494476
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-01-13 14:49:06 +00:00

21 lines
681 B
Plaintext

uniform half4 colorRed, colorGreen;
half4 main(float2 coords) {
half4 color = colorRed;
const int three = 3;
const int3 vecFour = int3(4);
switch (int(colorGreen.g)) {
case vecFour.000x.y: break; // case 0
case int4(1, 2, 3, 4).x: color = colorGreen; break; // case 1
case int(max(-5.5, 2.0)): break; // case 2
case three: break; // case 3
case vecFour.yz01.x: break; // case 4
case 2 * 3 - 1: break; // case 5
default: break;
}
return color;
}