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

Method GetHeapBudgets

include/vk_mem_alloc.h:14782–14836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14780}
14781
14782void VmaAllocator_T::GetHeapBudgets(VmaBudget* outBudgets, uint32_t firstHeap, uint32_t heapCount)
14783{
14784#if VMA_MEMORY_BUDGET
14785 if(m_UseExtMemoryBudget)
14786 {
14787 if(m_Budget.m_OperationsSinceBudgetFetch < 30)
14788 {
14789 VmaMutexLockRead lockRead(m_Budget.m_BudgetMutex, m_UseMutex);
14790 for(uint32_t i = 0; i < heapCount; ++i, ++outBudgets)
14791 {
14792 const uint32_t heapIndex = firstHeap + i;
14793
14794 outBudgets->statistics.blockCount = m_Budget.m_BlockCount[heapIndex];
14795 outBudgets->statistics.allocationCount = m_Budget.m_AllocationCount[heapIndex];
14796 outBudgets->statistics.blockBytes = m_Budget.m_BlockBytes[heapIndex];
14797 outBudgets->statistics.allocationBytes = m_Budget.m_AllocationBytes[heapIndex];
14798
14799 if(m_Budget.m_VulkanUsage[heapIndex] + outBudgets->statistics.blockBytes > m_Budget.m_BlockBytesAtBudgetFetch[heapIndex])
14800 {
14801 outBudgets->usage = m_Budget.m_VulkanUsage[heapIndex] +
14802 outBudgets->statistics.blockBytes - m_Budget.m_BlockBytesAtBudgetFetch[heapIndex];
14803 }
14804 else
14805 {
14806 outBudgets->usage = 0;
14807 }
14808
14809 // Have to take MIN with heap size because explicit HeapSizeLimit is included in it.
14810 outBudgets->budget = VMA_MIN(
14811 m_Budget.m_VulkanBudget[heapIndex], m_MemProps.memoryHeaps[heapIndex].size);
14812 }
14813 }
14814 else
14815 {
14816 UpdateVulkanBudget(); // Outside of mutex lock
14817 GetHeapBudgets(outBudgets, firstHeap, heapCount); // Recursion
14818 }
14819 }
14820 else
14821#endif
14822 {
14823 for(uint32_t i = 0; i < heapCount; ++i, ++outBudgets)
14824 {
14825 const uint32_t heapIndex = firstHeap + i;
14826
14827 outBudgets->statistics.blockCount = m_Budget.m_BlockCount[heapIndex];
14828 outBudgets->statistics.allocationCount = m_Budget.m_AllocationCount[heapIndex];
14829 outBudgets->statistics.blockBytes = m_Budget.m_BlockBytes[heapIndex];
14830 outBudgets->statistics.allocationBytes = m_Budget.m_AllocationBytes[heapIndex];
14831
14832 outBudgets->usage = outBudgets->statistics.blockBytes;
14833 outBudgets->budget = m_MemProps.memoryHeaps[heapIndex].size * 8 / 10; // 80% heuristics.
14834 }
14835 }
14836}
14837
14838void VmaAllocator_T::GetAllocationInfo(VmaAllocation hAllocation, VmaAllocationInfo* pAllocationInfo)
14839{

Callers 3

AllocatePageMethod · 0.80
FreeMethod · 0.80
vmaBuildStatsStringFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected