summaryrefslogtreecommitdiffstats
path: root/tools/gfx/d3d12/d3d12-shader-object.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-10-18 06:26:00 +0800
committerGitHub <noreply@github.com>2023-10-17 15:26:00 -0700
commit7826afcaad78cc33c976bb3db3cdc9eada4c77e8 (patch)
tree7a89a54512a4cbab6165d2c4b7906f88a032bbee /tools/gfx/d3d12/d3d12-shader-object.cpp
parent0a3683dd39fc04d15937b8a4700d477f9492c257 (diff)
Type layouts for structured buffers with counters (#3269)
* More tests for append structured buffer * Append and Consume structured buffer tests for DX12 * neaten * test wobble * Add counter layout information to append/consume structured buffers * add getRWStructuredBufferType * Correct definition of get size for append/consume structured buffers * tweak append structured buffer test * Allow initializing counter buffer in render test * vulkan test for consume structured buffer * Handle null counterVarLayout in getExplicitCounterBindingRangeOffset * remove dead code * Implement atomic counter increment/decrement for spirv * explicit spirv test * Add missing check on result * Hold on to counter resources --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/gfx/d3d12/d3d12-shader-object.cpp')
-rw-r--r--tools/gfx/d3d12/d3d12-shader-object.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/gfx/d3d12/d3d12-shader-object.cpp b/tools/gfx/d3d12/d3d12-shader-object.cpp
index c5389f6ea..74760eabd 100644
--- a/tools/gfx/d3d12/d3d12-shader-object.cpp
+++ b/tools/gfx/d3d12/d3d12-shader-object.cpp
@@ -181,7 +181,11 @@ Result ShaderObjectImpl::init(
// referenced by descriptors in this object does not get
// freed while the object is still live.
//
+ // The doubling here is because any buffer resource could
+ // have a counter buffer associated with it, which we
+ // also need to ensure isn't destroyed prematurely.
m_boundResources.setCount(resourceCount);
+ m_boundCounterResources.setCount(resourceCount);
}
if (auto samplerCount = layout->getSamplerSlotCount())
{
@@ -950,8 +954,9 @@ Result ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView*
{
auto resourceViewImpl = static_cast<ResourceViewImpl*>(resourceView);
// Hold a reference to the resource to prevent its destruction.
- m_boundResources[bindingRange.baseIndex + offset.bindingArrayIndex] =
- resourceViewImpl->m_resource;
+ const auto resourceOffset = bindingRange.baseIndex + offset.bindingArrayIndex;
+ m_boundResources[resourceOffset] = resourceViewImpl->m_resource;
+ m_boundCounterResources[resourceOffset] = resourceViewImpl->m_counterResource;
internalResourceView = resourceViewImpl;
}
break;