From 48d3cc46a0820c4dafac026483ceea98b2d4bbbd Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Mon, 31 Jan 2022 17:20:29 +0100 Subject: [PATCH] Minor fixes after merging #226 --- include/vk_mem_alloc.h | 10 ++++++---- src/Tests.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index 0662577..ecc19a2 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -6067,13 +6067,15 @@ void VmaBlockMetadata::DebugLogAllocation(VkDeviceSize offset, VkDeviceSize size #else if (userData != VMA_NULL && allocation->IsUserDataString()) { - VMA_DEBUG_LOG("UNFREED ALLOCATION; Offset: %llu; Size: %llu; UserData: %s", - offset, size, reinterpret_cast(userData)); + VMA_DEBUG_LOG("UNFREED ALLOCATION; Offset: %llu; Size: %llu; UserData: %s; Type: %u", + offset, size, reinterpret_cast(userData), + (uint32_t)allocation->GetSuballocationType()); } else { - VMA_DEBUG_LOG("UNFREED ALLOCATION; Offset: %llu; Size: %llu; UserData: %p", - offset, size, userData); + VMA_DEBUG_LOG("UNFREED ALLOCATION; Offset: %llu; Size: %llu; UserData: %p; Type: %u", + offset, size, userData, + (uint32_t)allocation->GetSuballocationType()); } #endif // VMA_STATS_STRING_ENABLED } diff --git a/src/Tests.cpp b/src/Tests.cpp index 770e803..6367d41 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp @@ -709,11 +709,13 @@ VkResult MainTest(Result& outResult, const Config& config) void SaveAllocatorStatsToFile(const wchar_t* filePath) { +#if !defined(VMA_STATS_STRING_ENABLED) || VMA_STATS_STRING_ENABLED wprintf(L"Saving JSON dump to file \"%s\"\n", filePath); char* stats; vmaBuildStatsString(g_hAllocator, &stats, VK_TRUE); SaveFile(filePath, stats, strlen(stats)); vmaFreeStatsString(g_hAllocator, stats); +#endif } struct AllocInfo @@ -2778,6 +2780,7 @@ static void TestVirtualBlocks() // # Generate JSON dump +#if !defined(VMA_STATS_STRING_ENABLED) || VMA_STATS_STRING_ENABLED char* json = nullptr; vmaBuildVirtualBlockStatsString(block, &json, VK_TRUE); { @@ -2786,6 +2789,7 @@ static void TestVirtualBlocks() TEST( str.find("\"UserData\": \"0000000000000002\"") != std::string::npos ); } vmaFreeVirtualBlockStatsString(block, json); +#endif // # Free alloc0, leave alloc2 unfreed. @@ -2986,6 +2990,7 @@ static void TestVirtualBlocksAlgorithms() TEST(statInfo.usedBytes >= actualAllocSizeSum); } +#if !defined(VMA_STATS_STRING_ENABLED) || VMA_STATS_STRING_ENABLED // Build JSON dump string { char* json = nullptr; @@ -2993,6 +2998,7 @@ static void TestVirtualBlocksAlgorithms() int I = 0; // put a breakpoint here to debug vmaFreeVirtualBlockStatsString(block, json); } +#endif // Final cleanup vmaClearVirtualBlock(block); @@ -3996,6 +4002,7 @@ static void ManuallyTestLinearAllocator() VmaPoolStats poolStats; vmaGetPoolStats(g_hAllocator, pool, &poolStats); +#if !defined(VMA_STATS_STRING_ENABLED) || VMA_STATS_STRING_ENABLED char* statsStr = nullptr; vmaBuildStatsString(g_hAllocator, &statsStr, VK_TRUE); @@ -4004,6 +4011,7 @@ static void ManuallyTestLinearAllocator() int I = 0; vmaFreeStatsString(g_hAllocator, statsStr); +#endif // Destroy the buffers in reverse order. while(!bufInfo.empty())