summaryrefslogtreecommitdiffstats
path: root/tools/gfx/d3d12/d3d12-command-encoder.cpp
diff options
context:
space:
mode:
authorskallweitNV <64953474+skallweitNV@users.noreply.github.com>2024-05-14 00:39:49 +0200
committerGitHub <noreply@github.com>2024-05-13 15:39:49 -0700
commit9f23046138629f78995d54a7722ad6749bd84db9 (patch)
tree25ac343566f896cae547046ac7e960441874ec00 /tools/gfx/d3d12/d3d12-command-encoder.cpp
parent04d3dd51125182767d90c318895a6232ec4ee750 (diff)
[gfx] specify resource view buffer range in bytes (#4149)
* refactor gfx buffer range to use byte range * create buffer view with zero struct stride for ClearUnorderedAccessViewUint/Float * create buffer descriptors on demand * avoid copying gfx.dll --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/gfx/d3d12/d3d12-command-encoder.cpp')
-rw-r--r--tools/gfx/d3d12/d3d12-command-encoder.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/gfx/d3d12/d3d12-command-encoder.cpp b/tools/gfx/d3d12/d3d12-command-encoder.cpp
index b88bf3168..ff50dcc5f 100644
--- a/tools/gfx/d3d12/d3d12-command-encoder.cpp
+++ b/tools/gfx/d3d12/d3d12-command-encoder.cpp
@@ -384,11 +384,14 @@ void ResourceCommandEncoderImpl::clearResourceView(
case IResourceView::Type::UnorderedAccess:
{
ID3D12Resource* d3dResource = nullptr;
+ D3D12Descriptor descriptor = viewImpl->m_descriptor;
switch (viewImpl->m_resource->getType())
{
case IResource::Type::Buffer:
d3dResource = static_cast<BufferResourceImpl*>(viewImpl->m_resource.Ptr())
->m_resource.getResource();
+ // D3D12 requires a UAV descriptor with zero buffer stride for calling ClearUnorderedAccessViewUint/Float.
+ viewImpl->getBufferDescriptorForBinding(m_commandBuffer->m_renderer, viewImpl, 0, descriptor);
break;
default:
d3dResource = static_cast<TextureResourceImpl*>(viewImpl->m_resource.Ptr())
@@ -407,7 +410,7 @@ void ResourceCommandEncoderImpl::clearResourceView(
this->m_commandBuffer->m_renderer->m_device->CopyDescriptorsSimple(
1,
m_commandBuffer->m_transientHeap->getCurrentViewHeap().getCpuHandle(gpuHandleIndex),
- viewImpl->m_descriptor.cpuHandle,
+ descriptor.cpuHandle,
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
if (flags & ClearResourceViewFlags::FloatClearValues)
@@ -415,7 +418,7 @@ void ResourceCommandEncoderImpl::clearResourceView(
m_commandBuffer->m_cmdList->ClearUnorderedAccessViewFloat(
m_commandBuffer->m_transientHeap->getCurrentViewHeap().getGpuHandle(
gpuHandleIndex),
- viewImpl->m_descriptor.cpuHandle,
+ descriptor.cpuHandle,
d3dResource,
clearValue->color.floatValues,
0,
@@ -426,7 +429,7 @@ void ResourceCommandEncoderImpl::clearResourceView(
m_commandBuffer->m_cmdList->ClearUnorderedAccessViewUint(
m_commandBuffer->m_transientHeap->getCurrentViewHeap().getGpuHandle(
gpuHandleIndex),
- viewImpl->m_descriptor.cpuHandle,
+ descriptor.cpuHandle,
d3dResource,
clearValue->color.uintValues,
0,