Added missing mutex when unmapping memory.
Hopefully fixes #267. Code by @medranSolus
diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h
index cd88e65..bdb4ff5 100644
--- a/include/vk_mem_alloc.h
+++ b/include/vk_mem_alloc.h
@@ -5907,7 +5907,7 @@
// Call when allocation/free was made from m_pMetadata.
// Used for m_MappingHysteresis.
- void PostAlloc() { m_MappingHysteresis.PostAlloc(); }
+ void PostAlloc(VmaAllocator hAllocator);
void PostFree(VmaAllocator hAllocator);
// Validates all data structures inside this object. If not valid, returns false.
@@ -11765,8 +11765,15 @@
m_pMetadata = VMA_NULL;
}
+void VmaDeviceMemoryBlock::PostAlloc(VmaAllocator hAllocator)
+{
+ VmaMutexLock lock(m_MapAndBindMutex, hAllocator->m_UseMutex);
+ m_MappingHysteresis.PostAlloc();
+}
+
void VmaDeviceMemoryBlock::PostFree(VmaAllocator hAllocator)
{
+ VmaMutexLock lock(m_MapAndBindMutex, hAllocator->m_UseMutex);
if(m_MappingHysteresis.PostFree())
{
VMA_ASSERT(m_MappingHysteresis.GetExtraMapping() == 0);
@@ -12775,7 +12782,7 @@
const bool isMappingAllowed = (allocFlags &
(VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT)) != 0;
- pBlock->PostAlloc();
+ pBlock->PostAlloc(m_hAllocator);
// Allocate from pCurrBlock.
if (mapped)
{