Improved handling of destruction calls with null handle, in vk_mem_alloc as well as VmaReplay.

This commit is contained in:
Adam Sawicki 2018-08-13 12:22:37 +02:00
parent 5b48b5efcf
commit db1f73fee4
2 changed files with 41 additions and 22 deletions

View File

@ -764,6 +764,8 @@ void Player::ExecuteDestroyPool(size_t lineNumber, const CsvSplit& csvSplit)
uint64_t origPtr = 0; uint64_t origPtr = 0;
if(StrRangeToPtr(csvSplit.GetRange(FIRST_PARAM_INDEX), origPtr)) if(StrRangeToPtr(csvSplit.GetRange(FIRST_PARAM_INDEX), origPtr))
{
if(origPtr != 0)
{ {
const auto it = m_Pools.find(origPtr); const auto it = m_Pools.find(origPtr);
if(it != m_Pools.end()) if(it != m_Pools.end())
@ -779,6 +781,7 @@ void Player::ExecuteDestroyPool(size_t lineNumber, const CsvSplit& csvSplit)
} }
} }
} }
}
else else
{ {
if(IssueWarning()) if(IssueWarning())
@ -866,6 +869,8 @@ void Player::DestroyAllocation(size_t lineNumber, const CsvSplit& csvSplit)
uint64_t origAllocPtr = 0; uint64_t origAllocPtr = 0;
if(StrRangeToPtr(csvSplit.GetRange(FIRST_PARAM_INDEX), origAllocPtr)) if(StrRangeToPtr(csvSplit.GetRange(FIRST_PARAM_INDEX), origAllocPtr))
{
if(origAllocPtr != 0)
{ {
const auto it = m_Allocations.find(origAllocPtr); const auto it = m_Allocations.find(origAllocPtr);
if(it != m_Allocations.end()) if(it != m_Allocations.end())
@ -881,6 +886,7 @@ void Player::DestroyAllocation(size_t lineNumber, const CsvSplit& csvSplit)
} }
} }
} }
}
else else
{ {
if(IssueWarning()) if(IssueWarning())

View File

@ -9929,6 +9929,11 @@ void vmaFreeMemory(
{ {
VMA_ASSERT(allocator); VMA_ASSERT(allocator);
if(allocation == VK_NULL_HANDLE)
{
return;
}
{ {
VmaMutexLock lock(g_FileMutex, true); VmaMutexLock lock(g_FileMutex, true);
EnsureFile(); EnsureFile();
@ -9943,11 +9948,8 @@ void vmaFreeMemory(
VMA_DEBUG_LOG("vmaFreeMemory"); VMA_DEBUG_LOG("vmaFreeMemory");
VMA_DEBUG_GLOBAL_MUTEX_LOCK VMA_DEBUG_GLOBAL_MUTEX_LOCK
if(allocation != VK_NULL_HANDLE)
{
allocator->FreeMemory(allocation); allocator->FreeMemory(allocation);
} }
}
void vmaGetAllocationInfo( void vmaGetAllocationInfo(
VmaAllocator allocator, VmaAllocator allocator,
@ -10232,6 +10234,11 @@ void vmaDestroyBuffer(
{ {
VMA_ASSERT(allocator); VMA_ASSERT(allocator);
if(buffer == VK_NULL_HANDLE && allocation == VK_NULL_HANDLE)
{
return;
}
{ {
VmaMutexLock lock(g_FileMutex, true); VmaMutexLock lock(g_FileMutex, true);
EnsureFile(); EnsureFile();
@ -10356,6 +10363,12 @@ void vmaDestroyImage(
{ {
VMA_ASSERT(allocator); VMA_ASSERT(allocator);
if(image == VK_NULL_HANDLE && allocation == VK_NULL_HANDLE)
{
return;
}
{ {
VmaMutexLock lock(g_FileMutex, true); VmaMutexLock lock(g_FileMutex, true);
EnsureFile(); EnsureFile();