diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-06-05 21:35:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-05 21:35:48 -0700 |
| commit | 1a698128c15bce0c05b0664bb1458842e1e55511 (patch) | |
| tree | de4b65733737b1002168084e0b579843be761c3e /tests/compute | |
| parent | 8b16bbf64a082d30d496453f948f65605e58a014 (diff) | |
Fix atomic operations on RWBuffer (#593)
* Fix atomic operations on RWBuffer
An earlier change added support for passing true pointers to `__ref` parameters to fix the global `Interlocked*()` functions when applied to `groupshared` variables or `RWStructureBuffer<T>` elements.
That change didn't apply to `RWBuffer<T>` or `RWTexture2D<T>`, etc. because those types had so far only declared `get` and `set` accessors, but not any `ref` accessors (which return a pointer).
The main fixes here are:
* Add `ref` accessors to the subscript oeprations on the `RW*` resource types
* Adjust the logic for emitting calls to subscript accessors so that we don't get quite as eager about invoking a `ref` accessor, and instead try to invoke just a `get` or `set` accessor when these will suffice. This is important for Vulkan cross-compilation, where we don't yet support the semantics of our `ref` accessors.
* Add a test case for atomics on a `RWBuffer`
* Fix up `render-test` so that we can specify a format for a buffer resource, which allows us to use things other than `*StructuredBuffer` and `*ByteAddressBuffer`. The work there is probably not complete; I just did what I could to get the test working.
* A bunch of files got whitespace edits thanks to the fact that I'm using editorconfig and others on the project seemingly arent...
* fixup: remove ifdefed-out code
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/atomics-buffer.slang | 28 | ||||
| -rw-r--r-- | tests/compute/atomics-buffer.slang.expected.txt | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/compute/atomics-buffer.slang b/tests/compute/atomics-buffer.slang new file mode 100644 index 000000000..92f00272d --- /dev/null +++ b/tests/compute/atomics-buffer.slang @@ -0,0 +1,28 @@ +// atomics-buffer.slang + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute + +// Note: not enabling D3D12 test yet because change +// was developed on a machine that can run D3D12 +// +//TEST_DISABLED(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 + +//TEST_INPUT:ubuffer(format=R_UInt32, data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]):dxbinding(0),glbinding(0),out + +RWBuffer<uint> outputBuffer; + +void test(uint val) +{ + uint originalValue; + + InterlockedAdd(outputBuffer[val], val, originalValue); + InterlockedAdd(outputBuffer[val ^ 1], val*16, originalValue); + InterlockedAdd(outputBuffer[val ^ 2], val*16*16, originalValue); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + test(tid); +}
\ No newline at end of file diff --git a/tests/compute/atomics-buffer.slang.expected.txt b/tests/compute/atomics-buffer.slang.expected.txt new file mode 100644 index 000000000..36caeb8d6 --- /dev/null +++ b/tests/compute/atomics-buffer.slang.expected.txt @@ -0,0 +1,4 @@ +210 +301 +32 +123 |
