diff options
| author | Darren Wihandi <65404740+fairywreath@users.noreply.github.com> | 2025-04-14 14:48:17 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-14 14:48:17 -0600 |
| commit | 705d00ab8528e0d7c14f68b7d0e15fb57280c16e (patch) | |
| tree | acf6e024ef803c5a49e2c6c0075ab0d9a49a11d3 /tests | |
| parent | d6f4780e8a608fa37597116d5b0ac5c80034c2aa (diff) | |
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 <yonghe@outlook.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/matrix-divided-by-scalar.slang | 21 | ||||
| -rw-r--r-- | tests/diagnostics/division-by-matrix.slang | 15 |
2 files changed, 36 insertions, 0 deletions
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<float> inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<float> 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]; +} + diff --git a/tests/diagnostics/division-by-matrix.slang b/tests/diagnostics/division-by-matrix.slang new file mode 100644 index 000000000..6ed78d353 --- /dev/null +++ b/tests/diagnostics/division-by-matrix.slang @@ -0,0 +1,15 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target metal +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target wgsl + +RWStructuredBuffer<float> outputBuffer; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ + // CHECK: error 56102: division by matrix is not supported + float3x3 divisor = float3x3(2.5); + divisor[1][1] = 1.5; + outputBuffer[0] = (float3x3(15) / divisor)[0][0]; +} + |
