Skip to content

Commit 7924e27

Browse files
Fixes in calls to VMA_DEBUG_LOG_FORMAT, using PRIu32 for compatibility
See #400, thanks @dneto0 and @alecazam
1 parent 01ccf06 commit 7924e27

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

include/vk_mem_alloc.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,7 +3038,7 @@ static void vma_aligned_free(void* VMA_NULLABLE ptr)
30383038
#if VMA_STATS_STRING_ENABLED
30393039
static inline void VmaUint32ToStr(char* VMA_NOT_NULL outStr, size_t strLen, uint32_t num)
30403040
{
3041-
snprintf(outStr, strLen, "%u", static_cast<unsigned int>(num));
3041+
snprintf(outStr, strLen, "%" PRIu32, num);
30423042
}
30433043
static inline void VmaUint64ToStr(char* VMA_NOT_NULL outStr, size_t strLen, uint64_t num)
30443044
{
@@ -6510,14 +6510,14 @@ void VmaBlockMetadata::DebugLogAllocation(VkDeviceSize offset, VkDeviceSize size
65106510
const char* name = allocation->GetName();
65116511

65126512
#if VMA_STATS_STRING_ENABLED
6513-
VMA_LEAK_LOG_FORMAT("UNFREED ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %s; Usage: %u",
6513+
VMA_LEAK_LOG_FORMAT("UNFREED ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %s; Usage: %" PRIu32,
65146514
offset, size, userData, name ? name : "vma_empty",
65156515
VMA_SUBALLOCATION_TYPE_NAMES[allocation->GetSuballocationType()],
65166516
allocation->GetBufferImageUsage());
65176517
#else
65186518
VMA_LEAK_LOG_FORMAT("UNFREED ALLOCATION; Offset: %" PRIu64 "; Size: %" PRIu64 "; UserData: %p; Name: %s; Type: %u",
65196519
offset, size, userData, name ? name : "vma_empty",
6520-
(uint32_t)allocation->GetSuballocationType());
6520+
(unsigned)allocation->GetSuballocationType());
65216521
#endif // VMA_STATS_STRING_ENABLED
65226522
}
65236523

@@ -11082,7 +11082,7 @@ VkResult VmaBlockVector::AllocatePage(
1108211082
pCurrBlock, size, alignment, createInfo.flags, createInfo.pUserData, suballocType, strategy, pAllocation);
1108311083
if (res == VK_SUCCESS)
1108411084
{
11085-
VMA_DEBUG_LOG_FORMAT(" Returned from last block #%u", pCurrBlock->GetId());
11085+
VMA_DEBUG_LOG_FORMAT(" Returned from last block #%" PRIu32, pCurrBlock->GetId());
1108611086
IncrementallySortBlocks();
1108711087
return VK_SUCCESS;
1108811088
}
@@ -11118,7 +11118,7 @@ VkResult VmaBlockVector::AllocatePage(
1111811118
pCurrBlock, size, alignment, createInfo.flags, createInfo.pUserData, suballocType, strategy, pAllocation);
1111911119
if (res == VK_SUCCESS)
1112011120
{
11121-
VMA_DEBUG_LOG_FORMAT(" Returned from existing block #%u", pCurrBlock->GetId());
11121+
VMA_DEBUG_LOG_FORMAT(" Returned from existing block #%" PRIu32, pCurrBlock->GetId());
1112211122
IncrementallySortBlocks();
1112311123
return VK_SUCCESS;
1112411124
}
@@ -11137,7 +11137,7 @@ VkResult VmaBlockVector::AllocatePage(
1113711137
pCurrBlock, size, alignment, createInfo.flags, createInfo.pUserData, suballocType, strategy, pAllocation);
1113811138
if (res == VK_SUCCESS)
1113911139
{
11140-
VMA_DEBUG_LOG_FORMAT(" Returned from existing block #%u", pCurrBlock->GetId());
11140+
VMA_DEBUG_LOG_FORMAT(" Returned from existing block #%" PRIu32, pCurrBlock->GetId());
1114111141
IncrementallySortBlocks();
1114211142
return VK_SUCCESS;
1114311143
}
@@ -11154,7 +11154,7 @@ VkResult VmaBlockVector::AllocatePage(
1115411154
VkResult res = AllocateFromBlock(pCurrBlock, size, alignment, createInfo.flags, createInfo.pUserData, suballocType, strategy, pAllocation);
1115511155
if (res == VK_SUCCESS)
1115611156
{
11157-
VMA_DEBUG_LOG_FORMAT(" Returned from existing block #%u", pCurrBlock->GetId());
11157+
VMA_DEBUG_LOG_FORMAT(" Returned from existing block #%" PRIu32, pCurrBlock->GetId());
1115811158
IncrementallySortBlocks();
1115911159
return VK_SUCCESS;
1116011160
}
@@ -11221,7 +11221,7 @@ VkResult VmaBlockVector::AllocatePage(
1122111221
pBlock, size, alignment, createInfo.flags, createInfo.pUserData, suballocType, strategy, pAllocation);
1122211222
if (res == VK_SUCCESS)
1122311223
{
11224-
VMA_DEBUG_LOG_FORMAT(" Created new block #%u Size=%" PRIu64, pBlock->GetId(), newBlockSize);
11224+
VMA_DEBUG_LOG_FORMAT(" Created new block #%" PRIu32 " Size=%" PRIu64, pBlock->GetId(), newBlockSize);
1122511225
IncrementallySortBlocks();
1122611226
return VK_SUCCESS;
1122711227
}
@@ -11270,7 +11270,7 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
1127011270
pBlock->PostFree(m_hAllocator);
1127111271
VMA_HEAVY_ASSERT(pBlock->Validate());
1127211272

11273-
VMA_DEBUG_LOG_FORMAT(" Freed from MemoryTypeIndex=%u", m_MemoryTypeIndex);
11273+
VMA_DEBUG_LOG_FORMAT(" Freed from MemoryTypeIndex=%" PRIu32, m_MemoryTypeIndex);
1127411274

1127511275
const bool canDeleteBlock = m_Blocks.size() > m_MinBlockCount;
1127611276
// pBlock became empty after this deallocation.
@@ -11303,7 +11303,7 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
1130311303
// lock, for performance reason.
1130411304
if (pBlockToDelete != VMA_NULL)
1130511305
{
11306-
VMA_DEBUG_LOG_FORMAT(" Deleted empty block #%u", pBlockToDelete->GetId());
11306+
VMA_DEBUG_LOG_FORMAT(" Deleted empty block #%" PRIu32, pBlockToDelete->GetId());
1130711307
pBlockToDelete->Destroy(m_hAllocator);
1130811308
vma_delete(m_hAllocator, pBlockToDelete);
1130911309
}
@@ -13102,7 +13102,7 @@ VkResult VmaAllocator_T::AllocateMemoryOfType(
1310213102
VmaAllocation* pAllocations)
1310313103
{
1310413104
VMA_ASSERT(pAllocations != VMA_NULL);
13105-
VMA_DEBUG_LOG_FORMAT(" AllocateMemory: MemoryTypeIndex=%u, AllocationCount=%zu, Size=%" PRIu64, memTypeIndex, allocationCount, size);
13105+
VMA_DEBUG_LOG_FORMAT(" AllocateMemory: MemoryTypeIndex=%" PRIu32 ", AllocationCount=%zu, Size=%" PRIu64, memTypeIndex, allocationCount, size);
1310613106

1310713107
VmaAllocationCreateInfo finalCreateInfo = createInfo;
1310813108
VkResult res = CalcMemTypeParams(
@@ -13348,7 +13348,7 @@ VkResult VmaAllocator_T::AllocateDedicatedMemory(
1334813348
{
1334913349
dedicatedAllocations.Register(pAllocations[allocIndex]);
1335013350
}
13351-
VMA_DEBUG_LOG_FORMAT(" Allocated DedicatedMemory Count=%zu, MemoryTypeIndex=#%u", allocationCount, memTypeIndex);
13351+
VMA_DEBUG_LOG_FORMAT(" Allocated DedicatedMemory Count=%zu, MemoryTypeIndex=#%" PRIu32, allocationCount, memTypeIndex);
1335213352
}
1335313353
else
1335413354
{
@@ -13925,7 +13925,7 @@ void VmaAllocator_T::GetAllocationInfo2(VmaAllocation hAllocation, VmaAllocation
1392513925

1392613926
VkResult VmaAllocator_T::CreatePool(const VmaPoolCreateInfo* pCreateInfo, VmaPool* pPool)
1392713927
{
13928-
VMA_DEBUG_LOG_FORMAT(" CreatePool: MemoryTypeIndex=%u, flags=%u", pCreateInfo->memoryTypeIndex, pCreateInfo->flags);
13928+
VMA_DEBUG_LOG_FORMAT(" CreatePool: MemoryTypeIndex=%" PRIu32 ", flags=%" PRIu32, pCreateInfo->memoryTypeIndex, pCreateInfo->flags);
1392913929

1393013930
VmaPoolCreateInfo newCreateInfo = *pCreateInfo;
1393113931

@@ -14442,7 +14442,7 @@ void VmaAllocator_T::FreeDedicatedMemory(const VmaAllocation allocation)
1444214442
m_Budget.RemoveAllocation(MemoryTypeIndexToHeapIndex(allocation->GetMemoryTypeIndex()), allocation->GetSize());
1444314443
m_AllocationObjectAllocator.Free(allocation);
1444414444

14445-
VMA_DEBUG_LOG_FORMAT(" Freed DedicatedMemory MemoryTypeIndex=%u", memTypeIndex);
14445+
VMA_DEBUG_LOG_FORMAT(" Freed DedicatedMemory MemoryTypeIndex=%" PRIu32, memTypeIndex);
1444614446
}
1444714447

1444814448
uint32_t VmaAllocator_T::CalculateGpuDefragmentationMemoryTypeBits() const

0 commit comments

Comments
 (0)