Added macro VMA_LEAK_LOG_FORMAT

Fixes #379 - thanks @alecazam
This commit is contained in:
Adam Sawicki 2024-01-14 21:22:25 +01:00
parent 51bac8e0ea
commit c23192cfc1

View File

@ -2938,6 +2938,10 @@ static void vma_aligned_free(void* VMA_NULLABLE ptr)
#define VMA_DEBUG_LOG(str) VMA_DEBUG_LOG_FORMAT("%s", (str)) #define VMA_DEBUG_LOG(str) VMA_DEBUG_LOG_FORMAT("%s", (str))
#endif #endif
#ifndef VMA_LEAK_LOG_FORMAT
#define VMA_LEAK_LOG_FORMAT(format, ...) VMA_DEBUG_LOG_FORMAT(format, __VA_ARGS__)
#endif
#ifndef VMA_CLASS_NO_COPY #ifndef VMA_CLASS_NO_COPY
#define VMA_CLASS_NO_COPY(className) \ #define VMA_CLASS_NO_COPY(className) \
private: \ private: \
@ -6508,7 +6512,7 @@ void VmaBlockMetadata::DebugLogAllocation(VkDeviceSize offset, VkDeviceSize size
{ {
if (IsVirtual()) if (IsVirtual())
{ {
VMA_DEBUG_LOG_FORMAT("UNFREED VIRTUAL ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p", offset, size, userData); VMA_LEAK_LOG_FORMAT("UNFREED VIRTUAL ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p", offset, size, userData);
} }
else else
{ {
@ -6519,12 +6523,12 @@ void VmaBlockMetadata::DebugLogAllocation(VkDeviceSize offset, VkDeviceSize size
const char* name = allocation->GetName(); const char* name = allocation->GetName();
#if VMA_STATS_STRING_ENABLED #if VMA_STATS_STRING_ENABLED
VMA_DEBUG_LOG_FORMAT("UNFREED ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %s; Usage: %u", VMA_LEAK_LOG_FORMAT("UNFREED ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %s; Usage: %u",
offset, size, userData, name ? name : "vma_empty", offset, size, userData, name ? name : "vma_empty",
VMA_SUBALLOCATION_TYPE_NAMES[allocation->GetSuballocationType()], VMA_SUBALLOCATION_TYPE_NAMES[allocation->GetSuballocationType()],
allocation->GetBufferImageUsage()); allocation->GetBufferImageUsage());
#else #else
VMA_DEBUG_LOG_FORMAT("UNFREED ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %u", VMA_LEAK_LOG_FORMAT("UNFREED ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %u",
offset, size, userData, name ? name : "vma_empty", offset, size, userData, name ? name : "vma_empty",
(uint32_t)allocation->GetSuballocationType()); (uint32_t)allocation->GetSuballocationType());
#endif // VMA_STATS_STRING_ENABLED #endif // VMA_STATS_STRING_ENABLED
@ -11345,7 +11349,8 @@ VmaVirtualBlock_T::VmaVirtualBlock_T(const VmaVirtualBlockCreateInfo& createInfo
VmaVirtualBlock_T::~VmaVirtualBlock_T() VmaVirtualBlock_T::~VmaVirtualBlock_T()
{ {
// Define macro VMA_DEBUG_LOG_FORMAT to receive the list of the unfreed allocations // Define macro VMA_DEBUG_LOG_FORMAT or more specialized VMA_LEAK_LOG_FORMAT
// to receive the list of the unfreed allocations.
if (!m_Metadata->IsEmpty()) if (!m_Metadata->IsEmpty())
m_Metadata->DebugLogAllAllocations(); m_Metadata->DebugLogAllAllocations();
// This is the most important assert in the entire library. // This is the most important assert in the entire library.
@ -11840,7 +11845,8 @@ void VmaDeviceMemoryBlock::Init(
void VmaDeviceMemoryBlock::Destroy(VmaAllocator allocator) void VmaDeviceMemoryBlock::Destroy(VmaAllocator allocator)
{ {
// Define macro VMA_DEBUG_LOG_FORMAT to receive the list of the unfreed allocations // Define macro VMA_DEBUG_LOG_FORMAT or more specialized VMA_LEAK_LOG_FORMAT
// to receive the list of the unfreed allocations.
if (!m_pMetadata->IsEmpty()) if (!m_pMetadata->IsEmpty())
m_pMetadata->DebugLogAllAllocations(); m_pMetadata->DebugLogAllAllocations();
// This is the most important assert in the entire library. // This is the most important assert in the entire library.