From 705d00ab8528e0d7c14f68b7d0e15fb57280c16e Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Mon, 14 Apr 2025 14:48:17 -0600 Subject: Fix matrix division by scalar for Metal and WGSL targets (#6752) * Fix matrix division by scalar for Metal and WGSL targets * Add tests * Minor fix * Fix compilation error * Convert to multiplication for WGSL * Minor cleanup --------- Co-authored-by: Yong He --- tests/bugs/matrix-divided-by-scalar.slang | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/bugs/matrix-divided-by-scalar.slang (limited to 'tests/bugs') diff --git a/tests/bugs/matrix-divided-by-scalar.slang b/tests/bugs/matrix-divided-by-scalar.slang new file mode 100644 index 000000000..27c23e501 --- /dev/null +++ b/tests/bugs/matrix-divided-by-scalar.slang @@ -0,0 +1,21 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -compute -entry computeMain -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-metal -compute -entry computeMain -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-wgpu -compute -entry computeMain -output-using-type + +//TEST_INPUT:ubuffer(data=[3.5], stride=4):name inputBuffer +StructuredBuffer inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ + // CHECK: 6.0 + outputBuffer[0] = (float3x3(15.0) / 2.5)[0][0]; + + // CHECK: 4.0 + outputBuffer[1] = (float4x4(14.0) / inputBuffer[0])[0][0]; +} + -- cgit v1.2.3