Add more memory profiler categories

This commit is contained in:
Wojtek Figat
2025-05-25 18:38:07 +02:00
parent a74c5e7943
commit 9dc4dbc6d7
6 changed files with 112 additions and 38 deletions

View File

@@ -244,7 +244,15 @@ bool GPUBuffer::Init(const GPUBufferDescription& desc)
LOG(Warning, "Cannot initialize buffer. Description: {0}", desc.ToString());
return true;
}
PROFILE_MEM_INC(GraphicsBuffers, GetMemoryUsage());
#if COMPILE_WITH_PROFILER
auto group = ProfilerMemory::Groups::GraphicsBuffers;
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::VertexBuffer))
group = ProfilerMemory::Groups::GraphicsVertexBuffers;
else if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::IndexBuffer))
group = ProfilerMemory::Groups::GraphicsIndexBuffers;
ProfilerMemory::IncrementGroup(group, _memoryUsage);
#endif
return false;
}
@@ -480,7 +488,15 @@ GPUResourceType GPUBuffer::GetResourceType() const
void GPUBuffer::OnReleaseGPU()
{
PROFILE_MEM_DEC(GraphicsBuffers, GetMemoryUsage());
#if COMPILE_WITH_PROFILER
auto group = ProfilerMemory::Groups::GraphicsBuffers;
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::VertexBuffer))
group = ProfilerMemory::Groups::GraphicsVertexBuffers;
else if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::IndexBuffer))
group = ProfilerMemory::Groups::GraphicsIndexBuffers;
ProfilerMemory::IncrementGroup(group, _memoryUsage);
#endif
_desc.Clear();
_isLocked = false;
}

View File

@@ -503,7 +503,17 @@ bool GPUTexture::Init(const GPUTextureDescription& desc)
LOG(Warning, "Cannot initialize texture. Description: {0}", desc.ToString());
return true;
}
PROFILE_MEM_INC(GraphicsTextures, GetMemoryUsage());
#if COMPILE_WITH_PROFILER
auto group = ProfilerMemory::Groups::GraphicsTextures;
if (_desc.IsRenderTarget())
group = ProfilerMemory::Groups::GraphicsRenderTargets;
else if (_desc.IsCubeMap())
group = ProfilerMemory::Groups::GraphicsCubeMaps;
else if (_desc.IsVolume())
group = ProfilerMemory::Groups::GraphicsVolumeTextures;
ProfilerMemory::IncrementGroup(group, _memoryUsage);
#endif
// Render targets and depth buffers doesn't support normal textures streaming and are considered to be always resident
if (IsRegularTexture() == false)
@@ -593,7 +603,17 @@ GPUResourceType GPUTexture::GetResourceType() const
void GPUTexture::OnReleaseGPU()
{
PROFILE_MEM_DEC(GraphicsTextures, GetMemoryUsage());
#if COMPILE_WITH_PROFILER
auto group = ProfilerMemory::Groups::GraphicsTextures;
if (_desc.IsRenderTarget())
group = ProfilerMemory::Groups::GraphicsRenderTargets;
else if (_desc.IsCubeMap())
group = ProfilerMemory::Groups::GraphicsCubeMaps;
else if (_desc.IsVolume())
group = ProfilerMemory::Groups::GraphicsVolumeTextures;
ProfilerMemory::DecrementGroup(group, _memoryUsage);
#endif
_desc.Clear();
_residentMipLevels = 0;
}