skia2/resources/sksl/shared/StaticSwitchWithContinue.sksl
John Stiles f3a28db703 Eliminate control-flow analysis.
We no longer derive a performance benefit from this pass in practice,
and it is a very expensive compilation step. It is also prone to fuzz-
related errors.

Doc: http://go/optimization-in-sksl

Change-Id: Ief08ffac659a8fe7fe92c92b9a5da14c9f713bc2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/381261
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-11 13:24:54 +00:00

23 lines
743 B
Plaintext

// A continue inside a switch (where permitted) prevents fallthrough to the next case block, just
// like a break statement would.
// Make sure that we properly dead-strip code following `continue` in a switch.
// This is particularly relevant because our inliner replaces return statements with continue.
uniform half4 colorGreen, colorRed;
half4 main() {
// A looping construct is required for continue.
float result = 0;
for (int x=0; x<=1; x++) {
@switch (2) {
case 1: result = abs(1); continue;
case 2: result = abs(2); continue;
case 3: result = abs(3); continue;
case 4: result = abs(4); continue;
}
}
return result == 2 ? colorGreen : colorRed;
}