mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-22 15:04:34 +00:00
Added recording and replaying of calls to functions: vmaTouchAllocation, vmaGetAllocationInfo. VmaReplay: fixed handling of null allocation.
This commit is contained in:
parent
b3ea2c62f1
commit
80cb2365c5
@ -154,6 +154,10 @@ No parameters.
|
||||
- offset : uint64
|
||||
- size : uint64
|
||||
|
||||
**vmaTouchAllocation, vmaGetAllocationInfo** (min format version 1.2)
|
||||
|
||||
- allocation : pointer
|
||||
|
||||
## Data types
|
||||
|
||||
**bool**
|
||||
|
@ -517,6 +517,8 @@ private:
|
||||
void ExecuteUnmapMemory(size_t lineNumber, const CsvSplit& csvSplit);
|
||||
void ExecuteFlushAllocation(size_t lineNumber, const CsvSplit& csvSplit);
|
||||
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 DestroyAllocation(size_t lineNumber, const CsvSplit& csvSplit);
|
||||
};
|
||||
@ -644,6 +646,10 @@ void Player::ExecuteLine(size_t lineNumber, const StrRange& line)
|
||||
ExecuteFlushAllocation(lineNumber, csvSplit);
|
||||
else if(StrRangeEq(functionName, "vmaInvalidateAllocation"))
|
||||
ExecuteInvalidateAllocation(lineNumber, csvSplit);
|
||||
else if(StrRangeEq(functionName, "vmaTouchAllocation"))
|
||||
ExecuteTouchAllocation(lineNumber, csvSplit);
|
||||
else if(StrRangeEq(functionName, "vmaGetAllocationInfo"))
|
||||
ExecuteGetAllocationInfo(lineNumber, csvSplit);
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
@ -1619,6 +1625,8 @@ void Player::ExecuteMapMemory(size_t lineNumber, const CsvSplit& csvSplit)
|
||||
{
|
||||
const auto it = m_Allocations.find(origPtr);
|
||||
if(it != m_Allocations.end())
|
||||
{
|
||||
if(it->second.allocation)
|
||||
{
|
||||
void* pData;
|
||||
VkResult res = vmaMapMemory(m_Allocator, it->second.allocation, &pData);
|
||||
@ -1628,6 +1636,14 @@ void Player::ExecuteMapMemory(size_t lineNumber, const CsvSplit& csvSplit)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Cannot call vmaMapMemory - allocation is null.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
@ -1658,10 +1674,20 @@ void Player::ExecuteUnmapMemory(size_t lineNumber, const CsvSplit& csvSplit)
|
||||
{
|
||||
const auto it = m_Allocations.find(origPtr);
|
||||
if(it != m_Allocations.end())
|
||||
{
|
||||
if(it->second.allocation)
|
||||
{
|
||||
vmaUnmapMemory(m_Allocator, it->second.allocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Cannot call vmaUnmapMemory - allocation is null.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
@ -1696,10 +1722,20 @@ void Player::ExecuteFlushAllocation(size_t lineNumber, const CsvSplit& csvSplit)
|
||||
{
|
||||
const auto it = m_Allocations.find(origPtr);
|
||||
if(it != m_Allocations.end())
|
||||
{
|
||||
if(it->second.allocation)
|
||||
{
|
||||
vmaFlushAllocation(m_Allocator, it->second.allocation, offset, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Cannot call vmaFlushAllocation - allocation is null.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
@ -1734,10 +1770,20 @@ void Player::ExecuteInvalidateAllocation(size_t lineNumber, const CsvSplit& csvS
|
||||
{
|
||||
const auto it = m_Allocations.find(origPtr);
|
||||
if(it != m_Allocations.end())
|
||||
{
|
||||
if(it->second.allocation)
|
||||
{
|
||||
vmaInvalidateAllocation(m_Allocator, it->second.allocation, offset, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Cannot call vmaInvalidateAllocation - allocation is null.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
@ -1756,6 +1802,87 @@ void Player::ExecuteInvalidateAllocation(size_t lineNumber, const CsvSplit& csvS
|
||||
}
|
||||
}
|
||||
|
||||
void Player::ExecuteTouchAllocation(size_t lineNumber, const CsvSplit& csvSplit)
|
||||
{
|
||||
if(ValidateFunctionParameterCount(lineNumber, csvSplit, 1, false))
|
||||
{
|
||||
uint64_t origPtr = 0;
|
||||
if(StrRangeToPtr(csvSplit.GetRange(FIRST_PARAM_INDEX), origPtr))
|
||||
{
|
||||
const auto it = m_Allocations.find(origPtr);
|
||||
if(it != m_Allocations.end())
|
||||
{
|
||||
if(it->second.allocation)
|
||||
{
|
||||
vmaTouchAllocation(m_Allocator, it->second.allocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Cannot call vmaTouchAllocation - allocation is null.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Allocation %llX not found.\n", lineNumber, origPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Invalid parameters for vmaTouchAllocation.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::ExecuteGetAllocationInfo(size_t lineNumber, const CsvSplit& csvSplit)
|
||||
{
|
||||
if(ValidateFunctionParameterCount(lineNumber, csvSplit, 1, false))
|
||||
{
|
||||
uint64_t origPtr = 0;
|
||||
if(StrRangeToPtr(csvSplit.GetRange(FIRST_PARAM_INDEX), origPtr))
|
||||
{
|
||||
const auto it = m_Allocations.find(origPtr);
|
||||
if(it != m_Allocations.end())
|
||||
{
|
||||
if(it->second.allocation)
|
||||
{
|
||||
VmaAllocationInfo allocInfo;
|
||||
vmaGetAllocationInfo(m_Allocator, it->second.allocation, &allocInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Cannot call vmaGetAllocationInfo - allocation is null.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Allocation %llX not found.\n", lineNumber, origPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Invalid parameters for vmaGetAllocationInfo.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Main functions
|
||||
|
||||
|
@ -4803,6 +4803,10 @@ public:
|
||||
VmaAllocation allocation);
|
||||
void RecordDestroyImage(uint32_t frameIndex,
|
||||
VmaAllocation allocation);
|
||||
void RecordTouchAllocation(uint32_t frameIndex,
|
||||
VmaAllocation allocation);
|
||||
void RecordGetAllocationInfo(uint32_t frameIndex,
|
||||
VmaAllocation allocation);
|
||||
|
||||
private:
|
||||
struct CallParams
|
||||
@ -8432,6 +8436,30 @@ void VmaRecorder::RecordDestroyImage(uint32_t frameIndex,
|
||||
Flush();
|
||||
}
|
||||
|
||||
void VmaRecorder::RecordTouchAllocation(uint32_t frameIndex,
|
||||
VmaAllocation allocation)
|
||||
{
|
||||
CallParams callParams;
|
||||
GetBasicParams(callParams);
|
||||
|
||||
VmaMutexLock lock(m_FileMutex, m_UseMutex);
|
||||
fprintf(m_File, "%u,%.3f,%u,vmaTouchAllocation,%p\n", callParams.threadId, callParams.time, frameIndex,
|
||||
allocation);
|
||||
Flush();
|
||||
}
|
||||
|
||||
void VmaRecorder::RecordGetAllocationInfo(uint32_t frameIndex,
|
||||
VmaAllocation allocation)
|
||||
{
|
||||
CallParams callParams;
|
||||
GetBasicParams(callParams);
|
||||
|
||||
VmaMutexLock lock(m_FileMutex, m_UseMutex);
|
||||
fprintf(m_File, "%u,%.3f,%u,vmaGetAllocationInfo,%p\n", callParams.threadId, callParams.time, frameIndex,
|
||||
allocation);
|
||||
Flush();
|
||||
}
|
||||
|
||||
VmaRecorder::UserDataString::UserDataString(VmaAllocationCreateFlags allocFlags, const void* pUserData)
|
||||
{
|
||||
if(pUserData != VMA_NULL)
|
||||
@ -10519,6 +10547,15 @@ void vmaGetAllocationInfo(
|
||||
|
||||
VMA_DEBUG_GLOBAL_MUTEX_LOCK
|
||||
|
||||
#if VMA_RECORDING_ENABLED
|
||||
if(allocator->GetRecorder() != VMA_NULL)
|
||||
{
|
||||
allocator->GetRecorder()->RecordGetAllocationInfo(
|
||||
allocator->GetCurrentFrameIndex(),
|
||||
allocation);
|
||||
}
|
||||
#endif
|
||||
|
||||
allocator->GetAllocationInfo(allocation, pAllocationInfo);
|
||||
}
|
||||
|
||||
@ -10530,6 +10567,15 @@ VkBool32 vmaTouchAllocation(
|
||||
|
||||
VMA_DEBUG_GLOBAL_MUTEX_LOCK
|
||||
|
||||
#if VMA_RECORDING_ENABLED
|
||||
if(allocator->GetRecorder() != VMA_NULL)
|
||||
{
|
||||
allocator->GetRecorder()->RecordTouchAllocation(
|
||||
allocator->GetCurrentFrameIndex(),
|
||||
allocation);
|
||||
}
|
||||
#endif
|
||||
|
||||
return allocator->TouchAllocation(allocation);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user