From 111636445d2e19420468cdf78ffd2b87b7ad6489 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 2 Dec 2018 10:22:22 -0800 Subject: Brought back MapType paramter to UnmapBuffer() function. The performance hit of keeping track of mapped buffers turned out to be unacceptable --- .../include/DeviceContextVkImpl.h | 8 +------ .../src/DeviceContextVkImpl.cpp | 27 ++++------------------ 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 978c374b..4f207929 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -112,7 +112,7 @@ public: virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)override final; - virtual void UnmapBuffer(IBuffer* pBuffer)override final; + virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType)override final; virtual void UpdateTexture(ITexture* pTexture, Uint32 MipLevel, @@ -346,12 +346,6 @@ private: }; std::unordered_map m_MappedTextures; - struct MappedBufferInfo - { - MAP_TYPE MapType; - }; - std::unordered_map m_MappedBuffers; - VulkanUtilities::VulkanCommandBufferPool m_CmdPool; VulkanUploadHeap m_UploadHeap; VulkanDynamicHeap m_DynamicHeap; diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 226faf1a..b0fe445b 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -861,8 +861,8 @@ namespace Diligent void DeviceContextVkImpl::FinishFrame() { -#ifdef DEVELOPMENT - for(const auto& MappedBuffIt : m_MappedBuffers) +#ifdef _DEBUG + for(const auto& MappedBuffIt : m_DbgMappedBuffers) { const auto& BuffDesc = MappedBuffIt.first->GetDesc(); if (BuffDesc.Usage == USAGE_DYNAMIC) @@ -1340,13 +1340,6 @@ namespace Diligent auto* pBufferVk = ValidatedCast(pBuffer); const auto& BuffDesc = pBufferVk->GetDesc(); -#ifdef DEVELOPMENT - if (m_MappedBuffers.find(pBufferVk) != m_MappedBuffers.end()) - { - LOG_ERROR_MESSAGE("Buffer '", BuffDesc.Name, "' has already been mapped"); - } -#endif - if (MapType == MAP_READ ) { LOG_ERROR("Mapping buffer for reading is not yet imlemented in Vulkan backend"); @@ -1398,23 +1391,13 @@ namespace Diligent { LOG_ERROR("Only MAP_WRITE_DISCARD and MAP_READ are currently implemented in Vk"); } - m_MappedBuffers[pBufferVk] = MappedBufferInfo{MapType}; } - void DeviceContextVkImpl::UnmapBuffer(IBuffer* pBuffer) + void DeviceContextVkImpl::UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) { - TDeviceContextBase::UnmapBuffer(pBuffer); + TDeviceContextBase::UnmapBuffer(pBuffer, MapType); auto* pBufferVk = ValidatedCast(pBuffer); - - auto MappedBufferIt = m_MappedBuffers.find(pBufferVk); - if (MappedBufferIt == m_MappedBuffers.end()) - { - LOG_ERROR_MESSAGE("Buffer '", pBufferVk->GetDesc().Name, "' has not been mapped."); - return; - } - const auto& MapInfo = MappedBufferIt->second; const auto& BuffDesc = pBufferVk->GetDesc(); - auto MapType = MapInfo.MapType; if (MapType == MAP_READ ) { @@ -1438,8 +1421,6 @@ namespace Diligent } } } - - m_MappedBuffers.erase(MappedBufferIt); } void DeviceContextVkImpl::UpdateTexture(ITexture* pTexture, -- cgit v1.2.3