From 1d77d51ca497ddc8d0ed310fe5eb078fc9edf74b Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Thu, 29 May 2025 18:42:18 +0200 Subject: [PATCH] tests/hlsl: Test some quirks of TGSMs with SM < 5.0. I'm not specifically interested in that, but since I ran into those idiosyncrasies while writing other TGSM tests I decided that it might turn out useful to keep them. --- tests/hlsl/tgsm.shader_test | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tests/hlsl/tgsm.shader_test b/tests/hlsl/tgsm.shader_test index 21ad9ebe9..a10f77fa2 100644 --- a/tests/hlsl/tgsm.shader_test +++ b/tests/hlsl/tgsm.shader_test @@ -1,3 +1,78 @@ +[require] +% SM < 5.0 requires that groupshared variables are arrays of N elements, +% where N is the number of threads in a group, and they are only ever indexed +% by SV_GroupIndex when storing (though violating this last condition gives +% E_NOTIMPL rather than E_FAIL). +shader model >= 4.0 +shader model < 5.0 + +[compute shader fail todo] +RWByteAddressBuffer u : register(u0); +groupshared uint m; + + [numthreads(4, 1, 1)] +void main(uint local_idx : SV_GroupIndex) +{ + if (local_idx == 0) + m = 0; + GroupMemoryBarrierWithGroupSync(); + u.Store(4 * local_idx, m); +} + +[compute shader fail todo] +RWByteAddressBuffer u : register(u0); +groupshared uint m[1]; + + [numthreads(4, 1, 1)] +void main(uint local_idx : SV_GroupIndex) +{ + if (local_idx == 0) + m[0] = 0; + GroupMemoryBarrierWithGroupSync(); + u.Store(4 * local_idx, m[0]); +} + +[compute shader notimpl] +RWByteAddressBuffer u : register(u0); +groupshared uint m[4]; + + [numthreads(4, 1, 1)] +void main(uint local_idx : SV_GroupIndex) +{ + if (local_idx == 0) + m[0] = 0; + GroupMemoryBarrierWithGroupSync(); + u.Store(4 * local_idx, m[0]); +} + +[require] +shader model >= 4.0 + +[uav 0] +format r32-typeless +size (raw_buffer, 4) + +0 0 0 0 + +[compute shader todo] +RWByteAddressBuffer u : register(u0); +groupshared uint m[4]; + + [numthreads(4, 1, 1)] +void main(uint local_idx : SV_GroupIndex) +{ + m[local_idx] = 0xcafef00d; + GroupMemoryBarrierWithGroupSync(); + u.Store(4 * local_idx, m[0]); +} + +[test] +todo(sm<6) dispatch 1 1 1 +probe uav 0 (0) rui(0xcafef00d) +probe uav 0 (1) rui(0xcafef00d) +probe uav 0 (2) rui(0xcafef00d) +probe uav 0 (3) rui(0xcafef00d) + [require] shader model >= 5.0