Added missing mutex when unmapping memory.

Hopefully fixes #267. Code by @medranSolus
This commit is contained in:
Adam Sawicki 2022-06-22 12:48:27 +02:00
parent b51fea7a53
commit 1022be64cf

View File

@ -5907,7 +5907,7 @@ public:
// 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 @@ void VmaDeviceMemoryBlock::Destroy(VmaAllocator allocator)
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 @@ VkResult VmaBlockVector::CommitAllocationRequest(
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)
{