| <!DOCTYPE html> |
| <html> |
| <meta charset=utf-8> |
| <meta name="timeout" content="long"> |
| <title>matrix-index-order.</title> |
| <script src="js/test-harness.js"></script> |
| <script src="../js/webgpu-functions.js"></script> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script> |
| const whlslTests = {}; |
| |
| whlslTests.matMul = async () => { |
| const program = ` |
| bool foo() { |
| float2x3 a = float2x3( |
| float3(1, 2, 3), |
| float3(4, 5, 6) |
| ); |
| |
| float3x2 b = float3x2( |
| float2(7, 8), |
| float2(9, 10), |
| float2(11, 12) |
| ); |
| |
| float3x3 result = mul(a, b); |
| |
| float3x3 expected = float3x3( |
| float3(39, 54, 69), |
| float3(49, 68, 87), |
| float3(59, 82, 105) |
| ); |
| return all(expected == result); |
| } |
| `; |
| |
| assert_equals(await callBoolFunction(program, "foo", []), true); |
| }; |
| |
| whlslTests.matMul2 = async () => { |
| const program = ` |
| bool foo() { |
| float2x2 a = float2x2( |
| float2(1, 8), |
| float2(5, 12) |
| ); |
| |
| float2 b = float2(22, 45); |
| |
| float2 result = mul(a, b); |
| |
| float2 expected = float2(247, 716); |
| |
| return all(expected == result); |
| } |
| `; |
| |
| assert_equals(await callBoolFunction(program, "foo", []), true); |
| }; |
| |
| whlslTests.matMul3 = async () => { |
| const program = ` |
| bool foo() { |
| float2x2 a = float2x2( |
| float2(1, 2), |
| float2(3, 4) |
| ); |
| |
| float2x2 b = float2x2( |
| float2(5, 6), |
| float2(7, 8) |
| ); |
| |
| float2x2 result = mul(a, b); |
| |
| float2x2 expected = float2x2( |
| float2(23, 34), |
| float2(31, 46) |
| ); |
| |
| return all(expected == result); |
| } |
| |
| bool bar() { |
| float2x2 b = float2x2( |
| float2(1, 2), |
| float2(3, 4) |
| ); |
| |
| float2x2 a = float2x2( |
| float2(5, 6), |
| float2(7, 8) |
| ); |
| |
| float2x2 result = mul(a, b); |
| |
| float2x2 expected = float2x2( |
| float2(19, 22), |
| float2(43, 50) |
| ); |
| |
| return all(expected == result); |
| } |
| `; |
| |
| assert_equals(await callBoolFunction(program, "foo", []), true); |
| assert_equals(await callBoolFunction(program, "bar", []), true); |
| }; |
| |
| whlslTests.matMul4 = async () => { |
| const program = ` |
| bool foo() { |
| float2x4 a = float2x4( |
| float4(1, 2, 3, 4), |
| float4(5, 6, 7, 8) |
| ); |
| |
| float3x2 b = float3x2( |
| float2(9, 10), |
| float2(11, 12), |
| float2(13, 14) |
| ); |
| |
| float3x4 result = mul(a, b); |
| |
| float3x4 expected = float3x4( |
| float4(59, 78, 97, 116), |
| float4(71, 94, 117, 140), |
| float4(83, 110, 137, 164) |
| ); |
| |
| return all(expected == result); |
| } |
| `; |
| |
| assert_equals(await callBoolFunction(program, "foo", []), true); |
| }; |
| |
| runTests(whlslTests); |
| </script> |
| </html> |