2021-11-04 21:38:35 +00:00
|
|
|
/*#pragma settings SkVMDebugTrace*/
|
|
|
|
|
2021-09-04 18:44:19 +00:00
|
|
|
uniform half4 colorRed, colorGreen;
|
|
|
|
|
2021-01-13 22:17:56 +00:00
|
|
|
// Should return 5
|
2021-09-23 15:36:15 +00:00
|
|
|
const float kZero = 0;
|
2021-11-12 13:45:31 +00:00
|
|
|
float return_loop(float five) {
|
2021-09-23 15:36:15 +00:00
|
|
|
for (float i = kZero; i < 10; ++i) {
|
2021-11-12 13:45:31 +00:00
|
|
|
if (i == five) { return i; }
|
2021-01-13 22:17:56 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Should return 35
|
2021-09-23 15:36:15 +00:00
|
|
|
const float kTen = kZero + 10;
|
2021-11-12 13:45:31 +00:00
|
|
|
float continue_loop(float five) {
|
2021-01-13 22:17:56 +00:00
|
|
|
float sum = 0;
|
2021-09-23 15:36:15 +00:00
|
|
|
for (float i = 0; i < kTen; ++i) {
|
2021-11-12 13:45:31 +00:00
|
|
|
if (i < five) { continue; }
|
2021-01-13 22:17:56 +00:00
|
|
|
sum += i;
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Should return 15
|
2021-11-12 13:45:31 +00:00
|
|
|
float break_loop(float five) {
|
2021-01-13 22:17:56 +00:00
|
|
|
float sum = 0;
|
2021-09-23 15:36:15 +00:00
|
|
|
const float kOne = 1;
|
|
|
|
for (float i = 0; i < 10; i += kOne) {
|
2021-11-12 13:45:31 +00:00
|
|
|
if (i > five) { break; }
|
2021-01-13 22:17:56 +00:00
|
|
|
sum += i;
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
2021-09-04 18:44:19 +00:00
|
|
|
// Should return a value close to zero
|
2021-01-13 22:17:56 +00:00
|
|
|
float float_loop() {
|
|
|
|
float sum = 0;
|
|
|
|
for (float i = 0.123; i < 0.6; i += 0.111) {
|
|
|
|
sum += i;
|
|
|
|
}
|
2021-09-04 18:44:19 +00:00
|
|
|
return sum - 1.725;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool loop_operator_le() {
|
|
|
|
// These loops are inside-out and execute zero times.
|
|
|
|
for (float i = 3; i <= 1; ++i) { return false; }
|
|
|
|
for (float i = 3; i <= 1; --i) { return false; }
|
|
|
|
|
|
|
|
float4 result = float4(9);
|
|
|
|
for (float i = 1; i <= 3; ++i) {
|
|
|
|
result = float4(result.yzw, i);
|
|
|
|
}
|
|
|
|
return result == float4(9, 1, 2, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool loop_operator_lt() {
|
|
|
|
// These loops are inside-out and execute zero times.
|
|
|
|
for (float i = 4; i < 1; ++i) { return false; }
|
|
|
|
for (float i = 4; i < 1; --i) { return false; }
|
|
|
|
|
|
|
|
float4 result = float4(9);
|
|
|
|
for (float i = 1; i < 4; ++i) {
|
|
|
|
result = float4(result.yzw, i);
|
|
|
|
}
|
|
|
|
return result == float4(9, 1, 2, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool loop_operator_ge() {
|
|
|
|
// These loops are inside-out and execute zero times.
|
|
|
|
for (float i = 1; i >= 3; ++i) { return false; }
|
|
|
|
for (float i = 1; i >= 3; --i) { return false; }
|
|
|
|
|
|
|
|
float4 result = float4(9);
|
|
|
|
for (float i = 3; i >= 1; --i) {
|
|
|
|
result = float4(result.yzw, i);
|
|
|
|
}
|
|
|
|
return result == float4(9, 3, 2, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool loop_operator_gt() {
|
|
|
|
// These loops are inside-out and execute zero times.
|
|
|
|
for (float i = 0; i > 3; ++i) { return false; }
|
|
|
|
for (float i = 0; i > 3; --i) { return false; }
|
|
|
|
|
|
|
|
float4 result = float4(9);
|
|
|
|
for (float i = 3; i > 0; --i) {
|
|
|
|
result = float4(result.yzw, i);
|
|
|
|
}
|
|
|
|
return result == float4(9, 3, 2, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool loop_operator_ne() {
|
|
|
|
// This loop executes zero times.
|
|
|
|
for (int i = 1; i != 1; ++i) { return false; }
|
|
|
|
|
|
|
|
float4 result = float4(9);
|
|
|
|
for (float i = 1; i != 4; ++i) {
|
|
|
|
result = float4(result.yzw, i);
|
|
|
|
}
|
|
|
|
return result == float4(9, 1, 2, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool loop_operator_eq() {
|
|
|
|
// This loops mismatches and executes zero times.
|
|
|
|
for (float i = 1; i == 2; ++i) { return false; }
|
|
|
|
|
|
|
|
float4 result = float4(9);
|
|
|
|
for (float i = 1; i == 1; ++i) {
|
|
|
|
result = float4(result.yzw, i);
|
|
|
|
}
|
|
|
|
return result == float4(9, 9, 9, 1);
|
2021-01-13 22:17:56 +00:00
|
|
|
}
|
|
|
|
|
2021-11-12 13:45:31 +00:00
|
|
|
half4 main(float2 pos) {
|
|
|
|
float five = clamp(pos.x, colorGreen.g, colorGreen.a) * 5.0;
|
|
|
|
return (return_loop(five) == 5 && continue_loop(five) == 35 &&
|
|
|
|
break_loop(five) == 15 && abs(float_loop()) < 0.025 &&
|
2021-09-04 18:44:19 +00:00
|
|
|
loop_operator_le() && loop_operator_lt() &&
|
|
|
|
loop_operator_ge() && loop_operator_gt() &&
|
|
|
|
loop_operator_eq() && loop_operator_ne()) ? colorGreen : colorRed;
|
2021-01-13 22:17:56 +00:00
|
|
|
}
|