skia2/resources/sksl/folding/ArrayFolding.sksl
John Stiles 8037c9e2ed Add test for folding of == and != for arrays.
We don't directly support this today at all. In practice, though, simple
constant arrays are detected as equal in the constant-folding pass
because they hit the `x == x` self-equality check (using
`IsSameExpressionTree`).

This does not work for our inequality tests, though, so those do not
fold.

Change-Id: I6730a9a2d1da9ac613ee58889d651f3ff65b1d2d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391057
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-31 15:32:03 +00:00

15 lines
294 B
Plaintext

uniform half4 colorRed, colorGreen;
bool test() {
const int x [3] = int[3](1, 2, 3);
const int xx[3] = int[3](1, 2, 3);
const int y [3] = int[3](1, 2, 4);
return (x == xx) && !(x != xx) && (x != y) && !(x == y);
}
half4 main() {
return test() ? colorGreen : colorRed;
}