7bb100ec04
This is similar to the intrinsic optimization for any() and all(). Tests for all three intrinsics have been bulked up a bit as well. Change-Id: I262b9448e543b4709d1e7c8585f74a206c4b5abd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406576 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
31 lines
1.1 KiB
Plaintext
31 lines
1.1 KiB
Plaintext
uniform half4 colorRed, colorGreen;
|
|
|
|
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;
|
|
|
|
const bool TRUE = true;
|
|
const bool FALSE = false;
|
|
bool k = all(bool4(1 == 1, !false, 123 > 12, TRUE)); // all are true
|
|
bool l = all(bool3(TRUE, 1 == 2, true)); // three out of four are true
|
|
bool m = any(bool4(true, 1 == 2, true, TRUE)); // three out of four are true
|
|
bool n = any(bool2(0 == 1, FALSE)); // none are true
|
|
bool o = any(not(bool2(0 == 1, FALSE))); // all true
|
|
bool p = all(not(bool4(1 == 1, !false, 123 > 12, TRUE))); // none are true
|
|
|
|
return a && !b && c && !d && e && !f && g && !h && i && !j && k && !l && m && !n && o && !p;
|
|
}
|
|
|
|
half4 main(float2 coords) {
|
|
return test() ? colorGreen : colorRed;
|
|
}
|
|
|