c332739531
If x is a known compile-time constant value, it can already be optimized to a final value. If x is not known, it could be zero, and 0/0 should result in a NaN. Change-Id: I643a7c6da0a43ec366235c4df39fc78d3b361de7 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441580 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
133 lines
4.9 KiB
Plaintext
133 lines
4.9 KiB
Plaintext
uniform half unknownInput;
|
|
uniform half4 colorRed, colorGreen;
|
|
|
|
bool test_half() {
|
|
half unknown = unknownInput;
|
|
|
|
bool ok = true;
|
|
ok = ok && (half4(half2(1), half2(2, 3)) + half4(5, 6, 7, 8)) == half4(6, 7, 9, 11);
|
|
ok = ok && (half4(8, half3(10)) - half4(1)) == half4(7, 9, 9, 9);
|
|
ok = ok && (half4(2) * half4(1, 2, 3, 4)) == half4(2, 4, 6, 8);
|
|
ok = ok && (half4(12) / half4(1, 2, 3, 4)) == half4(12, 6, 4, 3);
|
|
ok = ok && !(half4(1) == half4(2));
|
|
ok = ok && (half2(1) == half2(1, 1));
|
|
ok = ok && (half2(1, 1) == half2(1, 1));
|
|
ok = ok && !(half2(1) == half2(1, 0));
|
|
ok = ok && (half4(1) == half4(half2(1), half2(1)));
|
|
ok = ok && (half4(half3(1), 1) == half4(half2(1), half2(1)));
|
|
ok = ok && !(half4(half3(1), 1) == half4(half2(1), 1, 0));
|
|
ok = ok && (half2(1) != half2(1, 0));
|
|
ok = ok && !(half4(1) != half4(half2(1), half2(1)));
|
|
ok = ok && ( half4(1) == half4(1));
|
|
ok = ok && (-half4(1) == -half4(1));
|
|
ok = ok && ( half4(1) != -half4(1));
|
|
ok = ok && (-half4(1) != half4(1));
|
|
ok = ok && ( half4(0) != -half4(1));
|
|
ok = ok && (-half4(0) != half4(1));
|
|
ok = ok && (-half4(0) != -half4(1));
|
|
ok = ok && !(-half4(1) == half4(1));
|
|
ok = ok && !( half4(1) == -half4(1));
|
|
ok = ok && !( half4(0) == half4(1));
|
|
ok = ok && !( half4(0) == -half4(1));
|
|
ok = ok && !(-half4(0) == half4(1));
|
|
ok = ok && !(-half4(0) == -half4(1));
|
|
ok = ok && !(-half4(1) != -half4(1));
|
|
ok = ok && (half4(unknown) * half4(1) == half4(unknown));
|
|
ok = ok && (half4(1) * half4(unknown) == half4(unknown));
|
|
ok = ok && (half4(unknown) * half4(0) == half4(0));
|
|
ok = ok && (half4(0) * half4(unknown) == half4(0));
|
|
ok = ok && (half4(0) / half4(unknown) == half4(0)); // this should NOT optimize away
|
|
ok = ok && (half4(unknown) + half4(0) == half4(unknown));
|
|
ok = ok && (half4(0) + half4(unknown) == half4(unknown));
|
|
ok = ok && (half4(unknown) - half4(0) == half4(unknown));
|
|
|
|
half4 val = half4(unknown);
|
|
val += half4(1);
|
|
val += half4(0);
|
|
val -= half4(1);
|
|
val -= half4(0);
|
|
val = val + half4(1);
|
|
val = val + half4(0);
|
|
val = val - half4(1);
|
|
val = val - half4(0);
|
|
ok = ok && (val == half4(unknown));
|
|
val *= half4(1);
|
|
val *= half4(2);
|
|
val /= half4(1);
|
|
val /= half4(2);
|
|
val = val * half4(1);
|
|
val = val * half4(2);
|
|
val = val / half4(1);
|
|
val = val / half4(2);
|
|
ok = ok && (val == half4(unknown));
|
|
|
|
return ok;
|
|
}
|
|
|
|
bool test_int() {
|
|
int unknown = int(unknownInput);
|
|
|
|
bool ok = true;
|
|
ok = ok && (int4(int2(1), int2(2, 3)) + int4(5, 6, 7, 8)) == int4(6, 7, 9, 11);
|
|
ok = ok && (int4(8, int3(10)) - int4(1)) == int4(7, 9, 9, 9);
|
|
ok = ok && (int4(2) * int4(1, 2, 3, 4)) == int4(2, 4, 6, 8);
|
|
ok = ok && (int4(12) / int4(1, 2, 3, 4)) == int4(12, 6, 4, 3);
|
|
ok = ok && !(int4(1) == int4(2));
|
|
ok = ok && (int2(1) == int2(1, 1));
|
|
ok = ok && (int2(1, 1) == int2(1, 1));
|
|
ok = ok && !(int2(1) == int2(1, 0));
|
|
ok = ok && (int4(1) == int4(int2(1), int2(1)));
|
|
ok = ok && (int4(int3(1), 1) == int4(int2(1), int2(1)));
|
|
ok = ok && !(int4(int3(1), 1) == int4(int2(1), 1, 0));
|
|
ok = ok && (int2(1) != int2(1, 0));
|
|
ok = ok && !(int4(1) != int4(int2(1), int2(1)));
|
|
ok = ok && ( int4(1) == int4(1));
|
|
ok = ok && (-int4(1) == -int4(1));
|
|
ok = ok && ( int4(1) != -int4(1));
|
|
ok = ok && (-int4(1) != int4(1));
|
|
ok = ok && ( int4(0) != -int4(1));
|
|
ok = ok && (-int4(0) != int4(1));
|
|
ok = ok && (-int4(0) != -int4(1));
|
|
ok = ok && !(-int4(1) == int4(1));
|
|
ok = ok && !( int4(1) == -int4(1));
|
|
ok = ok && !( int4(0) == int4(1));
|
|
ok = ok && !( int4(0) == -int4(1));
|
|
ok = ok && !(-int4(0) == int4(1));
|
|
ok = ok && !(-int4(0) == -int4(1));
|
|
ok = ok && !(-int4(1) != -int4(1));
|
|
ok = ok && (int4(unknown) * int4(1) == int4(unknown));
|
|
ok = ok && (int4(1) * int4(unknown) == int4(unknown));
|
|
ok = ok && (int4(unknown) * int4(0) == int4(0));
|
|
ok = ok && (int4(0) * int4(unknown) == int4(0));
|
|
ok = ok && (int4(0) / int4(unknown) == int4(0));
|
|
ok = ok && (int4(unknown) + int4(0) == int4(unknown));
|
|
ok = ok && (int4(0) + int4(unknown) == int4(unknown));
|
|
ok = ok && (int4(unknown) - int4(0) == int4(unknown));
|
|
|
|
int4 val = int4(unknown);
|
|
val += int4(1);
|
|
val += int4(0);
|
|
val -= int4(1);
|
|
val -= int4(0);
|
|
val = val + int4(1);
|
|
val = val + int4(0);
|
|
val = val - int4(1);
|
|
val = val - int4(0);
|
|
ok = ok && (val == int4(unknown));
|
|
val *= int4(1);
|
|
val *= int4(2);
|
|
val /= int4(1);
|
|
val /= int4(2);
|
|
val = val * int4(1);
|
|
val = val * int4(2);
|
|
val = val / int4(1);
|
|
val = val / int4(2);
|
|
ok = ok && (val == int4(unknown));
|
|
|
|
return ok;
|
|
}
|
|
|
|
half4 main(float2 coords) {
|
|
return test_half() && test_int() ? colorGreen : colorRed;
|
|
}
|