summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-02-18 02:03:21 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:36:23 +0000
commit0d82ef821afdfad27f3b04bd33c8812c78b0dba3 (patch)
treedb7492c84462150800c8a2f580e15351622b79d9 /Graphics/GraphicsEngineD3D12
parentFew minor updates to ShaderResourceCacheD3D12 (diff)
downloadDiligentCore-0d82ef821afdfad27f3b04bd33c8812c78b0dba3.tar.gz
DiligentCore-0d82ef821afdfad27f3b04bd33c8812c78b0dba3.zip
DrawCommandTest: added structured buffer array, and formatted buffer tests
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp5
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp28
2 files changed, 12 insertions, 21 deletions
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<BufferD3D12Impl>()->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<BufferD3D12Impl>()->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<const BufferD3D12Impl>(),
SrcRes.pObject.RawPtr<const BufferD3D12Impl>(),
- DstBoundDynamicCBsCounter,
- Attr.GetD3D12RootParamType());
+ DstBoundDynamicCBsCounter);
}
else if (SrcRes.Type == SHADER_RESOURCE_TYPE_BUFFER_SRV || SrcRes.Type == SHADER_RESOURCE_TYPE_BUFFER_UAV)
{
UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr<const BufferViewD3D12Impl>(),
SrcRes.pObject.RawPtr<const BufferViewD3D12Impl>(),
- 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<const BufferD3D12Impl>(), pBuffD3D12, ResourceCache.GetDynamicRootBuffersCounter(), Attribs.GetD3D12RootParamType());
+ UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr<const BufferD3D12Impl>(), 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<const TResourceViewType>(), pViewD3D12, ResourceCache.GetDynamicRootBuffersCounter(), Attribs.GetD3D12RootParamType());
+ UpdateDynamicBuffersCounter(DstRes.pObject.RawPtr<const TResourceViewType>(), pViewD3D12, ResourceCache.GetDynamicRootBuffersCounter());
BindSamplerProc(pViewD3D12);