skia2/tests/sksl/shared/ForLoopMultipleInit.glsl
John Stiles f1ce6faf29 Fix for loops with multiple init-variables in GLSL.
When a Block is detected in the for loop's init-statement, we now
synthesize a scope and write the init-statement directly above the for
loop and leave the for loop's init-stmt section empty.

Change-Id: I3e89c6a4328a79e49b8a19faae7975629cd0e152
Bug: skia:11860
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396820
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-04-14 21:40:19 +00:00

30 lines
593 B
GLSL

out vec4 sk_FragColor;
vec4 main() {
vec4 result = vec4(0.0);
{
float a = 0.0;
float b = 0.0;
for (; a < 10.0 && b < 10.0; (++a , ++b)) {
result.x += a;
result.y += b;
}
}
{
int c = 0;
for (; c < 10; ++c) {
result.z += 1.0;
}
}
{
float d[2] = float[2](0.0, 10.0);
float e[4] = float[4](1.0, 2.0, 3.0, 4.0);
float f = 9.0;
for (; d[0] < d[1]; ++d[0]) {
result.w = e[0] * f;
}
}
for (; ; ) break;
return result;
}