blob: f625437ea95584f897f22d4fa91cf1839d4455a9 [file] [log] [blame]
John Stiles56233d12021-02-03 13:03:29 -05001uniform half4 colorGreen, colorRed;
2
3bool test_float() {
John Stiles465da152021-05-13 11:30:22 -04004 bool ok = true;
John Stiles56233d12021-02-03 13:03:29 -05005
6 float2x2 m1 = float2x2(float4(1, 2, 3, 4));
John Stiles465da152021-05-13 11:30:22 -04007 ok = ok && (m1 == float2x2(1, 2, 3, 4));
John Stiles86121f62021-05-12 11:01:37 -04008
John Stiles465da152021-05-13 11:30:22 -04009 // This generates {5, 0, 0, 5} on some Radeon GPUs.
10// float2x2 m2 = float2x2(float4(5));
11// ok = ok && (m2 == float2x2(5, 5, 5, 5));
12
13 float2x2 m3 = float2x2(m1);
14 ok = ok && (m3 == float2x2(1, 2, 3, 4));
15
16 float2x2 m4 = float2x2(6);
17 ok = ok && (m4 == float2x2(6, 0, 0, 6));
18
19 m3 *= m4;
20 ok = ok && (m3 == float2x2(6, 12, 18, 24));
21
22 float2x2 m5 = float2x2(m1[1][1]);
23 ok = ok && (m5 == float2x2(4, 0, 0, 4));
24
25 m1 += m5;
26 ok = ok && (m1 == float2x2(5, 2, 3, 8));
27
28 float2x2 m7 = float2x2(5, float3(6, 7, 8));
29 ok = ok && (m7 == float2x2(5, 6, 7, 8));
30
31 float3x3 m9 = float3x3(9);
32 ok = ok && (m9 == float3x3(9, 0, 0, 0, 9, 0, 0, 0, 9));
33
34 float4x4 m10 = float4x4(11);
35 ok = ok && (m10 == float4x4(11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11));
36
37 float4x4 m11 = float4x4(20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20);
38 m11 -= m10;
39 ok = ok && (m11 == float4x4(9, 20, 20, 20, 20, 9, 20, 20, 20, 20, 9, 20, 20, 20, 20, 9));
40
41 return ok;
John Stiles56233d12021-02-03 13:03:29 -050042}
43
44bool test_half() {
John Stiles465da152021-05-13 11:30:22 -040045 bool ok = true;
John Stiles56233d12021-02-03 13:03:29 -050046
47 half2x2 m1 = half2x2(half4(1, 2, 3, 4));
John Stiles465da152021-05-13 11:30:22 -040048 ok = ok && (m1 == half2x2(1, 2, 3, 4));
John Stiles86121f62021-05-12 11:01:37 -040049
John Stiles465da152021-05-13 11:30:22 -040050 // This generates {5, 0, 0, 5} on some Radeon GPUs.
51// half2x2 m2 = half2x2(half4(5));
52// ok = ok && (m2 == half2x2(5, 5, 5, 5));
53
54 half2x2 m3 = half2x2(m1);
55 ok = ok && (m3 == half2x2(1, 2, 3, 4));
56
57 half2x2 m4 = half2x2(6);
58 ok = ok && (m4 == half2x2(6, 0, 0, 6));
59
60 m3 *= m4;
61 ok = ok && (m3 == half2x2(6, 12, 18, 24));
62
63 half2x2 m5 = half2x2(m1[1][1]);
64 ok = ok && (m5 == half2x2(4, 0, 0, 4));
65
66 m1 += m5;
67 ok = ok && (m1 == half2x2(5, 2, 3, 8));
68
69 half2x2 m7 = half2x2(5, half3(6, 7, 8));
70 ok = ok && (m7 == half2x2(5, 6, 7, 8));
71
72 half3x3 m9 = half3x3(9);
73 ok = ok && (m9 == half3x3(9, 0, 0, 0, 9, 0, 0, 0, 9));
74
75 half4x4 m10 = half4x4(11);
76 ok = ok && (m10 == half4x4(11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11));
77
78 half4x4 m11 = half4x4(20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20);
79 m11 -= m10;
80 ok = ok && (m11 == half4x4(9, 20, 20, 20, 20, 9, 20, 20, 20, 20, 9, 20, 20, 20, 20, 9));
81
82 return ok;
John Stiles56233d12021-02-03 13:03:29 -050083}
84
John Stiles6011bbc2021-05-19 22:56:18 -040085bool test_comma() {
86 float2x2 x, y;
87 return (x = float2x2(1, 2, 3, 4),
88 y = 0.5 * float2x2(2, 4, 6, 8),
89 x == y);
90}
91
Brian Osman169c8902021-04-21 14:27:08 -040092half4 main(float2 coords) {
John Stiles6011bbc2021-05-19 22:56:18 -040093 return test_float() && test_half() && test_comma() ? colorGreen : colorRed;
John Stiles56233d12021-02-03 13:03:29 -050094}