mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-10 10:41:52 +00:00
Foo
This commit is contained in:
parent
ab8550340c
commit
87c8189002
@ -44,6 +44,15 @@ static enum class VERBOSITY
|
||||
} g_Verbosity = VERBOSITY::DEFAULT;
|
||||
|
||||
static std::string g_FilePath;
|
||||
// Most significant 16 bits are major version, least significant 16 bits are minor version.
|
||||
static uint32_t g_FileVersion;
|
||||
|
||||
static bool ValidateFileVersion()
|
||||
{
|
||||
const uint32_t major = g_FileVersion >> 16;
|
||||
const uint32_t minor = g_FileVersion & 0xFFFF;
|
||||
return major == 1 && minor <= 2;
|
||||
}
|
||||
|
||||
struct StrRange
|
||||
{
|
||||
@ -176,6 +185,24 @@ void CsvSplit::Set(const StrRange& line, size_t maxCount)
|
||||
m_Count = rangeIndex;
|
||||
}
|
||||
|
||||
static bool ParseFileVersion(const StrRange& s)
|
||||
{
|
||||
CsvSplit csvSplit;
|
||||
csvSplit.Set(s, 2);
|
||||
uint32_t major, minor;
|
||||
if(csvSplit.GetCount() == 2 &&
|
||||
StrRangeToUint(csvSplit.GetRange(0), major) &&
|
||||
StrRangeToUint(csvSplit.GetRange(1), minor))
|
||||
{
|
||||
g_FileVersion = (major << 16) | minor;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class Statistics
|
||||
|
||||
@ -442,6 +469,7 @@ private:
|
||||
void ExecuteCreateImage(size_t lineNumber, const CsvSplit& csvSplit);
|
||||
void ExecuteDestroyImage(size_t lineNumber, const CsvSplit& csvSplit) { DestroyAllocation(lineNumber, csvSplit); }
|
||||
void ExecuteFreeMemory(size_t lineNumber, const CsvSplit& csvSplit) { DestroyAllocation(lineNumber, csvSplit); }
|
||||
void ExecuteCreateLostAllocation(size_t lineNumber, const CsvSplit& csvSplit);
|
||||
|
||||
void DestroyAllocation(size_t lineNumber, const CsvSplit& csvSplit);
|
||||
};
|
||||
@ -566,6 +594,8 @@ void Player::ExecuteLine(size_t lineNumber, const StrRange& line)
|
||||
ExecuteDestroyImage(lineNumber, csvSplit);
|
||||
else if(StrRangeEq(functionName, "vmaFreeMemory"))
|
||||
ExecuteFreeMemory(lineNumber, csvSplit);
|
||||
else if(StrRangeEq(functionName, "vmaCreateLostAllocation"))
|
||||
ExecuteCreateLostAllocation(lineNumber, csvSplit);
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
@ -1250,6 +1280,64 @@ void Player::ExecuteCreateImage(size_t lineNumber, const CsvSplit& csvSplit)
|
||||
}
|
||||
}
|
||||
|
||||
void Player::ExecuteCreateLostAllocation(size_t lineNumber, const CsvSplit& csvSplit)
|
||||
{
|
||||
if(ValidateFunctionParameterCount(lineNumber, csvSplit, 1, false))
|
||||
{
|
||||
uint64_t origPtr = 0;
|
||||
|
||||
if(StrRangeToPtr(csvSplit.GetRange(FIRST_PARAM_INDEX), origPtr))
|
||||
{
|
||||
// TODO
|
||||
if(origPool != 0)
|
||||
{
|
||||
const auto poolIt = m_Pools.find(origPool);
|
||||
if(poolIt != m_Pools.end())
|
||||
allocCreateInfo.pool = poolIt->second.pool;
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Pool %llX not found.\n", lineNumber, origPool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Allocation allocDesc = {};
|
||||
VkResult res = vmaCreateBuffer(m_Allocator, &bufCreateInfo, &allocCreateInfo, &allocDesc.buffer, &allocDesc.allocation, nullptr);
|
||||
if(res == VK_SUCCESS)
|
||||
{
|
||||
m_Stats.RegisterCreateBuffer(bufCreateInfo.usage);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: vmaCreateBuffer failed (%u).\n", lineNumber, res);
|
||||
}
|
||||
}
|
||||
|
||||
const auto existingIt = m_Allocations.find(origPtr);
|
||||
if(existingIt != m_Allocations.end())
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Allocation %llX already exists.\n", lineNumber, origPtr);
|
||||
}
|
||||
}
|
||||
|
||||
m_Allocations[origPtr] = allocDesc;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IssueWarning())
|
||||
{
|
||||
printf("Line %zu: Invalid parameters for vmaCreateLostAllocation.\n", lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Main functions
|
||||
@ -1285,8 +1373,7 @@ static int ProcessFile(const char* data, size_t numBytes)
|
||||
return RESULT_ERROR_FORMAT;
|
||||
}
|
||||
|
||||
if(!lineSplit.GetNextLine(line) ||
|
||||
!(StrRangeEq(line, "1,0") || StrRangeEq(line, "1,1")))
|
||||
if(!lineSplit.GetNextLine(line) || !ParseFileVersion(line) || !ValidateFileVersion())
|
||||
{
|
||||
printf("ERROR: Incorrect file format version.\n");
|
||||
return RESULT_ERROR_FORMAT;
|
||||
|
@ -2666,7 +2666,7 @@ void EnsureFile()
|
||||
{
|
||||
fopen_s(&g_File, "VMA_Usage_Dump", "wb");
|
||||
fprintf(g_File, "%s\n", "Vulkan Memory Allocator,Calls recording");
|
||||
fprintf(g_File, "%s\n", "1,1");
|
||||
fprintf(g_File, "%s\n", "1,2");
|
||||
QueryPerformanceFrequency(&g_Freq);
|
||||
QueryPerformanceCounter(&g_StartCounter);
|
||||
}
|
||||
@ -10003,12 +10003,23 @@ void vmaCreateLostAllocation(
|
||||
VmaAllocator allocator,
|
||||
VmaAllocation* pAllocation)
|
||||
{
|
||||
Crash();
|
||||
VMA_ASSERT(allocator && pAllocation);
|
||||
|
||||
VMA_DEBUG_GLOBAL_MUTEX_LOCK;
|
||||
|
||||
allocator->CreateLostAllocation(pAllocation);
|
||||
|
||||
{
|
||||
VmaMutexLock lock(g_FileMutex, true);
|
||||
EnsureFile();
|
||||
LARGE_INTEGER counter; QueryPerformanceCounter(&counter);
|
||||
const DWORD threadId = GetCurrentThreadId();
|
||||
const double time = (double)(counter.QuadPart - g_StartCounter.QuadPart) / (double)g_Freq.QuadPart;
|
||||
const uint32_t frameIndex = allocator->GetCurrentFrameIndex();
|
||||
fprintf(g_File, "%u,%.3f,%u,vmaCreateLostAllocation,%p\n", threadId, time, frameIndex,
|
||||
(*pAllocation));
|
||||
fflush(g_File);
|
||||
}
|
||||
}
|
||||
|
||||
VkResult vmaMapMemory(
|
||||
@ -10089,7 +10100,6 @@ VkResult vmaBindBufferMemory(
|
||||
VmaAllocation allocation,
|
||||
VkBuffer buffer)
|
||||
{
|
||||
Crash();
|
||||
VMA_ASSERT(allocator && allocation && buffer);
|
||||
|
||||
VMA_DEBUG_LOG("vmaBindBufferMemory");
|
||||
@ -10104,7 +10114,6 @@ VkResult vmaBindImageMemory(
|
||||
VmaAllocation allocation,
|
||||
VkImage image)
|
||||
{
|
||||
Crash();
|
||||
VMA_ASSERT(allocator && allocation && image);
|
||||
|
||||
VMA_DEBUG_LOG("vmaBindImageMemory");
|
||||
|
Loading…
Reference in New Issue
Block a user