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>
This commit is contained in:
parent
6e7d2b3b72
commit
8037c9e2ed
@ -444,6 +444,7 @@ sksl_shared_tests = [
|
||||
]
|
||||
|
||||
sksl_folding_tests = [
|
||||
"/sksl/folding/ArrayFolding.sksl",
|
||||
"/sksl/folding/AssignmentOps.sksl",
|
||||
"/sksl/folding/BoolFolding.sksl",
|
||||
"/sksl/folding/FloatFolding.sksl",
|
||||
|
14
resources/sksl/folding/ArrayFolding.sksl
Normal file
14
resources/sksl/folding/ArrayFolding.sksl
Normal file
@ -0,0 +1,14 @@
|
||||
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;
|
||||
}
|
||||
|
9
tests/sksl/folding/ArrayFolding.glsl
Normal file
9
tests/sksl/folding/ArrayFolding.glsl
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
uniform vec4 colorRed;
|
||||
uniform vec4 colorGreen;
|
||||
vec4 main() {
|
||||
const int _0_x[3] = int[3](1, 2, 3);
|
||||
const int _2_y[3] = int[3](1, 2, 4);
|
||||
return _0_x != _2_y && !(_0_x == _2_y) ? colorGreen : colorRed;
|
||||
}
|
Loading…
Reference in New Issue
Block a user