Created project VmaReplay, started coding it.

This commit is contained in:
Adam Sawicki 2018-08-07 13:44:20 +02:00
parent 1d536111cc
commit 6d2e2e0cac
7 changed files with 2519 additions and 1 deletions

View File

@ -21,6 +21,7 @@ architecture "x64"
includedirs { "$(VULKAN_SDK)/include" } includedirs { "$(VULKAN_SDK)/include" }
libdirs { "$(VULKAN_SDK)/lib" } libdirs { "$(VULKAN_SDK)/lib" }
project "VulkanSample" project "VulkanSample"
kind "ConsoleApp" kind "ConsoleApp"
language "C++" language "C++"
@ -57,3 +58,41 @@ buildoptions { "/MDd" }
filter { "configurations:Release", "platforms:Windows-x64" } filter { "configurations:Release", "platforms:Windows-x64" }
buildoptions { "/MD" } buildoptions { "/MD" }
project "VmaReplay"
kind "ConsoleApp"
language "C++"
location "../build"
filename ("VmaReplay_" .. _SUFFIX)
targetdir "../bin"
objdir "../build/Desktop_%{_SUFFIX}/%{cfg.platform}/%{cfg.buildcfg}"
floatingpoint "Fast"
files { "../src/VmaReplay/*.h", "../src/VmaReplay/*.cpp" }
flags { "NoPCH", "FatalWarnings" }
characterset "Default"
filter "configurations:Debug"
defines { "_DEBUG", "DEBUG" }
flags { }
targetsuffix ("_Debug_" .. _SUFFIX)
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On"
flags { "LinkTimeOptimization" }
targetsuffix ("_Release_" .. _SUFFIX)
filter { "platforms:x64" }
defines { "WIN32", "_CONSOLE", "PROFILE", "_WINDOWS", "_WIN32_WINNT=0x0601" }
links { "vulkan-1" }
filter { "platforms:Linux-x64" }
buildoptions { "-std=c++0x" }
links { "vulkan" }
filter { "configurations:Debug", "platforms:x64" }
buildoptions { "/MDd" }
filter { "configurations:Release", "platforms:Windows-x64" }
buildoptions { "/MD" }

154
src/VmaReplay/Common.cpp Normal file
View File

