MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator / PrintDetailedMap

Method PrintDetailedMap

include/vk_mem_alloc.h:8107–8420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8105
8106#if VMA_STATS_STRING_ENABLED
8107void VmaBlockMetadata_Linear::PrintDetailedMap(class VmaJsonWriter& json) const
8108{
8109 const VkDeviceSize size = GetSize();
8110 const SuballocationVectorType& suballocations1st = AccessSuballocations1st();
8111 const SuballocationVectorType& suballocations2nd = AccessSuballocations2nd();
8112 const size_t suballoc1stCount = suballocations1st.size();
8113 const size_t suballoc2ndCount = suballocations2nd.size();
8114
8115 // FIRST PASS
8116
8117 size_t unusedRangeCount = 0;
8118 VkDeviceSize usedBytes = 0;
8119
8120 VkDeviceSize lastOffset = 0;
8121
8122 size_t alloc2ndCount = 0;
8123 if (m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER)
8124 {
8125 const VkDeviceSize freeSpace2ndTo1stEnd = suballocations1st[m_1stNullItemsBeginCount].offset;
8126 size_t nextAlloc2ndIndex = 0;
8127 while (lastOffset < freeSpace2ndTo1stEnd)
8128 {
8129 // Find next non-null allocation or move nextAlloc2ndIndex to the end.
8130 while (nextAlloc2ndIndex < suballoc2ndCount &&
8131 suballocations2nd[nextAlloc2ndIndex].userData == VMA_NULL)
8132 {
8133 ++nextAlloc2ndIndex;
8134 }
8135
8136 // Found non-null allocation.
8137 if (nextAlloc2ndIndex < suballoc2ndCount)
8138 {
8139 const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex];
8140
8141 // 1. Process free space before this allocation.
8142 if (lastOffset < suballoc.offset)
8143 {
8144 // There is free space from lastOffset to suballoc.offset.
8145 ++unusedRangeCount;
8146 }
8147
8148 // 2. Process this allocation.
8149 // There is allocation with suballoc.offset, suballoc.size.
8150 ++alloc2ndCount;
8151 usedBytes += suballoc.size;
8152
8153 // 3. Prepare for next iteration.
8154 lastOffset = suballoc.offset + suballoc.size;
8155 ++nextAlloc2ndIndex;
8156 }
8157 // We are at the end.
8158 else
8159 {
8160 if (lastOffset < freeSpace2ndTo1stEnd)
8161 {
8162 // There is free space from lastOffset to freeSpace2ndTo1stEnd.
8163 ++unusedRangeCount;
8164 }

Callers 2

BuildStatsStringMethod · 0.80
vmaBuildStatsStringFunction · 0.80

Calls 15

AddDetailedStatisticsFunction · 0.85
IsFreeMethod · 0.80
BeginObjectMethod · 0.80
BeginStringMethod · 0.80
ContinueStringMethod · 0.80
EndStringMethod · 0.80
WriteStringMethod · 0.80
WriteNumberMethod · 0.80
GetMapRefCountMethod · 0.80
EndObjectMethod · 0.80
GetPreferredBlockSizeMethod · 0.80

Tested by

no test coverage detected