skia2/tests/sksl/folding/BoolFolding.sksl
John Stiles 26fdcbb38b Implement constant folding for (bool == bool) and (bool != bool).
We already had support for &&, ||, ^^ but somehow the common cases of
== and != were not implemented in the constant-folder.

This CL also updates the test to return a green/red color on success or
failure, instead of assigning arbitrary numbers into sk_FragColor that
don't mean anything. The long-term plan is to signal success or failure
of each test by color code; we can display these colors as swatches in a
GM slide for testing purposes.

Change-Id: I0810108b3c6b656a60cd8aa64ceefd765eff0157
Bug: skia:11112
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/355984
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-20 14:22:35 +00:00

19 lines
452 B
Plaintext

bool test() {
bool a = 1 == 1 || 2 == 8;
bool b = 1 > 1 || 2 == 8;
bool c = 1 == 1 && 2 <= 8;
bool d = 1 == 2 && 2 == 8;
bool e = 1 == 1 ^^ 1 != 1;
bool f = 1 == 1 ^^ 1 == 1;
bool g = true == true;
bool h = false == true;
bool i = true == !false;
bool j = false == !false;
return a && !b && c && !d && e && !f && g && !h && i && !j;
}
half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1);
}