From 0d82ef821afdfad27f3b04bd33c8812c78b0dba3 Mon Sep 17 00:00:00 2001 From: assiduous Date: Wed, 17 Feb 2021 18:03:21 -0800 Subject: DrawCommandTest: added structured buffer array, and formatted buffer tests --- .../GraphicsEngineD3D12/src/BufferD3D12Impl.cpp | 5 ++-- .../src/PipelineResourceSignatureD3D12Impl.cpp | 28 +++++++--------------- 2 files changed, 12 insertions(+), 21 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp index 2a2e571a..ac5d94d1 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp @@ -93,10 +93,11 @@ BufferD3D12Impl::BufferD3D12Impl(IReferenceCounters* pRefCounters, if (AlignmentMask != 1) m_Desc.uiSizeInBytes = (m_Desc.uiSizeInBytes + AlignmentMask) & (~AlignmentMask); - if (m_Desc.Usage == USAGE_DYNAMIC && (m_Desc.BindFlags & BIND_UNORDERED_ACCESS) == 0) + + if (m_Desc.Usage == USAGE_DYNAMIC && (m_Desc.BindFlags & BIND_UNORDERED_ACCESS) == 0 && BuffDesc.Mode != BUFFER_MODE_FORMATTED) { // Dynamic constant/vertex/index buffers are suballocated in the upload heap when Map() is called. - // Dynamic buffers with UAV flags need to be allocated in GPU-only memory. + // Dynamic buffers with UAV flags as well as formatted buffers need to be allocated in GPU-only memory. // Dynamic upload heap buffer is always in D3D12_RESOURCE_STATE_GENERIC_READ state. SetState(RESOURCE_STATE_GENERIC_READ); diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp index d418f80b..3d385a75 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp @@ -665,47 +665,39 @@ void PipelineResourceSignatureD3D12Impl::InitSRBResourceCache(ShaderResourceCach ResourceCache.SetDescriptorHeapSpace(std::move(CbcSrvUavHeapSpace), std::move(SamplerHeapSpace)); } -inline void UpdateDynamicBuffersCounter(const BufferD3D12Impl* pOldBuff, - const BufferD3D12Impl* pNewBuff, - Uint32& BuffCounter, - D3D12_ROOT_PARAMETER_TYPE d3d12RootParamType) +inline void UpdateDynamicBuffersCounter(const BufferD3D12Impl* pOldBuff, + const BufferD3D12Impl* pNewBuff, + Uint32& BuffCounter) { if (pOldBuff != nullptr && pOldBuff->GetDesc().Usage == USAGE_DYNAMIC) { - VERIFY_EXPR(d3d12RootParamType == D3D12_ROOT_PARAMETER_TYPE_CBV); VERIFY(BuffCounter > 0, "There is a dynamic root buffer in the resource cache, but dynamic buffers counter is zero"); --BuffCounter; } if (pNewBuff != nullptr && pNewBuff->GetDesc().Usage == USAGE_DYNAMIC) { - DEV_CHECK_ERR(d3d12RootParamType == D3D12_ROOT_PARAMETER_TYPE_CBV, "Dynamic constant buffers must be used as root views"); ++BuffCounter; } } inline void UpdateDynamicBuffersCounter(const BufferViewD3D12Impl* pOldBuffView, const BufferViewD3D12Impl* pNewBuffView, - Uint32& BuffCounter, - D3D12_ROOT_PARAMETER_TYPE d3d12RootParamType) + Uint32& BuffCounter) { if (pOldBuffView != nullptr && pOldBuffView->GetBuffer()->GetDesc().Usage == USAGE_DYNAMIC) { - VERIFY_EXPR(d3d12RootParamType == D3D12_ROOT_PARAMETER_TYPE_SRV || d3d12RootParamType == D3D12_ROOT_PARAMETER_TYPE_UAV); VERIFY_EXPR(BuffCounter > 0); --BuffCounter; } if (pNewBuffView != nullptr && pNewBuffView->GetBuffer()->GetDesc().Usage == USAGE_DYNAMIC) { - DEV_CHECK_ERR(d3d12RootParamType == D3D12_ROOT_PARAMETER_TYPE_SRV || d3d12RootParamType == D3D12_ROOT_PARAMETER_TYPE_UAV, - "Dynamic buffers must be used as root views"); ++BuffCounter; } } inline void UpdateDynamicBuffersCounter(const TextureViewD3D12Impl*, const TextureViewD3D12Impl*, - Uint32&, - D3D12_ROOT_PARAMETER_TYPE) + Uint32&) { } @@ -758,15 +750,13 @@ void PipelineResourceSignatureD3D12Impl::InitializeStaticSRBResources(ShaderReso { UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr(), SrcRes.pObject.RawPtr(), - DstBoundDynamicCBsCounter, - Attr.GetD3D12RootParamType()); + DstBoundDynamicCBsCounter); } else if (SrcRes.Type == SHADER_RESOURCE_TYPE_BUFFER_SRV || SrcRes.Type == SHADER_RESOURCE_TYPE_BUFFER_UAV) { UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr(), SrcRes.pObject.RawPtr(), - DstBoundDynamicCBsCounter, - Attr.GetD3D12RootParamType()); + DstBoundDynamicCBsCounter); } DstRes.pObject = SrcRes.pObject; @@ -1318,7 +1308,7 @@ void BindResourceHelper::CacheCB(IDeviceObject* pBuffer) const GetD3D12Device()->CopyDescriptorsSimple(1, ShdrVisibleHeapCPUDescriptorHandle, DstRes.CPUDescriptorHandle, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); } - UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr(), pBuffD3D12, ResourceCache.GetDynamicRootBuffersCounter(), Attribs.GetD3D12RootParamType()); + UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr(), pBuffD3D12, ResourceCache.GetDynamicRootBuffersCounter()); DstRes.pObject = std::move(pBuffD3D12); } @@ -1465,7 +1455,7 @@ void BindResourceHelper::CacheResourceView(IDeviceObject* pView, GetD3D12Device()->CopyDescriptorsSimple(1, ShdrVisibleHeapCPUDescriptorHandle, DstRes.CPUDescriptorHandle, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); } - UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr(), pViewD3D12, ResourceCache.GetDynamicRootBuffersCounter(), Attribs.GetD3D12RootParamType()); + UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr(), pViewD3D12, ResourceCache.GetDynamicRootBuffersCounter()); BindSamplerProc(pViewD3D12); -- cgit v1.2.3