Minor fixes after merging #226

This commit is contained in:
Adam Sawicki 2022-01-31 17:20:29 +01:00
parent 83d3571b7c
commit 48d3cc46a0
2 changed files with 14 additions and 4 deletions

View File

@ -6067,13 +6067,15 @@ void VmaBlockMetadata::DebugLogAllocation(VkDeviceSize offset, VkDeviceSize size
#else #else
if (userData != VMA_NULL && allocation->IsUserDataString()) if (userData != VMA_NULL && allocation->IsUserDataString())
{ {
VMA_DEBUG_LOG("UNFREED ALLOCATION; Offset: %llu; Size: %llu; UserData: %s", VMA_DEBUG_LOG("UNFREED ALLOCATION; Offset: %llu; Size: %llu; UserData: %s; Type: %u",
offset, size, reinterpret_cast<const char*>(userData)); offset, size, reinterpret_cast<const char*>(userData),
(uint32_t)allocation->GetSuballocationType());
} }
else else
{ {
VMA_DEBUG_LOG("UNFREED ALLOCATION; Offset: %llu; Size: %llu; UserData: %p", VMA_DEBUG_LOG("UNFREED ALLOCATION; Offset: %llu; Size: %llu; UserData: %p; Type: %u",
offset, size, userData); offset, size, userData,
(uint32_t)allocation->GetSuballocationType());
} }
#endif // VMA_STATS_STRING_ENABLED #endif // VMA_STATS_STRING_ENABLED
} }

View File

@ -709,11 +709,13 @@ VkResult MainTest(Result& outResult, const Config& config)
void SaveAllocatorStatsToFile(const wchar_t* filePath) 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); wprintf(L"Saving JSON dump to file \"%s\"\n", filePath);
char* stats; char* stats;
vmaBuildStatsString(g_hAllocator, &stats, VK_TRUE); vmaBuildStatsString(g_hAllocator, &stats, VK_TRUE);
SaveFile(filePath, stats, strlen(stats)); SaveFile(filePath, stats, strlen(stats));
vmaFreeStatsString(g_hAllocator, stats); vmaFreeStatsString(g_hAllocator, stats);
#endif
} }
struct AllocInfo struct AllocInfo
@ -2778,6 +2780,7 @@ static void TestVirtualBlocks()
// # Generate JSON dump // # Generate JSON dump
#if !defined(VMA_STATS_STRING_ENABLED) || VMA_STATS_STRING_ENABLED
char* json = nullptr; char* json = nullptr;
vmaBuildVirtualBlockStatsString(block, &json, VK_TRUE); vmaBuildVirtualBlockStatsString(block, &json, VK_TRUE);
{ {
@ -2786,6 +2789,7 @@ static void TestVirtualBlocks()
TEST( str.find("\"UserData\": \"0000000000000002\"") != std::string::npos ); TEST( str.find("\"UserData\": \"0000000000000002\"") != std::string::npos );
} }
vmaFreeVirtualBlockStatsString(block, json); vmaFreeVirtualBlockStatsString(block, json);
#endif
// # Free alloc0, leave alloc2 unfreed. // # Free alloc0, leave alloc2 unfreed.
@ -2986,6 +2990,7 @@ static void TestVirtualBlocksAlgorithms()
TEST(statInfo.usedBytes >= actualAllocSizeSum); TEST(statInfo.usedBytes >= actualAllocSizeSum);
} }
#if !defined(VMA_STATS_STRING_ENABLED) || VMA_STATS_STRING_ENABLED
// Build JSON dump string // Build JSON dump string
{ {
char* json = nullptr; char* json = nullptr;
@ -2993,6 +2998,7 @@ static void TestVirtualBlocksAlgorithms()
int I = 0; // put a breakpoint here to debug int I = 0; // put a breakpoint here to debug
vmaFreeVirtualBlockStatsString(block, json); vmaFreeVirtualBlockStatsString(block, json);
} }
#endif
// Final cleanup // Final cleanup
vmaClearVirtualBlock(block); vmaClearVirtualBlock(block);
@ -3996,6 +4002,7 @@ static void ManuallyTestLinearAllocator()
VmaPoolStats poolStats; VmaPoolStats poolStats;
vmaGetPoolStats(g_hAllocator, pool, &poolStats); vmaGetPoolStats(g_hAllocator, pool, &poolStats);
#if !defined(VMA_STATS_STRING_ENABLED) || VMA_STATS_STRING_ENABLED
char* statsStr = nullptr; char* statsStr = nullptr;
vmaBuildStatsString(g_hAllocator, &statsStr, VK_TRUE); vmaBuildStatsString(g_hAllocator, &statsStr, VK_TRUE);
@ -4004,6 +4011,7 @@ static void ManuallyTestLinearAllocator()
int I = 0; int I = 0;
vmaFreeStatsString(g_hAllocator, statsStr); vmaFreeStatsString(g_hAllocator, statsStr);
#endif
// Destroy the buffers in reverse order. // Destroy the buffers in reverse order.
while(!bufInfo.empty()) while(!bufInfo.empty())