Added constant CLEANUP_LEAKED_OBJECTS.

This commit is contained in:
Adam Sawicki 2018-08-21 14:12:38 +02:00
parent 821e36705f
commit f17013e699

View File

@ -97,6 +97,10 @@ static_assert(
_countof(VMA_FUNCTION_NAMES) == (size_t)VMA_FUNCTION::Count, _countof(VMA_FUNCTION_NAMES) == (size_t)VMA_FUNCTION::Count,
"VMA_FUNCTION_NAMES array doesn't match VMA_FUNCTION enum."); "VMA_FUNCTION_NAMES array doesn't match VMA_FUNCTION enum.");
// Set this to false to disable deleting leaked VmaAllocation, VmaPool objects
// and let VMA report asserts about them.
static const bool CLEANUP_LEAKED_OBJECTS = true;
static std::string g_FilePath; static std::string g_FilePath;
// Most significant 16 bits are major version, least significant 16 bits are minor version. // Most significant 16 bits are major version, least significant 16 bits are minor version.
static uint32_t g_FileVersion; static uint32_t g_FileVersion;
@ -895,10 +899,13 @@ void Player::FinalizeVulkan()
{ {
printf("WARNING: Allocations not destroyed: %zu.\n", m_Allocations.size()); printf("WARNING: Allocations not destroyed: %zu.\n", m_Allocations.size());
if(CLEANUP_LEAKED_OBJECTS)
{
for(const auto it : m_Allocations) for(const auto it : m_Allocations)
{ {
Destroy(it.second); Destroy(it.second);
} }
}
m_Allocations.clear(); m_Allocations.clear();
} }
@ -907,8 +914,13 @@ void Player::FinalizeVulkan()
{ {
printf("WARNING: Custom pools not destroyed: %zu.\n", m_Pools.size()); printf("WARNING: Custom pools not destroyed: %zu.\n", m_Pools.size());
if(CLEANUP_LEAKED_OBJECTS)
{
for(const auto it : m_Pools) for(const auto it : m_Pools)
{
vmaDestroyPool(m_Allocator, it.second.pool); vmaDestroyPool(m_Allocator, it.second.pool);
}
}
m_Pools.clear(); m_Pools.clear();
} }