Record and replay: Added support for function vmaMakePoolAllocationsLost.

This commit is contained in:
Adam Sawicki 2018-08-21 12:04:19 +02:00
parent 5de71e1d28
commit 2556b377f7
3 changed files with 66 additions and 0 deletions

View File

@ -158,6 +158,10 @@ No parameters.
- allocation : pointer - allocation : pointer
**vmaMakePoolAllocationsLost** (min format version: 1.2)
- pool : pointer
## Data types ## Data types
**bool** **bool**

View File

@ -65,6 +65,7 @@ enum class VMA_FUNCTION
InvalidateAllocation, InvalidateAllocation,
TouchAllocation, TouchAllocation,
GetAllocationInfo, GetAllocationInfo,
MakePoolAllocationsLost,
Count Count
}; };
static const char* VMA_FUNCTION_NAMES[] = { static const char* VMA_FUNCTION_NAMES[] = {
@ -86,6 +87,7 @@ static const char* VMA_FUNCTION_NAMES[] = {
"vmaInvalidateAllocation", "vmaInvalidateAllocation",
"vmaTouchAllocation", "vmaTouchAllocation",
"vmaGetAllocationInfo", "vmaGetAllocationInfo",
"vmaMakePoolAllocationsLost",
}; };
static_assert( static_assert(
_countof(VMA_FUNCTION_NAMES) == (size_t)VMA_FUNCTION::Count, _countof(VMA_FUNCTION_NAMES) == (size_t)VMA_FUNCTION::Count,
@ -573,6 +575,7 @@ private:
void ExecuteInvalidateAllocation(size_t lineNumber, const CsvSplit& csvSplit); void ExecuteInvalidateAllocation(size_t lineNumber, const CsvSplit& csvSplit);
void ExecuteTouchAllocation(size_t lineNumber, const CsvSplit& csvSplit); void ExecuteTouchAllocation(size_t lineNumber, const CsvSplit& csvSplit);
void ExecuteGetAllocationInfo(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); void DestroyAllocation(size_t lineNumber, const CsvSplit& csvSplit);
}; };
@ -704,6 +707,8 @@ void Player::ExecuteLine(size_t lineNumber, const StrRange& line)
ExecuteTouchAllocation(lineNumber, csvSplit); ExecuteTouchAllocation(lineNumber, csvSplit);
else if(StrRangeEq(functionName, "vmaGetAllocationInfo")) else if(StrRangeEq(functionName, "vmaGetAllocationInfo"))
ExecuteGetAllocationInfo(lineNumber, csvSplit); ExecuteGetAllocationInfo(lineNumber, csvSplit);
else if(StrRangeEq(functionName, "vmaMakePoolAllocationsLost"))
ExecuteMakePoolAllocationsLost(lineNumber, csvSplit);
else else
{ {
if(IssueWarning()) 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 // Main functions

View File

@ -4854,6 +4854,8 @@ public:
VmaAllocation allocation); VmaAllocation allocation);
void RecordGetAllocationInfo(uint32_t frameIndex, void RecordGetAllocationInfo(uint32_t frameIndex,
VmaAllocation allocation); VmaAllocation allocation);
void RecordMakePoolAllocationsLost(uint32_t frameIndex,
VmaPool pool);
private: private:
struct CallParams struct CallParams
@ -8507,6 +8509,18 @@ void VmaRecorder::RecordGetAllocationInfo(uint32_t frameIndex,
Flush(); 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) VmaRecorder::UserDataString::UserDataString(VmaAllocationCreateFlags allocFlags, const void* pUserData)
{ {
if(pUserData != VMA_NULL) if(pUserData != VMA_NULL)
@ -10401,6 +10415,13 @@ void vmaMakePoolAllocationsLost(
VMA_DEBUG_GLOBAL_MUTEX_LOCK 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); allocator->MakePoolAllocationsLost(pool, pLostAllocationCount);
} }