@ -0,0 +1,154 @@
#include "Common.h"
void ReadFile(std::vector<char>& out, const char* fileName)
{
std::ifstream file(fileName, std::ios::ate | std::ios::binary);
assert(file.is_open());
size_t fileSize = (size_t)file.tellg();
if(fileSize > 0)
{
out.resize(fileSize);
file.seekg(0);
file.read(out.data(), fileSize);
}
else
out.clear();
}
void SetConsoleColor(CONSOLE_COLOR color)
{
WORD attr = 0;
switch(color)
{
case CONSOLE_COLOR::INFO:
attr = FOREGROUND_INTENSITY;;
break;
case CONSOLE_COLOR::NORMAL:
attr = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
break;
case CONSOLE_COLOR::WARNING:
attr = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case CONSOLE_COLOR::ERROR_:
attr = FOREGROUND_RED | FOREGROUND_INTENSITY;
break;
default:
assert(0);
}
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(out, attr);
}
void PrintMessage(CONSOLE_COLOR color, const char* msg)
{
if(color != CONSOLE_COLOR::NORMAL)
SetConsoleColor(color);
printf("%s\n", msg);
if (color != CONSOLE_COLOR::NORMAL)
SetConsoleColor(CONSOLE_COLOR::NORMAL);
}
void PrintMessage(CONSOLE_COLOR color, const wchar_t* msg)
{
if(color != CONSOLE_COLOR::NORMAL)
SetConsoleColor(color);
wprintf(L"%s\n", msg);
if (color != CONSOLE_COLOR::NORMAL)
SetConsoleColor(CONSOLE_COLOR::NORMAL);
}
static const size_t CONSOLE_SMALL_BUF_SIZE = 256;
void PrintMessageV(CONSOLE_COLOR color, const char* format, va_list argList)
{
size_t dstLen = (size_t)::_vscprintf(format, argList);
if(dstLen)
{
bool useSmallBuf = dstLen < CONSOLE_SMALL_BUF_SIZE;
char smallBuf[CONSOLE_SMALL_BUF_SIZE];
std::vector<char> bigBuf(useSmallBuf ? 0 : dstLen + 1);
char* bufPtr = useSmallBuf ? smallBuf : bigBuf.data();
::vsprintf_s(bufPtr, dstLen + 1, format, argList);
PrintMessage(color, bufPtr);
}
}
void PrintMessageV(CONSOLE_COLOR color, const wchar_t* format, va_list argList)
{
size_t dstLen = (size_t)::_vcwprintf(format, argList);
if(dstLen)
{
bool useSmallBuf = dstLen < CONSOLE_SMALL_BUF_SIZE;
wchar_t smallBuf[CONSOLE_SMALL_BUF_SIZE];
std::vector<wchar_t> bigBuf(useSmallBuf ? 0 : dstLen + 1);
wchar_t* bufPtr = useSmallBuf ? smallBuf : bigBuf.data();
::vswprintf_s(bufPtr, dstLen + 1, format, argList);
PrintMessage(color, bufPtr);
}
}
void PrintMessageF(CONSOLE_COLOR color, const char* format, ...)
{
va_list argList;
va_start(argList, format);
PrintMessageV(color, format, argList);
va_end(argList);
}
void PrintMessageF(CONSOLE_COLOR color, const wchar_t* format, ...)
{
va_list argList;
va_start(argList, format);
PrintMessageV(color, format, argList);
va_end(argList);
}
void PrintWarningF(const char* format, ...)
{
va_list argList;
va_start(argList, format);
PrintMessageV(CONSOLE_COLOR::WARNING, format, argList);
va_end(argList);
}
void PrintWarningF(const wchar_t* format, ...)
{
va_list argList;
va_start(argList, format);
PrintMessageV(CONSOLE_COLOR::WARNING, format, argList);
va_end(argList);
}
void PrintErrorF(const char* format, ...)
{
va_list argList;
va_start(argList, format);
PrintMessageV(CONSOLE_COLOR::WARNING, format, argList);
va_end(argList);
}
void PrintErrorF(const wchar_t* format, ...)
{
va_list argList;
va_start(argList, format);
PrintMessageV(CONSOLE_COLOR::WARNING, format, argList);
va_end(argList);
}
void SaveFile(const wchar_t* filePath, const void* data, size_t dataSize)
{
FILE* f = nullptr;
_wfopen_s(&f, filePath, L"wb");
if(f)
{
fwrite(data, 1, dataSize, f);
fclose(f);
}
else
assert(0);
}

96
src/VmaReplay/Common.h Normal file
View File

