summaryrefslogtreecommitdiff
path: root/tests/hlsl-intrinsic/byte-address-buffer
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-01 13:26:03 -0800
committerGitHub <noreply@github.com>2024-02-01 13:26:03 -0800
commitf370947c63bca707b9cfde7b18e67298f5fbace3 (patch)
tree1180cdb722529c8157f673fc68a2d45f00b5e827 /tests/hlsl-intrinsic/byte-address-buffer
parenta2d2018a8be41aecd2c1810db8556e0c07595fb9 (diff)
FP16 atomics for RWByteAddresBuffer, fp32 atomics for images. (#3536)
* FP16 atomics for RWByteAddresBuffer, fp32 atomics for images. * Fix spelling. * Add overload. * Fix test failures. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/hlsl-intrinsic/byte-address-buffer')
-rw-r--r--tests/hlsl-intrinsic/byte-address-buffer/byte-address-half-atomics.slang34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/hlsl-intrinsic/byte-address-buffer/byte-address-half-atomics.slang b/tests/hlsl-intrinsic/byte-address-buffer/byte-address-half-atomics.slang
new file mode 100644
index 000000000..a89c7c3fa
--- /dev/null
+++ b/tests/hlsl-intrinsic/byte-address-buffer/byte-address-half-atomics.slang
@@ -0,0 +1,34 @@
+// byte-address-half-atomics.slang
+// test the atomics on half types.
+
+// Disabled because our current driver doesn't support half atomics yet.
+//DISABLED_TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -compute -profile cs_6_2 -render-features half -shaderobj
+
+//TEST:SIMPLE(filecheck=SPIRV):-target spirv -entry computeMain -stage compute
+//TEST:SIMPLE(filecheck=SPIRV):-target spirv -entry computeMain -stage compute -emit-spirv-directly
+
+//TEST_INPUT:set tmpBuffer = ubuffer(data=[0 0 0 0], stride=4)
+RWByteAddressBuffer tmpBuffer;
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ half originalValue;
+
+ // SPIRV: OpAtomicFAddEXT
+
+ tmpBuffer.InterlockedAddF16(0, 1.0h, originalValue);
+ tmpBuffer.InterlockedAddF16(2, 2.0h, originalValue);
+
+ half2 v = tmpBuffer.Load<half2>(0);
+
+ // CHECK: 1.0
+ outputBuffer[0] = v.x;
+ // CHECK: 2.0
+ outputBuffer[1] = v.y;
+ // CHECK: 0.0
+ outputBuffer[3] = originalValue;
+}