| uniform half4 colorRed, colorGreen; |
| |
| bool test_eq_float() { |
| bool ok = true; |
| ok = ok && (float3x2(2) == float3x2(float2(2.0, 0.0), float2(0.0, 2.0), float2(0.0))); |
| ok = ok && (float3x2(1, 2, 3, 4, 5, 6) == float3x2(float4x2(1, 2, 3, 4, 5, 6, 7, 8))); |
| return ok; |
| } |
| |
| bool test_eq_half() { |
| bool ok = true; |
| ok = ok && (half3x2(2) == half3x2(half2(2.0, 0.0), half2(0.0, 2.0), half2(0.0))); |
| ok = ok && (half3x2(1, 2, 3, 4, 5, 6) == half3x2(half4x2(1, 2, 3, 4, 5, 6, 7, 8))); |
| return ok; |
| } |
| |
| bool test_matrix_op_matrix_float() { |
| bool ok = true; |
| |
| // Addition, subtraction and division operate componentwise. |
| { |
| const float3x2 splat_4 = float3x2(4, 4, 4, 4, 4, 4); |
| |
| ok = ok && ((float3x2(2) + splat_4) == float3x2(6, 4, 4, 6, 4, 4)); |
| ok = ok && ((float3x2(2) - splat_4) == float3x2(-2, -4, -4, -2, -4, -4)); |
| ok = ok && ((float3x2(2) / splat_4) == float3x2(0.5)); |
| } |
| { |
| const float2x3 splat_4 = float2x3(4, 4, 4, 4, 4, 4); |
| |
| ok = ok && (splat_4 + (float2x3(2)) == float2x3(6, 4, 4, 4, 6, 4)); |
| ok = ok && (splat_4 - (float2x3(2)) == float2x3(2, 4, 4, 4, 2, 4)); |
| ok = ok && (splat_4 / (float2x3(2, 2, 2, 2, 2, 2)) == float2x3(2, 2, 2, 2, 2, 2)); |
| } |
| ok = ok && (float4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) + |
| float4x3(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5) == |
| float4x3(17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17)); |
| |
| ok = ok && (float4x2(10, 20, 30, 40, 50, 60, 70, 80) - |
| float4x2(1, 2, 3, 4, 5, 6, 7, 8) == |
| float4x2(9, 18, 27, 36, 45, 54, 63, 72)); |
| |
| ok = ok && (float2x4(10, 20, 30, 40, 10, 20, 30, 40) / |
| float2x4(10, 10, 10, 10, 5, 5, 5, 5) == |
| float2x4(1, 2, 3, 4, 2, 4, 6, 8)); |
| |
| // Multiplication performs a proper matrix multiply. |
| ok = ok && (float3x2(1, 4, 2, 5, 3, 6) * |
| float2x3(7, 9, 11, 8, 10, 12) == |
| float2x2(58, 139, 64, 154)); |
| return ok; |
| } |
| |
| bool test_matrix_op_matrix_half() { |
| bool ok = true; |
| |
| // Addition, subtraction and division operate componentwise. |
| { |
| const half3x2 splat_4 = half3x2(4, 4, 4, 4, 4, 4); |
| |
| ok = ok && ((half3x2(2) + splat_4) == half3x2(6, 4, 4, 6, 4, 4)); |
| ok = ok && ((half3x2(2) - splat_4) == half3x2(-2, -4, -4, -2, -4, -4)); |
| ok = ok && ((half3x2(2) / splat_4) == half3x2(0.5)); |
| } |
| { |
| const half2x3 splat_4 = half2x3(4, 4, 4, 4, 4, 4); |
| |
| ok = ok && (splat_4 + (half2x3(2)) == half2x3(6, 4, 4, 4, 6, 4)); |
| ok = ok && (splat_4 - (half2x3(2)) == half2x3(2, 4, 4, 4, 2, 4)); |
| ok = ok && (splat_4 / (half2x3(2, 2, 2, 2, 2, 2)) == half2x3(2, 2, 2, 2, 2, 2)); |
| } |
| ok = ok && (half4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) + |
| half4x3(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5) == |
| half4x3(17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17)); |
| |
| ok = ok && (half4x2(10, 20, 30, 40, 50, 60, 70, 80) - |
| half4x2(1, 2, 3, 4, 5, 6, 7, 8) == |
| half4x2(9, 18, 27, 36, 45, 54, 63, 72)); |
| |
| ok = ok && (half2x4(10, 20, 30, 40, 10, 20, 30, 40) / |
| half2x4(10, 10, 10, 10, 5, 5, 5, 5) == |
| half2x4(1, 2, 3, 4, 2, 4, 6, 8)); |
| |
| // Multiplication performs a proper matrix multiply. |
| ok = ok && (half3x2(1, 4, 2, 5, 3, 6) * |
| half2x3(7, 9, 11, 8, 10, 12) == |
| half2x2(58, 139, 64, 154)); |
| return ok; |
| } |
| |
| half4 main(float2 coords) { |
| return (test_eq_float() && |
| test_eq_half() && |
| test_matrix_op_matrix_float() && |
| test_matrix_op_matrix_half()) ? colorGreen : colorRed; |
| } |