John Stiles | 56233d1 | 2021-02-03 13:03:29 -0500 | [diff] [blame] | 1 | uniform half4 colorGreen, colorRed; |
| 2 | |
| 3 | bool test_float() { |
John Stiles | 465da15 | 2021-05-13 11:30:22 -0400 | [diff] [blame] | 4 | bool ok = true; |
John Stiles | 56233d1 | 2021-02-03 13:03:29 -0500 | [diff] [blame] | 5 | |
| 6 | float2x2 m1 = float2x2(float4(1, 2, 3, 4)); |
John Stiles | 465da15 | 2021-05-13 11:30:22 -0400 | [diff] [blame] | 7 | ok = ok && (m1 == float2x2(1, 2, 3, 4)); |
John Stiles | 86121f6 | 2021-05-12 11:01:37 -0400 | [diff] [blame] | 8 | |
John Stiles | 465da15 | 2021-05-13 11:30:22 -0400 | [diff] [blame] | 9 | // 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 Stiles | 56233d1 | 2021-02-03 13:03:29 -0500 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | bool test_half() { |
John Stiles | 465da15 | 2021-05-13 11:30:22 -0400 | [diff] [blame] | 45 | bool ok = true; |
John Stiles | 56233d1 | 2021-02-03 13:03:29 -0500 | [diff] [blame] | 46 | |
| 47 | half2x2 m1 = half2x2(half4(1, 2, 3, 4)); |
John Stiles | 465da15 | 2021-05-13 11:30:22 -0400 | [diff] [blame] | 48 | ok = ok && (m1 == half2x2(1, 2, 3, 4)); |
John Stiles | 86121f6 | 2021-05-12 11:01:37 -0400 | [diff] [blame] | 49 | |
John Stiles | 465da15 | 2021-05-13 11:30:22 -0400 | [diff] [blame] | 50 | // 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 Stiles | 56233d1 | 2021-02-03 13:03:29 -0500 | [diff] [blame] | 83 | } |
| 84 | |
John Stiles | 6011bbc | 2021-05-19 22:56:18 -0400 | [diff] [blame^] | 85 | bool 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 Osman | 169c890 | 2021-04-21 14:27:08 -0400 | [diff] [blame] | 92 | half4 main(float2 coords) { |
John Stiles | 6011bbc | 2021-05-19 22:56:18 -0400 | [diff] [blame^] | 93 | return test_float() && test_half() && test_comma() ? colorGreen : colorRed; |
John Stiles | 56233d1 | 2021-02-03 13:03:29 -0500 | [diff] [blame] | 94 | } |