diff --git a/docs/Recording file format.md b/docs/Recording file format.md index 02e414b..d6c2878 100644 --- a/docs/Recording file format.md +++ b/docs/Recording file format.md @@ -158,6 +158,10 @@ No parameters. - allocation : pointer +**vmaMakePoolAllocationsLost** (min format version: 1.2) + +- pool : pointer + ## Data types **bool** diff --git a/src/VmaReplay/VmaReplay.cpp b/src/VmaReplay/VmaReplay.cpp index 114169b..58cd279 100644 --- a/src/VmaReplay/VmaReplay.cpp +++ b/src/VmaReplay/VmaReplay.cpp @@ -65,6 +65,7 @@ enum class VMA_FUNCTION InvalidateAllocation, TouchAllocation, GetAllocationInfo, + MakePoolAllocationsLost, Count }; static const char* VMA_FUNCTION_NAMES[] = { @@ -86,6 +87,7 @@ static const char* VMA_FUNCTION_NAMES[] = { "vmaInvalidateAllocation", "vmaTouchAllocation", "vmaGetAllocationInfo", + "vmaMakePoolAllocationsLost", }; static_assert( _countof(VMA_FUNCTION_NAMES) == (size_t)VMA_FUNCTION::Count, @@ -573,6 +575,7 @@ private: void ExecuteInvalidateAllocation(size_t lineNumber, const CsvSplit& csvSplit); void ExecuteTouchAllocation(size_t lineNumber, const CsvSplit& csvSplit); void ExecuteGetAllocationInfo(size_t lineNumber, const CsvSplit& csvSplit); + void ExecuteMakePoolAllocationsLost(size_t lineNumber, const CsvSplit& csvSplit); void DestroyAllocation(size_t lineNumber, const CsvSplit& csvSplit); }; @@ -704,6 +707,8 @@ void Player::ExecuteLine(size_t lineNumber, const StrRange& line) ExecuteTouchAllocation(lineNumber, csvSplit); else if(StrRangeEq(functionName, "vmaGetAllocationInfo")) ExecuteGetAllocationInfo(lineNumber, csvSplit); + else if(StrRangeEq(functionName, "vmaMakePoolAllocationsLost")) + ExecuteMakePoolAllocationsLost(lineNumber, csvSplit); else { if(IssueWarning()) @@ -1988,6 +1993,42 @@ void Player::ExecuteGetAllocationInfo(size_t lineNumber, const CsvSplit& csvSpli } } +void Player::ExecuteMakePoolAllocationsLost(size_t lineNumber, const CsvSplit& csvSplit) +{ + m_Stats.RegisterFunctionCall(VMA_FUNCTION::MakePoolAllocationsLost); + + if(ValidateFunctionParameterCount(lineNumber, csvSplit, 1, false)) + { + uint64_t origPtr = 0; + + if(StrRangeToPtr(csvSplit.GetRange(FIRST_PARAM_INDEX), origPtr)) + { + if(origPtr != 0) + { + const auto it = m_Pools.find(origPtr); + if(it != m_Pools.end()) + { + vmaMakePoolAllocationsLost(m_Allocator, it->second.pool, nullptr); + } + else + { + if(IssueWarning()) + { + printf("Line %zu: Pool %llX not found.\n", lineNumber, origPtr); + } + } + } + } + else + { + if(IssueWarning()) + { + printf("Line %zu: Invalid parameters for vmaMakePoolAllocationsLost.\n", lineNumber); + } + } + } +} + //////////////////////////////////////////////////////////////////////////////// // Main functions diff --git a/src/vk_mem_alloc.h b/src/vk_mem_alloc.h index 95e6260..479b4b4 100644 --- a/src/vk_mem_alloc.h +++ b/src/vk_mem_alloc.h @@ -4854,6 +4854,8 @@ public: VmaAllocation allocation); void RecordGetAllocationInfo(uint32_t frameIndex, VmaAllocation allocation); + void RecordMakePoolAllocationsLost(uint32_t frameIndex, + VmaPool pool); private: struct CallParams @@ -8507,6 +8509,18 @@ void VmaRecorder::RecordGetAllocationInfo(uint32_t frameIndex, Flush(); } +void VmaRecorder::RecordMakePoolAllocationsLost(uint32_t frameIndex, + VmaPool pool) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaMakePoolAllocationsLost,%p\n", callParams.threadId, callParams.time, frameIndex, + pool); + Flush(); +} + VmaRecorder::UserDataString::UserDataString(VmaAllocationCreateFlags allocFlags, const void* pUserData) { if(pUserData != VMA_NULL) @@ -10401,6 +10415,13 @@ void vmaMakePoolAllocationsLost( VMA_DEBUG_GLOBAL_MUTEX_LOCK +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordMakePoolAllocationsLost(allocator->GetCurrentFrameIndex(), pool); + } +#endif + allocator->MakePoolAllocationsLost(pool, pLostAllocationCount); }