Debian Codegraph @

thirdparty/vulkan/patches/0003-VMA-add-vmaCalculateLazilyAllocatedBytes.patch

raw
1 diff --git a/thirdparty/vulkan/vk_mem_alloc.h b/thirdparty/vulkan/vk_mem_alloc.h
2 index ecb84094b9..c436209896 100644
3 --- a/thirdparty/vulkan/vk_mem_alloc.h
4 +++ b/thirdparty/vulkan/vk_mem_alloc.h
5 @@ -1713,6 +1713,19 @@ VMA_CALL_PRE void VMA_CALL_POST vmaCalculateStatistics(
6 VmaAllocator VMA_NOT_NULL allocator,
7 VmaTotalStatistics* VMA_NOT_NULL pStats);
8
9 +/** \brief Retrieves lazily allocated bytes
10 +
11 +This function is called "calculate" not "get" because it has to traverse all
12 +internal data structures, so it may be quite slow. Use it for debugging purposes.
13 +For faster but more brief statistics suitable to be called every frame or every allocation,
14 +use vmaGetHeapBudgets().
15 +
16 +Note that when using allocator from multiple threads, returned information may immediately
17 +become outdated.
18 +*/
19 +VMA_CALL_PRE uint64_t VMA_CALL_POST vmaCalculateLazilyAllocatedBytes(
20 + VmaAllocator VMA_NOT_NULL allocator);
21 +
22 /** \brief Retrieves information about current memory usage and budget for all memory heaps.
23
24 \param allocator
25 @@ -14912,6 +14925,26 @@ VMA_CALL_PRE void VMA_CALL_POST vmaCalculateStatistics(
26 allocator->CalculateStatistics(pStats);
27 }
28
29 +VMA_CALL_PRE uint64_t VMA_CALL_POST vmaCalculateLazilyAllocatedBytes(
30 + VmaAllocator allocator)
31 +{
32 + VMA_ASSERT(allocator);
33 + VMA_DEBUG_GLOBAL_MUTEX_LOCK
34 + VmaTotalStatistics stats;
35 + allocator->CalculateStatistics(&stats);
36 + uint64_t total_lazilily_allocated_bytes = 0;
37 + for (uint32_t heapIndex = 0; heapIndex < allocator->GetMemoryHeapCount(); ++heapIndex) {
38 + for (uint32_t typeIndex = 0; typeIndex < allocator->GetMemoryTypeCount(); ++typeIndex) {
39 + if (allocator->MemoryTypeIndexToHeapIndex(typeIndex) == heapIndex) {
40 + VkMemoryPropertyFlags flags = allocator->m_MemProps.memoryTypes[typeIndex].propertyFlags;
41 + if (flags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT)
42 + total_lazilily_allocated_bytes += stats.memoryType[typeIndex].statistics.allocationBytes;
43 + }
44 + }
45 + }
46 + return total_lazilily_allocated_bytes;
47 +}
48 +
49 VMA_CALL_PRE void VMA_CALL_POST vmaGetHeapBudgets(
50 VmaAllocator allocator,
51 VmaBudget* pBudgets)