2021-01-26 21:28:12 +00:00
|
|
|
uniform half4 colorRed, colorGreen;
|
|
|
|
uniform half unknownInput;
|
|
|
|
|
2021-01-22 14:51:13 +00:00
|
|
|
bool test_half() {
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
// Vector op scalar
|
|
|
|
half4 x = half4(half2(1), half2(2, 3)) + 5;
|
|
|
|
ok = ok && (x == half4(6, 6, 7, 8));
|
|
|
|
x = half4(8, half3(10)) - 1;
|
|
|
|
ok = ok && (x == half4(7, 9, 9, 9));
|
|
|
|
x = half4(half2(8), half2(9)) + 1;
|
|
|
|
ok = ok && (x == half4(9, 9, 10, 10));
|
|
|
|
x.xyz = half3(2) * 3;
|
|
|
|
ok = ok && (x == half4(6, 6, 6, 10));
|
|
|
|
x.xy = half2(12) / 4;
|
|
|
|
ok = ok && (x == half4(3, 3, 6, 10));
|
|
|
|
|
|
|
|
// (Vector op scalar).swizzle
|
|
|
|
x = (half4(12) / 2).yxwz;
|
|
|
|
ok = ok && (x == half4(6));
|
|
|
|
|
|
|
|
// Scalar op vector
|
|
|
|
x = 5 + half4(half2(1), half2(2, 3));
|
|
|
|
ok = ok && (x == half4(6, 6, 7, 8));
|
|
|
|
x = 1 - half4(8, half3(10));
|
|
|
|
ok = ok && (x == half4(-7, -9, -9, -9));
|
|
|
|
x = 1 + half4(half2(8), half2(9));
|
|
|
|
ok = ok && (x == half4(9, 9, 10, 10));
|
|
|
|
x.xyz = 3 * half3(2);
|
|
|
|
ok = ok && (x == half4(6, 6, 6, 10));
|
|
|
|
x.xy = 4 / half2(0.5);
|
|
|
|
ok = ok && (x == half4(8, 8, 6, 10));
|
|
|
|
x = 20 / half4(10, 20, 40, 80);
|
|
|
|
ok = ok && (x == half4(2, 1, 0.5, 0.25));
|
|
|
|
|
|
|
|
// (Scalar op vector).swizzle
|
|
|
|
x = (12 / half4(2)).yxwz;
|
|
|
|
ok = ok && (x == half4(6));
|
|
|
|
|
|
|
|
// Vector op unknown scalar
|
2021-01-26 21:28:12 +00:00
|
|
|
half unknown = unknownInput;
|
2021-01-22 14:51:13 +00:00
|
|
|
x = half4(0) + unknown;
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
x = half4(0) * unknown;
|
|
|
|
ok = ok && (x == half4(0));
|
|
|
|
x = half4(0) / unknown;
|
|
|
|
ok = ok && (x == half4(0));
|
|
|
|
x = half4(1) * unknown;
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
|
|
|
|
// Unknown scalar op vector
|
|
|
|
x = unknown * half4(1);
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
x = unknown + half4(0);
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
x = unknown - half4(0);
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
x = unknown / half4(1);
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
|
|
|
|
// Scalar op unknown vector
|
|
|
|
x = 0 + half4(unknown);
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
x = 0 * half4(unknown);
|
|
|
|
ok = ok && (x == half4(0));
|
2021-08-24 18:13:16 +00:00
|
|
|
x = 0 / half4(unknown); // this should NOT optimize away
|
2021-01-22 14:51:13 +00:00
|
|
|
ok = ok && (x == half4(0));
|
|
|
|
x = 1 * half4(unknown);
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
|
2021-02-06 00:12:27 +00:00
|
|
|
// X = Unknown op scalar
|
2021-01-22 14:51:13 +00:00
|
|
|
x = half4(unknown) + 0;
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
x = half4(unknown) * 0;
|
|
|
|
ok = ok && (x == half4(0));
|
|
|
|
x = half4(unknown) * 1;
|
2021-01-25 15:57:47 +00:00
|
|
|
ok = ok && (x == half4(unknown));
|
2021-01-22 14:51:13 +00:00
|
|
|
x = half4(unknown) - 0;
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
|
2021-02-06 00:12:27 +00:00
|
|
|
// X op= scalar.
|
|
|
|
x = half4(unknown);
|
|
|
|
x += 1;
|
|
|
|
x += 0;
|
|
|
|
x -= 1;
|
|
|
|
x -= 0;
|
|
|
|
x *= 1;
|
|
|
|
x /= 1;
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
|
|
|
|
// X = X op scalar.
|
|
|
|
x = half4(unknown);
|
|
|
|
x = x + 1;
|
|
|
|
x = x + 0;
|
|
|
|
x = x - 1;
|
|
|
|
x = x - 0;
|
|
|
|
x = x * 1;
|
|
|
|
x = x / 1;
|
|
|
|
ok = ok && (x == half4(unknown));
|
|
|
|
|
2021-01-22 14:51:13 +00:00
|
|
|
return ok;
|
2021-01-11 16:07:01 +00:00
|
|
|
}
|
|
|
|
|
2021-01-22 14:51:13 +00:00
|
|
|
bool test_int() {
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
// Vector op scalar
|
|
|
|
int4 x = int4(int2(1), int2(2, 3)) + 5;
|
|
|
|
ok = ok && (x == int4(6, 6, 7, 8));
|
|
|
|
x = int4(8, int3(10)) - 1;
|
|
|
|
ok = ok && (x == int4(7, 9, 9, 9));
|
|
|
|
x = int4(int2(8), int2(9)) + 1;
|
|
|
|
ok = ok && (x == int4(9, 9, 10, 10));
|
|
|
|
x.xyz = int3(2) * 3;
|
|
|
|
ok = ok && (x == int4(6, 6, 6, 10));
|
|
|
|
x.xy = int2(12) / 4;
|
|
|
|
ok = ok && (x == int4(3, 3, 6, 10));
|
|
|
|
|
|
|
|
// (Vector op scalar).swizzle
|
|
|
|
x = (int4(12) / 2).yxwz;
|
|
|
|
ok = ok && (x == int4(6));
|
|
|
|
|
|
|
|
// Scalar op vector
|
|
|
|
x = 5 + int4(int2(1), int2(2, 3));
|
|
|
|
ok = ok && (x == int4(6, 6, 7, 8));
|
|
|
|
x = 1 - int4(8, int3(10));
|
|
|
|
ok = ok && (x == int4(-7, -9, -9, -9));
|
|
|
|
x = 1 + int4(int2(8), int2(9));
|
|
|
|
ok = ok && (x == int4(9, 9, 10, 10));
|
|
|
|
x.xyz = 3 * int3(2);
|
|
|
|
ok = ok && (x == int4(6, 6, 6, 10));
|
|
|
|
x.xy = 16 / int2(2);
|
|
|
|
ok = ok && (x == int4(8, 8, 6, 10));
|
|
|
|
x = 2000 / int4(10, 20, 40, 80);
|
|
|
|
ok = ok && (x == int4(200, 100, 50, 25));
|
|
|
|
|
|
|
|
// (Scalar op vector).swizzle
|
|
|
|
x = (12 / int4(2)).yxwz;
|
|
|
|
ok = ok && (x == int4(6));
|
|
|
|
|
|
|
|
// Vector op unknown scalar
|
2021-01-26 21:28:12 +00:00
|
|
|
int unknown = int(unknownInput);
|
2021-01-22 14:51:13 +00:00
|
|
|
x = int4(0) + unknown;
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
x = int4(0) * unknown;
|
|
|
|
ok = ok && (x == int4(0));
|
|
|
|
x = int4(0) / unknown;
|
|
|
|
ok = ok && (x == int4(0));
|
|
|
|
x = int4(1) * unknown;
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
|
|
|
|
// Unknown scalar op vector
|
|
|
|
x = unknown * int4(1);
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
x = unknown + int4(0);
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
x = unknown - int4(0);
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
x = unknown / int4(1);
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
|
|
|
|
// Scalar op unknown vector
|
|
|
|
x = 0 + int4(unknown);
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
x = 0 * int4(unknown);
|
|
|
|
ok = ok && (x == int4(0));
|
|
|
|
x = 0 / int4(unknown);
|
|
|
|
ok = ok && (x == int4(0));
|
|
|
|
x = 1 * int4(unknown);
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
|
|
|
|
// Unknown vector op scalar
|
|
|
|
x = int4(unknown) + 0;
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
x = int4(unknown) * 0;
|
|
|
|
ok = ok && (x == int4(0));
|
|
|
|
x = int4(unknown) * 1;
|
2021-01-25 15:57:47 +00:00
|
|
|
ok = ok && (x == int4(unknown));
|
2021-01-22 14:51:13 +00:00
|
|
|
x = int4(unknown) - 0;
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
|
2021-02-06 00:12:27 +00:00
|
|
|
// X op= scalar.
|
|
|
|
x = int4(unknown);
|
|
|
|
x += 1;
|
|
|
|
x += 0;
|
|
|
|
x -= 1;
|
|
|
|
x -= 0;
|
|
|
|
x *= 1;
|
|
|
|
x /= 1;
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
|
|
|
|
// X = X op scalar.
|
|
|
|
x = int4(unknown);
|
|
|
|
x = x + 1;
|
|
|
|
x = x + 0;
|
|
|
|
x = x - 1;
|
|
|
|
x = x - 0;
|
|
|
|
x = x * 1;
|
|
|
|
x = x / 1;
|
|
|
|
ok = ok && (x == int4(unknown));
|
|
|
|
|
2021-01-22 14:51:13 +00:00
|
|
|
return ok;
|
2021-01-11 16:07:01 +00:00
|
|
|
}
|
|
|
|
|
2021-04-21 18:27:08 +00:00
|
|
|
half4 main(float2 coords) {
|
2021-01-26 21:28:12 +00:00
|
|
|
return test_half() && test_int() ? colorGreen : colorRed;
|
2021-01-11 16:07:01 +00:00
|
|
|
}
|