summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-07-22 18:47:37 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-07-22 18:47:37 +0000
commit5eca9ecce9770af037006c31f206bdad22b10be2 (patch)
treebd8f40bbf333f64c5390b1b0d8cbfd063741e8dc /Graphics/GraphicsEngineD3D12
parentFixed release build error (diff)
downloadDiligentCore-5eca9ecce9770af037006c31f206bdad22b10be2.tar.gz
DiligentCore-5eca9ecce9770af037006c31f206bdad22b10be2.zip
Implemented mapping with MAP_FLAG_DO_NOT_SYNCHRONIZE flag in Vulkan and D3D12
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp
index 07438730..0942014a 100644
--- a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp
@@ -349,10 +349,19 @@ void BufferD3D12Impl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 M
}
else if (m_Desc.Usage == USAGE_DYNAMIC)
{
- VERIFY(MapFlags & MAP_FLAG_DISCARD, "D3D12 buffer must be mapped for writing with MAP_FLAG_DISCARD flag");
+ VERIFY( (MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_DO_NOT_SYNCHRONIZE)) != 0, "D3D12 buffer must be mapped for writing with MAP_FLAG_DISCARD or MAP_FLAG_DO_NOT_SYNCHRONIZE flag");
+
auto *pCtxD3D12 = ValidatedCast<DeviceContextD3D12Impl>(pContext);
auto ContextId = pDeviceContextD3D12->GetContextId();
- m_DynamicData[ContextId] = pCtxD3D12->AllocateDynamicSpace(m_Desc.uiSizeInBytes);
+ if ((MapFlags & MAP_FLAG_DISCARD) != 0 || m_DynamicData[ContextId].CPUAddress == nullptr)
+ {
+ m_DynamicData[ContextId] = pCtxD3D12->AllocateDynamicSpace(m_Desc.uiSizeInBytes);
+ }
+ else
+ {
+ VERIFY_EXPR(MapFlags & MAP_FLAG_DO_NOT_SYNCHRONIZE);
+ // Reuse previously mapped region
+ }
pMappedData = m_DynamicData[ContextId].CPUAddress;
}
else