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 /tools/render-test/shader-renderer-util.cpp | |
| 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 'tools/render-test/shader-renderer-util.cpp')
| -rw-r--r-- | tools/render-test/shader-renderer-util.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/render-test/shader-renderer-util.cpp b/tools/render-test/shader-renderer-util.cpp index 6e11757fb..e46c725bc 100644 --- a/tools/render-test/shader-renderer-util.cpp +++ b/tools/render-test/shader-renderer-util.cpp @@ -23,7 +23,7 @@ using namespace Slang; textureResourceDesc.arraySize = inputDesc.arrayLength; textureResourceDesc.bindFlags = bindFlags; - // It's the same size in all dimensions + // It's the same size in all dimensions switch (inputDesc.dimension) { case 1: @@ -92,6 +92,7 @@ using namespace Slang; BufferResource::Desc srcDesc; srcDesc.init(bufferSize); + srcDesc.format = inputDesc.format; int bindFlags = 0; if (inputDesc.type == InputBufferType::ConstantBuffer) @@ -123,7 +124,7 @@ using namespace Slang; bufferOut = bufferResource; return SLANG_OK; } - + static BindingState::SamplerDesc _calcSamplerDesc(const InputSamplerDesc& srcDesc) { BindingState::SamplerDesc dstDesc; @@ -139,7 +140,7 @@ static BindingState::SamplerDesc _calcSamplerDesc(const InputSamplerDesc& srcDes switch (bindingStyle) { - case BindingStyle::DirectX: + case BindingStyle::DirectX: { return RegisterRange::makeSingle(entry.hlslBinding); } @@ -167,7 +168,7 @@ static BindingState::SamplerDesc _calcSamplerDesc(const InputSamplerDesc& srcDes break; } } - return RegisterRange::makeRange(baseIndex, count); + return RegisterRange::makeRange(baseIndex, count); } /* case BindingStyle::Vulkan: { @@ -204,7 +205,7 @@ static BindingState::SamplerDesc _calcSamplerDesc(const InputSamplerDesc& srcDes RefPtr<BufferResource> bufferResource; SLANG_RETURN_ON_FAIL(createBufferResource(srcEntry.bufferDesc, srcEntry.isOutput, bufferSize, srcEntry.bufferData.Buffer(), renderer, bufferResource)); - + descOut.addBufferResource(bufferResource, registerSet); break; } @@ -228,13 +229,13 @@ static BindingState::SamplerDesc _calcSamplerDesc(const InputSamplerDesc& srcDes descOut.addSampler(_calcSamplerDesc(srcEntry.samplerDesc), registerSet); break; } - default: + default: { assert(!"Unhandled type"); return SLANG_FAIL; } } - } + } return SLANG_OK; } |
