Add memory profiling events to the main areas of the engine
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#include "Engine/Utilities/StringConverter.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Profiler/ProfilerMemory.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
#include "Engine/Scripting/Enums.h"
|
||||
|
||||
@@ -229,9 +230,13 @@ static VKAPI_ATTR VkBool32 VKAPI_PTR DebugUtilsCallback(VkDebugUtilsMessageSever
|
||||
|
||||
const String message(callbackData->pMessage);
|
||||
if (callbackData->pMessageIdName)
|
||||
{
|
||||
LOG(Info, "[Vulkan] {0} {1}:{2}({3}) {4}", type, severity, callbackData->messageIdNumber, String(callbackData->pMessageIdName), message);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(Info, "[Vulkan] {0} {1}:{2} {3}", type, severity, callbackData->messageIdNumber, message);
|
||||
}
|
||||
|
||||
#if BUILD_DEBUG
|
||||
if (auto* context = (GPUContextVulkan*)GPUDevice::Instance->GetMainContext())
|
||||
@@ -2095,16 +2100,19 @@ void GPUDeviceVulkan::WaitForGPU()
|
||||
|
||||
GPUTexture* GPUDeviceVulkan::CreateTexture(const StringView& name)
|
||||
{
|
||||
PROFILE_MEM(GraphicsTextures);
|
||||
return New<GPUTextureVulkan>(this, name);
|
||||
}
|
||||
|
||||
GPUShader* GPUDeviceVulkan::CreateShader(const StringView& name)
|
||||
{
|
||||
PROFILE_MEM(GraphicsShaders);
|
||||
return New<GPUShaderVulkan>(this, name);
|
||||
}
|
||||
|
||||
GPUPipelineState* GPUDeviceVulkan::CreatePipelineState()
|
||||
{
|
||||
PROFILE_MEM(GraphicsCommands);
|
||||
return New<GPUPipelineStateVulkan>(this);
|
||||
}
|
||||
|
||||
@@ -2115,6 +2123,7 @@ GPUTimerQuery* GPUDeviceVulkan::CreateTimerQuery()
|
||||
|
||||
GPUBuffer* GPUDeviceVulkan::CreateBuffer(const StringView& name)
|
||||
{
|
||||
PROFILE_MEM(GraphicsBuffers);
|
||||
return New<GPUBufferVulkan>(this, name);
|
||||
}
|
||||
|
||||
@@ -2135,6 +2144,7 @@ GPUSwapChain* GPUDeviceVulkan::CreateSwapChain(Window* window)
|
||||
|
||||
GPUConstantBuffer* GPUDeviceVulkan::CreateConstantBuffer(uint32 size, const StringView& name)
|
||||
{
|
||||
PROFILE_MEM(GraphicsShaders);
|
||||
return New<GPUConstantBufferVulkan>(this, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "Engine/Core/Types/DataContainer.h"
|
||||
#include "Engine/Serialization/MemoryReadStream.h"
|
||||
#include "Engine/Graphics/PixelFormatExtensions.h"
|
||||
#include "Engine/Profiler/ProfilerMemory.h"
|
||||
|
||||
#if PLATFORM_DESKTOP
|
||||
#define VULKAN_UNIFORM_RING_BUFFER_SIZE (24 * 1024 * 1024)
|
||||
@@ -41,6 +42,7 @@ UniformBufferUploaderVulkan::UniformBufferUploaderVulkan(GPUDeviceVulkan* device
|
||||
VkResult result = vmaCreateBuffer(_device->Allocator, &bufferInfo, &allocInfo, &_buffer, &_allocation, nullptr);
|
||||
LOG_VULKAN_RESULT(result);
|
||||
_memoryUsage = bufferInfo.size;
|
||||
PROFILE_MEM_INC(GraphicsCommands, _memoryUsage);
|
||||
|
||||
// Map buffer
|
||||
result = vmaMapMemory(_device->Allocator, _allocation, (void**)&_mapped);
|
||||
@@ -87,6 +89,7 @@ void UniformBufferUploaderVulkan::OnReleaseGPU()
|
||||
{
|
||||
if (_allocation != VK_NULL_HANDLE)
|
||||
{
|
||||
PROFILE_MEM_DEC(GraphicsCommands, _memoryUsage);
|
||||
if (_mapped)
|
||||
{
|
||||
vmaUnmapMemory(_device->Allocator, _allocation);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "Engine/Graphics/GPULimits.h"
|
||||
#include "Engine/Scripting/Enums.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Profiler/ProfilerMemory.h"
|
||||
|
||||
void BackBufferVulkan::Setup(GPUSwapChainVulkan* window, VkImage backbuffer, PixelFormat format, VkExtent3D extent)
|
||||
{
|
||||
@@ -61,6 +62,7 @@ void GPUSwapChainVulkan::OnReleaseGPU()
|
||||
ReleaseBackBuffer();
|
||||
|
||||
// Release data
|
||||
PROFILE_MEM_DEC(Graphics, _memoryUsage);
|
||||
_currentImageIndex = -1;
|
||||
_semaphoreIndex = 0;
|
||||
_acquiredImageIndex = -1;
|
||||
@@ -76,6 +78,7 @@ void GPUSwapChainVulkan::OnReleaseGPU()
|
||||
_surface = VK_NULL_HANDLE;
|
||||
}
|
||||
_width = _height = 0;
|
||||
_memoryUsage = 0;
|
||||
}
|
||||
|
||||
bool GPUSwapChainVulkan::IsFullscreen()
|
||||
@@ -412,6 +415,7 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height)
|
||||
|
||||
// Estimate memory usage
|
||||
_memoryUsage = 1024 + RenderTools::CalculateTextureMemoryUsage(_format, _width, _height, 1) * _backBuffers.Count();
|
||||
PROFILE_MEM_INC(Graphics, _memoryUsage);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user