diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-07-22 18:47:37 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-07-22 18:47:37 +0000 |
| commit | 5eca9ecce9770af037006c31f206bdad22b10be2 (patch) | |
| tree | bd8f40bbf333f64c5390b1b0d8cbfd063741e8dc /Graphics/GraphicsEngineVulkan | |
| parent | Fixed release build error (diff) | |
| download | DiligentCore-5eca9ecce9770af037006c31f206bdad22b10be2.tar.gz DiligentCore-5eca9ecce9770af037006c31f206bdad22b10be2.zip | |
Implemented mapping with MAP_FLAG_DO_NOT_SYNCHRONIZE flag in Vulkan and D3D12
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp index 90cc149f..c81361d8 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp @@ -282,7 +282,7 @@ void BufferVkImpl :: CopyData(IDeviceContext* pContext, IBuffer* pSrcBuffer, Uin pDeviceContextVk->CopyBufferRegion(ValidatedCast<BufferVkImpl>(pSrcBuffer), this, SrcOffset, DstOffset, Size); } -void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData) +void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData) { TBufferBase::Map( pContext, MapType, MapFlags, pMappedData ); @@ -326,20 +326,29 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF else if (m_Desc.Usage == USAGE_DYNAMIC) { #ifdef DEVELOPMENT - if( (MapFlags & MAP_FLAG_DISCARD) == 0 ) + if( (MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_DO_NOT_SYNCHRONIZE)) == 0 ) { - LOG_ERROR_MESSAGE("Failed to map buffer '", m_Desc.Name, "': Vk buffer must be mapped for writing with MAP_FLAG_DISCARD flag. Context Id: ", pDeviceContextVk->GetContextId()); + LOG_ERROR_MESSAGE("Failed to map buffer '", m_Desc.Name, "': Vk buffer must be mapped for writing with MAP_FLAG_DISCARD or MAP_FLAG_DO_NOT_SYNCHRONIZE flag. Context Id: ", pDeviceContextVk->GetContextId()); return; } #endif - auto DynAlloc = pDeviceContextVk->AllocateDynamicSpace(m_Desc.uiSizeInBytes); - if(DynAlloc.pParentDynamicHeap != nullptr) + auto& DynAllocation = m_DynamicAllocations[pDeviceContextVk->GetContextId()]; + if ( (MapFlags & MAP_FLAG_DISCARD) != 0 || DynAllocation.pParentDynamicHeap == nullptr ) + { + DynAllocation = pDeviceContextVk->AllocateDynamicSpace(m_Desc.uiSizeInBytes); + } + else + { + VERIFY_EXPR(MapFlags & MAP_FLAG_DO_NOT_SYNCHRONIZE); + // Reuse the same allocation + } + + if (DynAllocation.pParentDynamicHeap != nullptr) { const auto& DynamicHeap = pDeviceVk->GetDynamicHeapRingBuffer(); auto* CPUAddress = DynamicHeap.GetCPUAddress(); - pMappedData = CPUAddress + DynAlloc.Offset; - m_DynamicAllocations[pDeviceContextVk->GetContextId()] = std::move(DynAlloc); + pMappedData = CPUAddress + DynAllocation.Offset; } else { |
