summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-10-06 13:30:55 -0400
committerGitHub <noreply@github.com>2020-10-06 13:30:55 -0400
commit8a70e20df6f47678c146eb29f89655aa734f97c7 (patch)
tree49aab68137de0001ae853b0deb1f03f533745f53 /tests
parentb6ad8dfb65358271f52ba76676db1926a90dcd46 (diff)
InterlockedExchangeU64 support on RWByteAddressBuffer (#1572)
* #include an absolute path didn't work - because paths were taken to always be relative. * Added [__requiresNVAPI] to functions that need nvapi support. * Added support for InterlockedExchangeU64 Added exchange-int64-byte-address-buffer test Fixed typo in cas-int64-byte-address-buffer test * Improve comment around NVAPI usage in hlsl.meta.slang
Diffstat (limited to 'tests')
-rw-r--r--tests/slang-extension/cas-int64-byte-address-buffer.slang2
-rw-r--r--tests/slang-extension/exchange-int64-byte-address-buffer.slang32
-rw-r--r--tests/slang-extension/exchange-int64-byte-address-buffer.slang.expected.txt8
3 files changed, 41 insertions, 1 deletions
diff --git a/tests/slang-extension/cas-int64-byte-address-buffer.slang b/tests/slang-extension/cas-int64-byte-address-buffer.slang
index b75a9fa04..451d97e36 100644
--- a/tests/slang-extension/cas-int64-byte-address-buffer.slang
+++ b/tests/slang-extension/cas-int64-byte-address-buffer.slang
@@ -24,7 +24,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
int idx = (tid & 3) ^ (tid >> 2);
// Try directly reading
- uint2 currentValue2 = outputBuffer.Load2(idx << 8);
+ uint2 currentValue2 = outputBuffer.Load2(idx << 3);
uint64_t currentValue = uint64_t(currentValue2.y) | currentValue2.x;
while (true)
diff --git a/tests/slang-extension/exchange-int64-byte-address-buffer.slang b/tests/slang-extension/exchange-int64-byte-address-buffer.slang
new file mode 100644
index 000000000..0145d3838
--- /dev/null
+++ b/tests/slang-extension/exchange-int64-byte-address-buffer.slang
@@ -0,0 +1,32 @@
+// No atomic support on CPU
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
+// No support for int64_t on DX11
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+// No support for int64_t on fxc - we need SM6.0 and dxil
+// https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -nvapi-slot u0
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -use-dxil -render-features atomic-int64 -nvapi-slot u0 -compile-arg -O2
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-features atomic-int64
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute
+
+// The test doesn't directly use this, but having this defined makes the 0 slot available if NVAPI is going to be used
+// Only strictly necessary on the D3D12 path
+//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):name=nvapiBuffer
+RWStructuredBuffer<int> nvapiBuffer;
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3 4 5 6 7]):out,name=outputBuffer
+RWByteAddressBuffer outputBuffer;
+
+// With only 4 threads there is no contention - which makes for a simple test
+// but doesn't actually test for the exchange atomicity
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = dispatchThreadID.x;
+
+ // Try directly reading
+ uint2 currentValue2 = outputBuffer.Load2(idx << 3);
+ uint64_t currentValue = uint64_t(currentValue2.y) | currentValue2.x;
+
+ uint64_t readValue = outputBuffer.InterlockedExchangeU64(idx << 3, currentValue + 1);
+} \ No newline at end of file
diff --git a/tests/slang-extension/exchange-int64-byte-address-buffer.slang.expected.txt b/tests/slang-extension/exchange-int64-byte-address-buffer.slang.expected.txt
new file mode 100644
index 000000000..4346d293e
--- /dev/null
+++ b/tests/slang-extension/exchange-int64-byte-address-buffer.slang.expected.txt
@@ -0,0 +1,8 @@
+2
+0
+4
+0
+6
+0
+8
+0