Skip to content

Commit

Permalink
Fixes in multithreading in VmaBlockVector::Free
Browse files Browse the repository at this point in the history
Also improved the documentation of vmaGetPoolStatistics.
See #451 - thanks @danginsburg
  • Loading branch information
adam-sawicki-a committed Oct 28, 2024
1 parent 1c35ba9 commit 05973d8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/vk_mem_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,9 @@ VMA_CALL_PRE void VMA_CALL_POST vmaDestroyPool(
\param allocator Allocator object.
\param pool Pool object.
\param[out] pPoolStats Statistics of specified pool.

Note that when using the pool from multiple threads, returned information may immediately
become outdated.
*/
VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolStatistics(
VmaAllocator VMA_NOT_NULL allocator,
Expand Down Expand Up @@ -11605,6 +11608,10 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
}

IncrementallySortBlocks();

m_hAllocator->m_Budget.RemoveAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), hAllocation->GetSize());
hAllocation->Destroy(m_hAllocator);
m_hAllocator->m_AllocationObjectAllocator.Free(hAllocation);
}

// Destruction of a free block. Deferred until this point, outside of mutex
Expand All @@ -11615,10 +11622,6 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
pBlockToDelete->Destroy(m_hAllocator);
vma_delete(m_hAllocator, pBlockToDelete);
}

m_hAllocator->m_Budget.RemoveAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), hAllocation->GetSize());
hAllocation->Destroy(m_hAllocator);
m_hAllocator->m_AllocationObjectAllocator.Free(hAllocation);
}

VkDeviceSize VmaBlockVector::CalcMaxBlockSize() const
Expand Down

0 comments on commit 05973d8

Please sign in to comment.