blob: d79d74fb43dd3d311fe343c52110e0c7466ebcbf [file] [log] [blame]
// TODO(skia:14082): This test is patterned after shared/LogicalOrShortCircuit.sksl, but WGSL
// doesn't yet support expressions of the form `(y += 1) == 2` as a sub-expression. This test can be
// removed once such expressions work properly.
uniform half4 colorGreen, colorRed;
int Increment(inout int y) {
y += 1;
return y;
}
noinline bool True() {
return true;
}
noinline bool False() {
return false;
}
bool TrueTrue() {
int x = 1, y = 1;
if ((x == 1 ? True() : False()) || (Increment(y) == 2)) { // LHS true, RHS not executed but would be true
return (x == 1 && y == 1);
} else {
return false;
}
}
bool TrueFalse() {
int x = 1, y = 1;
if ((x == 1 ? True() : False()) || (Increment(y) == 3)) { // LHS true, RHS not executed but would be false
return (x == 1 && y == 1);
} else {
return false;
}
}
bool FalseTrue() {
int x = 1, y = 1;
if ((x == 2 ? True() : False()) || (Increment(y) == 2)) { // LHS false, RHS is executed and is true
return (x == 1 && y == 2);
} else {
return false;
}
}
bool FalseFalse() {
int x = 1, y = 1;
if ((x == 2 ? True() : False()) || (Increment(y) == 3)) { // LHS false, RHS is executed and is false
return false;
} else {
return (x == 1 && y == 2);
}
}
half4 main(float2 coords) {
return TrueTrue() && TrueFalse() && FalseTrue() && FalseFalse() ? colorGreen : colorRed;
}