Skip to content

Commit 05973d8

Browse files
Fixes in multithreading in VmaBlockVector::Free
Also improved the documentation of vmaGetPoolStatistics. See #451 - thanks @danginsburg
1 parent 1c35ba9 commit 05973d8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/vk_mem_alloc.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,9 @@ VMA_CALL_PRE void VMA_CALL_POST vmaDestroyPool(
18361836
\param allocator Allocator object.
18371837
\param pool Pool object.
18381838
\param[out] pPoolStats Statistics of specified pool.
1839+
1840+
Note that when using the pool from multiple threads, returned information may immediately
1841+
become outdated.
18391842
*/
18401843
VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolStatistics(
18411844
VmaAllocator VMA_NOT_NULL allocator,
@@ -11605,6 +11608,10 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
1160511608
}
1160611609

1160711610
IncrementallySortBlocks();
11611+
11612+
m_hAllocator->m_Budget.RemoveAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), hAllocation->GetSize());
11613+
hAllocation->Destroy(m_hAllocator);
11614+
m_hAllocator->m_AllocationObjectAllocator.Free(hAllocation);
1160811615
}
1160911616

1161011617
// Destruction of a free block. Deferred until this point, outside of mutex
@@ -11615,10 +11622,6 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
1161511622
pBlockToDelete->Destroy(m_hAllocator);
1161611623
vma_delete(m_hAllocator, pBlockToDelete);
1161711624
}
11618-
11619-
m_hAllocator->m_Budget.RemoveAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), hAllocation->GetSize());
11620-
hAllocation->Destroy(m_hAllocator);
11621-
m_hAllocator->m_AllocationObjectAllocator.Free(hAllocation);
1162211625
}
1162311626

1162411627
VkDeviceSize VmaBlockVector::CalcMaxBlockSize() const

0 commit comments

Comments
 (0)