From 9f23046138629f78995d54a7722ad6749bd84db9 Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Tue, 14 May 2024 00:39:49 +0200 Subject: [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 --- tools/gfx/d3d12/d3d12-command-encoder.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tools/gfx/d3d12/d3d12-command-encoder.cpp') 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(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(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, -- cgit v1.2.3