From 3ab4870f0826d91b00ccbeba8aa95189b779678b Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 16 Jun 2018 15:49:31 -0700 Subject: Improved dynamic heap memory usage stats reporting --- .../src/DeviceContextVkImpl.cpp | 28 ++++++++++++++++++++-- .../GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp | 5 ++-- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 9062d962..39be6239 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -22,6 +22,7 @@ */ #include "pch.h" +#include #include "RenderDeviceVkImpl.h" #include "DeviceContextVkImpl.h" #include "SwapChainVk.h" @@ -34,6 +35,29 @@ namespace Diligent { + static std::string GetUploadHeapName(bool bIsDeferred, Uint32 ContextId) + { + if(bIsDeferred) + { + std::stringstream ss; + ss << "Upload heap of deferred context #" << ContextId; + return ss.str(); + } + else + return "Upload heap of immediate context"; + } + + static std::string GetDynamicHeapName(bool bIsDeferred, Uint32 ContextId) + { + if (bIsDeferred) + { + std::stringstream ss; + ss << "Dynamic heap of deferred context #" << ContextId; + return ss.str(); + } + else + return "Dynamic heap of immediate context"; + } DeviceContextVkImpl::DeviceContextVkImpl( IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDeviceVkImpl, @@ -57,7 +81,7 @@ namespace Diligent // Upload heap must always be thread-safe as Finish() may be called from another thread m_UploadHeap { - bIsDeferred ? "Upload heap for deferred context" : "Upload heap for immediate context", + GetUploadHeapName(bIsDeferred, ContextId), pDeviceVkImpl->GetLogicalDevice(), pDeviceVkImpl->GetPhysicalDevice(), GetRawAllocator(), @@ -87,7 +111,7 @@ namespace Diligent m_DynamicHeap { pDeviceVkImpl->GetDynamicHeapRingBuffer(), - bIsDeferred ? "Dynamic heap for immediate context" : "Dynamic heap for deferred context", + GetDynamicHeapName(bIsDeferred, ContextId), bIsDeferred ? Attribs.DeferredCtxDynamicHeapPageSize : Attribs.ImmediateCtxDynamicHeapPageSize } { diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp index a62368c6..80322bcd 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp @@ -114,7 +114,7 @@ VulkanRingBuffer::~VulkanRingBuffer() VERIFY(m_BufferMemory == VK_NULL_HANDLE && m_VkBuffer == VK_NULL_HANDLE, "Vulkan resources must be explcitly released with Destroy()"); LOG_INFO_MESSAGE("Dynamic heap ring buffer usage stats:\n" " Total size: ", SizeFormatter{ m_RingBuffer.GetMaxSize(), 2 }, - ". Peak buffer size: ", SizeFormatter{ m_TotalPeakSize, 2, m_RingBuffer.GetMaxSize() }, + ". Peak allocated size: ", SizeFormatter{ m_TotalPeakSize, 2, m_RingBuffer.GetMaxSize() }, ". Peak frame size: ", SizeFormatter{ m_FramePeakSize, 2, m_RingBuffer.GetMaxSize() }, ". Peak utilization: ", std::fixed, std::setprecision(1), static_cast(m_TotalPeakSize) / static_cast(std::max(m_RingBuffer.GetMaxSize(), size_t{1})) * 100.0, '%' ); } @@ -206,8 +206,7 @@ VulkanDynamicAllocation VulkanDynamicHeap::Allocate(Uint32 SizeInBytes, Uint32 A VulkanDynamicHeap::~VulkanDynamicHeap() { LOG_INFO_MESSAGE(m_HeapName, " usage stats:\n" - " Peak allocated size: ", SizeFormatter{ m_PeakAllocatedSize, 2, m_PeakAllocatedSize }, - ". Peak used size: ", SizeFormatter{ m_PeakUsedSize, 2, m_PeakAllocatedSize }, + " Peak used/peak allocated size: ", SizeFormatter{ m_PeakUsedSize, 2, m_PeakAllocatedSize }, '/', SizeFormatter{ m_PeakAllocatedSize, 2, m_PeakAllocatedSize }, ". Peak utilization: ", std::fixed, std::setprecision(1), static_cast(m_PeakUsedSize) / static_cast(std::max(m_PeakAllocatedSize, 1U)) * 100.0, '%'); } -- cgit v1.2.3