From 728cf1dcfef8982e9b19b475e9d1ddef1ef68b44 Mon Sep 17 00:00:00 2001 From: Shaun Ren Date: Fri, 20 Dec 2024 16:10:17 -0500 Subject: [PATCH] tests/hlsl: Add tests to check the types of the value arguments of atomic ops. --- tests/hlsl/uav-atomics.shader_test | 98 ++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/tests/hlsl/uav-atomics.shader_test b/tests/hlsl/uav-atomics.shader_test index c56c09dc..bdee2c63 100644 --- a/tests/hlsl/uav-atomics.shader_test +++ b/tests/hlsl/uav-atomics.shader_test @@ -156,3 +156,101 @@ uniform 0 int4 -3 1 0 0 todo(sm<6) dispatch 1 1 1 probe uav 2 (0) ri (1) probe uav 2 (1) ri (-3) + + +[uav 1] +format r32-uint +size (buffer, 3) + +1 1 1 + +[uav 2] +format r32-sint +size (buffer, 3) + +1 1 1 + +% The value fields of InterlockedMax/Min have the same type as the underlying scalar type of dst. + +[compute shader fail(sm<5) todo(sm>=5)] +RWBuffer u : register(u1); +RWBuffer s : register(u2); + + [numthreads(3, 1, 1)] +void main() +{ + uint i = 0xffffffff; + float a = -1.0; + + InterlockedMax(u[0], i); + InterlockedMin(u[1], i); + InterlockedMin(u[2], a); + + InterlockedMax(s[0], i); + InterlockedMin(s[1], i); + InterlockedMin(s[2], a); +} + +[test] +todo(sm<6) dispatch 1 1 1 +probe uav 1 (0) rui (0xffffffff) +probe uav 1 (1) rui (1) +% SM6 emits i32 undef for the value float a = -1.0. +if(sm<6) probe uav 1 (2) rui (0) +probe uav 2 (0) ri (1) +probe uav 2 (1) ri (-1) +if(sm<6) probe uav 2 (2) ri (-1) + +[uav 1] +format r32-uint +size (buffer, 5) + +0 0 0xffffffff 0 0xffffffff + +[uav 2] +format r32-sint +size (buffer, 5) + +0 0 -1 0 -1 + +% The value fields of other Interlocked functions are always uint. + +[compute shader fail(sm<5) todo(sm>=5)] +RWBuffer u : register(u1); +RWBuffer s : register(u2); + + [numthreads(3, 1, 1)] +void main() +{ + uint i = 0xffffffff; + float a = -1.0; + uint old; + + InterlockedAdd(u[0], i); + InterlockedAdd(u[1], a); + InterlockedAnd(u[2], a); + InterlockedExchange(u[3], i, old); + InterlockedCompareStore(u[4], a, 0); + + InterlockedAdd(s[0], i); + InterlockedAdd(s[1], a); + InterlockedAnd(s[2], a); + InterlockedExchange(s[3], i, old); + InterlockedCompareStore(s[4], a, 0); +} + +[test] +todo(sm<6) dispatch 1 1 1 +if(sm<6) probe uav 1 (0) rui (0xffffffff) +if(sm>=6) probe uav 1 (0) rui (0xfffffffd) +% SM6 emits i32 undef for the value float a = -1.0. +if(sm<6) probe uav 1 (1) rui (0) +if(sm<6) probe uav 1 (2) rui (0) +probe uav 1 (3) rui (0xffffffff) +if(sm<6) probe uav 1 (4) rui (0xffffffff) +if(sm<6) probe uav 2 (0) ri (-1) +if(sm>=6) probe uav 2 (0) rui (0xfffffffd) +if(sm<6) probe uav 2 (1) ri (0) +if(sm<6) probe uav 2 (2) ri (0) +probe uav 2 (3) ri (-1) +if(sm<6) probe uav 2 (4) ri (-1)