@ -0,0 +1,96 @@
#pragma once
#include "VmaUsage.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <memory>
#include <algorithm>
#include <numeric>
#include <array>
#include <type_traits>
#include <utility>
#include <chrono>
#include <string>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <cstdarg>
typedef std::chrono::high_resolution_clock::time_point time_point;
typedef std::chrono::high_resolution_clock::duration duration;
#define ERR_GUARD_VULKAN(Expr) do { VkResult res__ = (Expr); if (res__ < 0) assert(0); } while(0)
extern VkPhysicalDevice g_hPhysicalDevice;
extern VkDevice g_hDevice;
extern VmaAllocator g_hAllocator;
extern bool g_MemoryAliasingWarningEnabled;
inline float ToFloatSeconds(duration d)
{
return std::chrono::duration_cast<std::chrono::duration<float>>(d).count();
}
template <typename T>
inline T ceil_div(T x, T y)
{
return (x+y-1) / y;
}
template <typename T>
static inline T align_up(T val, T align)
{
return (val + align - 1) / align * align;
}
static const float PI = 3.14159265358979323846264338327950288419716939937510582f;
class RandomNumberGenerator
{
public:
RandomNumberGenerator() : m_Value{GetTickCount()} {}
RandomNumberGenerator(uint32_t seed) : m_Value{seed} { }
void Seed(uint32_t seed) { m_Value = seed; }
uint32_t Generate() { return GenerateFast() ^ (GenerateFast() >> 7); }
private:
uint32_t m_Value;
uint32_t GenerateFast() { return m_Value = (m_Value * 196314165 + 907633515); }
};
void ReadFile(std::vector<char>& out, const char* fileName);
enum class CONSOLE_COLOR
{
INFO,
NORMAL,
WARNING,
ERROR_,
COUNT
};
void SetConsoleColor(CONSOLE_COLOR color);
void PrintMessage(CONSOLE_COLOR color, const char* msg);
void PrintMessage(CONSOLE_COLOR color, const wchar_t* msg);
inline void Print(const char* msg) { PrintMessage(CONSOLE_COLOR::NORMAL, msg); }
inline void Print(const wchar_t* msg) { PrintMessage(CONSOLE_COLOR::NORMAL, msg); }
inline void PrintWarning(const char* msg) { PrintMessage(CONSOLE_COLOR::WARNING, msg); }
inline void PrintWarning(const wchar_t* msg) { PrintMessage(CONSOLE_COLOR::WARNING, msg); }
inline void PrintError(const char* msg) { PrintMessage(CONSOLE_COLOR::ERROR_, msg); }
inline void PrintError(const wchar_t* msg) { PrintMessage(CONSOLE_COLOR::ERROR_, msg); }
void PrintMessageV(CONSOLE_COLOR color, const char* format, va_list argList);
void PrintMessageV(CONSOLE_COLOR color, const wchar_t* format, va_list argList);
void PrintMessageF(CONSOLE_COLOR color, const char* format, ...);
void PrintMessageF(CONSOLE_COLOR color, const wchar_t* format, ...);
void PrintWarningF(const char* format, ...);
void PrintWarningF(const wchar_t* format, ...);
void PrintErrorF(const char* format, ...);
void PrintErrorF(const wchar_t* format, ...);
void SaveFile(const wchar_t* filePath, const void* data, size_t dataSize);

2018
src/VmaReplay/VmaReplay.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
#define VMA_IMPLEMENTATION
#include "VmaUsage.h"

27
src/VmaReplay/VmaUsage.h Normal file
View File

@ -0,0 +1,27 @@
#pragma once
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#define VK_USE_PLATFORM_WIN32_KHR
#include <vulkan/vulkan.h>
//#define VMA_USE_STL_CONTAINERS 1
//#define VMA_HEAVY_ASSERT(expr) assert(expr)
//#define VMA_DEDICATED_ALLOCATION 0
//#define VMA_DEBUG_MARGIN 16
//#define VMA_DEBUG_DETECT_CORRUPTION 1
//#define VMA_DEBUG_INITIALIZE_ALLOCATIONS 1
#pragma warning(push, 4)
#pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable: 4100) // unreferenced formal parameter
#pragma warning(disable: 4189) // local variable is initialized but not referenced
#include "../vk_mem_alloc.h"
#pragma warning(pop)

View File

