448b2d5795
Prior to this fix, the new test cases would report that the various loop terms needed to be constant expressions. Bug: skia:12472 Change-Id: Ic377ed0c4598136ae38fb2b65c93b6d8609d54cb Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452276 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
110 lines
2.7 KiB
Plaintext
110 lines
2.7 KiB
Plaintext
uniform half4 colorRed, colorGreen;
|
|
|
|
// Should return 5
|
|
const int kZero = 0;
|
|
int return_loop() {
|
|
for (int i = kZero; i < 10; ++i) {
|
|
if (i == 5) { return i; }
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// Should return 35
|
|
const int kTen = kZero + 10;
|
|
int continue_loop() {
|
|
int sum = 0;
|
|
for (int i = 0; i < kTen; ++i) {
|
|
if (i < 5) { continue; }
|
|
sum += i;
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
// Should return 15
|
|
int break_loop() {
|
|
int sum = 0;
|
|
const int kOne = 1;
|
|
for (int i = 0; i < 10; i += kOne) {
|
|
if (i > 5) { break; }
|
|
sum += i;
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
bool loop_operator_le() {
|
|
// These loops are inside-out and execute zero times.
|
|
for (int i = 3; i <= 1; ++i) { return false; }
|
|
for (int i = 3; i <= 1; --i) { return false; }
|
|
|
|
int4 result = int4(9);
|
|
for (int i = 1; i <= 3; ++i) {
|
|
result = int4(result.yzw, i);
|
|
}
|
|
return result == int4(9, 1, 2, 3);
|
|
}
|
|
|
|
bool loop_operator_lt() {
|
|
// These loops are inside-out and execute zero times.
|
|
for (int i = 4; i < 1; ++i) { return false; }
|
|
for (int i = 4; i < 1; --i) { return false; }
|
|
|
|
int4 result = int4(9);
|
|
for (int i = 1; i < 4; ++i) {
|
|
result = int4(result.yzw, i);
|
|
}
|
|
return result == int4(9, 1, 2, 3);
|
|
}
|
|
|
|
bool loop_operator_ge() {
|
|
// These loops are inside-out and execute zero times.
|
|
for (int i = 1; i >= 3; ++i) { return false; }
|
|
for (int i = 1; i >= 3; --i) { return false; }
|
|
|
|
int4 result = int4(9);
|
|
for (int i = 3; i >= 1; --i) {
|
|
result = int4(result.yzw, i);
|
|
}
|
|
return result == int4(9, 3, 2, 1);
|
|
}
|
|
|
|
bool loop_operator_gt() {
|
|
// These loops are inside-out and execute zero times.
|
|
for (int i = 0; i > 3; ++i) { return false; }
|
|
for (int i = 0; i > 3; --i) { return false; }
|
|
|
|
int4 result = int4(9);
|
|
for (int i = 3; i > 0; --i) {
|
|
result = int4(result.yzw, i);
|
|
}
|
|
return result == int4(9, 3, 2, 1);
|
|
}
|
|
|
|
bool loop_operator_ne() {
|
|
// This loop executes zero times.
|
|
for (int i = 1; i != 1; ++i) { return false; }
|
|
|
|
int4 result = int4(9);
|
|
for (int i = 1; i != 4; ++i) {
|
|
result = int4(result.yzw, i);
|
|
}
|
|
return result == int4(9, 1, 2, 3);
|
|
}
|
|
|
|
bool loop_operator_eq() {
|
|
// This loop executes zero times.
|
|
for (int i = 1; i == 2; ++i) { return false; }
|
|
|
|
int4 result = int4(9);
|
|
for (int i = 1; i == 1; ++i) {
|
|
result = int4(result.yzw, i);
|
|
}
|
|
return result == int4(9, 9, 9, 1);
|
|
}
|
|
|
|
half4 main(float2 xy) {
|
|
return (return_loop() == 5 && continue_loop() == 35 && break_loop() == 15 &&
|
|
loop_operator_le() && loop_operator_lt() &&
|
|
loop_operator_ge() && loop_operator_gt() &&
|
|
loop_operator_eq() && loop_operator_ne()) ? colorGreen : colorRed;
|
|
}
|