skia2/tests/sksl/shared/EmptyBlocksES3.glsl
John Stiles 6d0234673a Optimize away empty for loops.
The fuzzer has found that it can get timeouts in SkVM by nesting loops
very very deeply, then at the bottom of the chain, making an inside-out
loop that runs for zero iterations. This has a calculated unrolled-size
of zero, but SkVM would still think hard about unrolling the (ultimately
empty) outer loops.

SkSL now optimizes away unrollable loops that run for zero iteratinons,
as well as empty unrollable loops. This should eliminate the fuzzer's
troublesome construct entirely.

Change-Id: Ic3ef7b7a6a9fc7ee7fb13eb7bd7f34c9bff57448
Bug: oss-fuzz:39661
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456469
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-10-06 17:56:26 +00:00

12 lines
278 B
GLSL

out vec4 sk_FragColor;
uniform vec4 colorWhite;
vec4 main() {
vec4 color = vec4(0.0);
if (colorWhite.x == 1.0) color.y = 1.0;
if (colorWhite.x == 2.0) ; else color.w = 1.0;
while (colorWhite.x == 2.0) ;
do ; while (colorWhite.x == 2.0);
return color;
}