@ -2649,6 +2649,29 @@ static const uint8_t VMA_ALLOCATION_FILL_PATTERN_DESTROYED = 0xEF;
END OF CONFIGURATION END OF CONFIGURATION
*/ */
// TEMP ADDED
void Crash()
{
int* i = 0; *i = 0;
}
FILE* g_File;
LARGE_INTEGER g_Freq, g_StartCounter;
VMA_MUTEX g_FileMutex;
void EnsureFile()
{
if(!g_File)
{
fopen_s(&g_File, "VMA_Usage_Dump", "wb");
fprintf(g_File, "%s\n", "Vulkan Memory Allocator,Calls recording");
fprintf(g_File, "%s\n", "1,0");
QueryPerformanceFrequency(&g_Freq);
QueryPerformanceCounter(&g_StartCounter);
}
}
static VkAllocationCallbacks VmaEmptyAllocationCallbacks = { static VkAllocationCallbacks VmaEmptyAllocationCallbacks = {
VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL }; VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL };
@ -4785,6 +4808,7 @@ public:
void GetPoolStats(VmaPool pool, VmaPoolStats* pPoolStats); void GetPoolStats(VmaPool pool, VmaPoolStats* pPoolStats);
void SetCurrentFrameIndex(uint32_t frameIndex); void SetCurrentFrameIndex(uint32_t frameIndex);
uint32_t GetCurrentFrameIndex() const { return m_CurrentFrameIndex.load(); }
void MakePoolAllocationsLost( void MakePoolAllocationsLost(
VmaPool hPool, VmaPool hPool,
@ -9338,6 +9362,18 @@ VkResult vmaCreateAllocator(
VMA_ASSERT(pCreateInfo && pAllocator); VMA_ASSERT(pCreateInfo && pAllocator);
VMA_DEBUG_LOG("vmaCreateAllocator"); VMA_DEBUG_LOG("vmaCreateAllocator");
*pAllocator = vma_new(pCreateInfo->pAllocationCallbacks, VmaAllocator_T)(pCreateInfo); *pAllocator = vma_new(pCreateInfo->pAllocationCallbacks, VmaAllocator_T)(pCreateInfo);
{
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 = (*pAllocator)->GetCurrentFrameIndex();
fprintf(g_File, "%u,%.3f,%u,vmaCreateAllocator\n", threadId, time, frameIndex);
fflush(g_File);
}
return VK_SUCCESS; return VK_SUCCESS;
} }
@ -9346,6 +9382,17 @@ void vmaDestroyAllocator(
{ {
if(allocator != VK_NULL_HANDLE) if(allocator != VK_NULL_HANDLE)
{ {
{
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,vmaDestroyAllocator\n", threadId, time, frameIndex);
fflush(g_File);
}
VMA_DEBUG_LOG("vmaDestroyAllocator"); VMA_DEBUG_LOG("vmaDestroyAllocator");
VkAllocationCallbacks allocationCallbacks = allocator->m_AllocationCallbacks; VkAllocationCallbacks allocationCallbacks = allocator->m_AllocationCallbacks;
vma_delete(&allocationCallbacks, allocator); vma_delete(&allocationCallbacks, allocator);
@ -9688,7 +9735,27 @@ VkResult vmaCreatePool(
VMA_DEBUG_GLOBAL_MUTEX_LOCK VMA_DEBUG_GLOBAL_MUTEX_LOCK
return allocator->CreatePool(pCreateInfo, pPool); VkResult res = allocator->CreatePool(pCreateInfo, pPool);
{
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,vmaCreatePool,%u,%u,%llu,%llu,%llu,%u,%p\n", threadId, time, frameIndex,
pCreateInfo->memoryTypeIndex,
pCreateInfo->flags,
pCreateInfo->blockSize,
pCreateInfo->minBlockCount,
pCreateInfo->maxBlockCount,
pCreateInfo->frameInUseCount,
(*pPool));
fflush(g_File);
}
return res;
} }
void vmaDestroyPool( void vmaDestroyPool(
@ -9702,6 +9769,18 @@ void vmaDestroyPool(
return; return;
} }
{
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,vmaDestroyPool,%p\n", threadId, time, frameIndex,
pool);
fflush(g_File);
}
VMA_DEBUG_LOG("vmaDestroyPool"); VMA_DEBUG_LOG("vmaDestroyPool");
VMA_DEBUG_GLOBAL_MUTEX_LOCK VMA_DEBUG_GLOBAL_MUTEX_LOCK
@ -9751,6 +9830,7 @@ VkResult vmaAllocateMemory(
VmaAllocation* pAllocation, VmaAllocation* pAllocation,
VmaAllocationInfo* pAllocationInfo) VmaAllocationInfo* pAllocationInfo)
{ {
Crash();
VMA_ASSERT(allocator && pVkMemoryRequirements && pCreateInfo && pAllocation); VMA_ASSERT(allocator && pVkMemoryRequirements && pCreateInfo && pAllocation);
VMA_DEBUG_LOG("vmaAllocateMemory"); VMA_DEBUG_LOG("vmaAllocateMemory");
@ -9782,6 +9862,7 @@ VkResult vmaAllocateMemoryForBuffer(
VmaAllocation* pAllocation, VmaAllocation* pAllocation,
VmaAllocationInfo* pAllocationInfo) VmaAllocationInfo* pAllocationInfo)
{ {
Crash();
VMA_ASSERT(allocator && buffer != VK_NULL_HANDLE && pCreateInfo && pAllocation); VMA_ASSERT(allocator && buffer != VK_NULL_HANDLE && pCreateInfo && pAllocation);
VMA_DEBUG_LOG("vmaAllocateMemoryForBuffer"); VMA_DEBUG_LOG("vmaAllocateMemoryForBuffer");
@ -9820,6 +9901,7 @@ VkResult vmaAllocateMemoryForImage(
VmaAllocation* pAllocation, VmaAllocation* pAllocation,
VmaAllocationInfo* pAllocationInfo) VmaAllocationInfo* pAllocationInfo)
{ {
Crash();
VMA_ASSERT(allocator && image != VK_NULL_HANDLE && pCreateInfo && pAllocation); VMA_ASSERT(allocator && image != VK_NULL_HANDLE && pCreateInfo && pAllocation);
VMA_DEBUG_LOG("vmaAllocateMemoryForImage"); VMA_DEBUG_LOG("vmaAllocateMemoryForImage");
@ -9845,6 +9927,7 @@ void vmaFreeMemory(
VmaAllocator allocator, VmaAllocator allocator,
VmaAllocation allocation) VmaAllocation allocation)
{ {
Crash();
VMA_ASSERT(allocator); VMA_ASSERT(allocator);
VMA_DEBUG_LOG("vmaFreeMemory"); VMA_DEBUG_LOG("vmaFreeMemory");
VMA_DEBUG_GLOBAL_MUTEX_LOCK VMA_DEBUG_GLOBAL_MUTEX_LOCK
@ -9886,6 +9969,19 @@ void vmaSetAllocationUserData(
VMA_DEBUG_GLOBAL_MUTEX_LOCK VMA_DEBUG_GLOBAL_MUTEX_LOCK
{
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,vmaSetAllocationUserData,%p,%s\n", threadId, time, frameIndex,
allocation,
(const char*)pUserData);
fflush(g_File);
}
allocation->SetUserData(allocator, pUserData); allocation->SetUserData(allocator, pUserData);
} }
@ -9893,6 +9989,7 @@ void vmaCreateLostAllocation(
VmaAllocator allocator, VmaAllocator allocator,
VmaAllocation* pAllocation) VmaAllocation* pAllocation)
{ {
Crash();
VMA_ASSERT(allocator && pAllocation); VMA_ASSERT(allocator && pAllocation);
VMA_DEBUG_GLOBAL_MUTEX_LOCK; VMA_DEBUG_GLOBAL_MUTEX_LOCK;
@ -9978,6 +10075,7 @@ VkResult vmaBindBufferMemory(
VmaAllocation allocation, VmaAllocation allocation,
VkBuffer buffer) VkBuffer buffer)
{ {
Crash();
VMA_ASSERT(allocator && allocation && buffer); VMA_ASSERT(allocator && allocation && buffer);
VMA_DEBUG_LOG("vmaBindBufferMemory"); VMA_DEBUG_LOG("vmaBindBufferMemory");
@ -9992,6 +10090,7 @@ VkResult vmaBindImageMemory(
VmaAllocation allocation, VmaAllocation allocation,
VkImage image) VkImage image)
{ {
Crash();
VMA_ASSERT(allocator && allocation && image); VMA_ASSERT(allocator && allocation && image);
VMA_DEBUG_LOG("vmaBindImageMemory"); VMA_DEBUG_LOG("vmaBindImageMemory");
@ -10075,6 +10174,30 @@ VkResult vmaCreateBuffer(
{ {
allocator->GetAllocationInfo(*pAllocation, pAllocationInfo); allocator->GetAllocationInfo(*pAllocation, pAllocationInfo);
} }
{
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,vmaCreateBuffer,%u,%llu,%u,%u,%u,%u,%u,%u,%u,%p,%p,%s\n", threadId, time, frameIndex,
pBufferCreateInfo->flags,
pBufferCreateInfo->size,
pBufferCreateInfo->usage,
pBufferCreateInfo->sharingMode,
pAllocationCreateInfo->flags,
pAllocationCreateInfo->usage,
pAllocationCreateInfo->requiredFlags,
pAllocationCreateInfo->preferredFlags,
pAllocationCreateInfo->memoryTypeBits,
pAllocationCreateInfo->pool,
(*pAllocation),
pAllocationCreateInfo->pUserData ? (const char*)pAllocationCreateInfo->pUserData : "");
fflush(g_File);
}
return VK_SUCCESS; return VK_SUCCESS;
} }
allocator->FreeMemory(*pAllocation); allocator->FreeMemory(*pAllocation);
@ -10096,6 +10219,19 @@ void vmaDestroyBuffer(
VmaAllocation allocation) VmaAllocation allocation)
{ {
VMA_ASSERT(allocator); VMA_ASSERT(allocator);
{
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,vmaDestroyBuffer,%p\n", threadId, time, frameIndex,
allocation);
fflush(g_File);
}
VMA_DEBUG_LOG("vmaDestroyBuffer"); VMA_DEBUG_LOG("vmaDestroyBuffer");
VMA_DEBUG_GLOBAL_MUTEX_LOCK VMA_DEBUG_GLOBAL_MUTEX_LOCK
if(buffer != VK_NULL_HANDLE) if(buffer != VK_NULL_HANDLE)
@ -10153,6 +10289,39 @@ VkResult vmaCreateImage(
{ {
allocator->GetAllocationInfo(*pAllocation, pAllocationInfo); allocator->GetAllocationInfo(*pAllocation, pAllocationInfo);
} }
{
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,vmaCreateImage,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%p,%p,%s\n", threadId, time, frameIndex,
pImageCreateInfo->flags,
pImageCreateInfo->imageType,
pImageCreateInfo->format,
pImageCreateInfo->extent.width,
pImageCreateInfo->extent.height,
pImageCreateInfo->extent.depth,
pImageCreateInfo->mipLevels,
pImageCreateInfo->arrayLayers,
pImageCreateInfo->samples,
pImageCreateInfo->tiling,
pImageCreateInfo->usage,
pImageCreateInfo->sharingMode,
pImageCreateInfo->initialLayout,
pAllocationCreateInfo->flags,
pAllocationCreateInfo->usage,
pAllocationCreateInfo->requiredFlags,
pAllocationCreateInfo->preferredFlags,
pAllocationCreateInfo->memoryTypeBits,
pAllocationCreateInfo->pool,
(*pAllocation),
pAllocationCreateInfo->pUserData ? (const char*)pAllocationCreateInfo->pUserData : "");
fflush(g_File);
}
return VK_SUCCESS; return VK_SUCCESS;
} }
allocator->FreeMemory(*pAllocation); allocator->FreeMemory(*pAllocation);
@ -10174,6 +10343,19 @@ void vmaDestroyImage(
VmaAllocation allocation) VmaAllocation allocation)
{ {
VMA_ASSERT(allocator); VMA_ASSERT(allocator);
{
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,vmaDestroyImage,%p\n", threadId, time, frameIndex,
allocation);
fflush(g_File);
}
VMA_DEBUG_LOG("vmaDestroyImage"); VMA_DEBUG_LOG("vmaDestroyImage");
VMA_DEBUG_GLOBAL_MUTEX_LOCK VMA_DEBUG_GLOBAL_MUTEX_LOCK
if(image != VK_NULL_HANDLE) if(image != VK_NULL_HANDLE)