From ea759b65d440eaa15938b5f660de810fe06e67fb Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Fri, 4 Mar 2022 10:34:26 +0100 Subject: [PATCH] Added missing mutexes for DefragmentPassEnd(). Code by @medranSolus --- include/vk_mem_alloc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index 415bcc5..791c91c 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -13252,6 +13252,8 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo if (state.operation != StateExtensive::Operation::Cleanup) { VmaBlockVector* vector = m_pBlockVectors[block.data]; + VmaMutexLockWrite lock(vector->GetMutex(), vector->GetAllocator()->m_UseMutex); + for (size_t i = 0, count = vector->GetBlockCount() - m_ImmovableBlockCount; i < count; ++i) { if (vector->GetBlock(i) == block.block) @@ -13281,6 +13283,8 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo for (const FragmentedBlock& block : immovableBlocks) { VmaBlockVector* vector = m_pBlockVectors[block.data]; + VmaMutexLockWrite lock(vector->GetMutex(), vector->GetAllocator()->m_UseMutex); + for (size_t i = m_ImmovableBlockCount; i < vector->GetBlockCount(); ++i) { if (vector->GetBlock(i) == block.block)