skia2/resources/sksl/shared/ForLoopControlFlow.sksl
John Stiles b41d5bb3a7 Add helper uniforms to Runtime Effect tests.
This lets us use descriptive names like `colorRed` and `colorGreen`
instead of `half4(1,0,0,1)` and `half4(0,1,0,1)`. It also lets us use
actual unknown values instead of synthesizing sorta-kinda-unknowns by
calling sqrt.

Change-Id: I61481c33b7ff42182955777b05cfa5fcc13e0efc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359567
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-27 00:53:46 +00:00

22 lines
448 B
Plaintext

uniform half4 colorWhite;
half4 main() {
half4 x = colorWhite;
// Verify that break is allowed in a for loop.
for (half r = -5; r < 5; r += 1) {
x.r = abs(r);
if (x.r == 0) break;
}
// Verify that continue is allowed in a for loop.
for (half b = 5; b >= 0; b -= 1) {
x.b = b;
if (x.a == 1) continue; // should always happen
x.g = 0;
}
// x contains green.
return x;
}