Added optional usage of VmaAllocatorCreateInfo::pAllocationCallbacks (disabled by default).
diff --git a/src/VulkanSample.cpp b/src/VulkanSample.cpp
index cb8aae7..d3937b7 100644
--- a/src/VulkanSample.cpp
+++ b/src/VulkanSample.cpp
@@ -35,14 +35,15 @@
 

 static const bool VSYNC = true;

 static const uint32_t COMMAND_BUFFER_COUNT = 2;

-

-static bool g_EnableValidationLayer = true;

+static void* const CUSTOM_CPU_ALLOCATION_CALLBACK_USER_DATA = (void*)(intptr_t)43564544;

+static const bool USE_CUSTOM_CPU_ALLOCATION_CALLBACKS = false;

 

 VkPhysicalDevice g_hPhysicalDevice;

 VkDevice g_hDevice;

 VmaAllocator g_hAllocator;

 bool g_MemoryAliasingWarningEnabled = true;

 

+static bool g_EnableValidationLayer = true;

 static bool VK_KHR_get_memory_requirements2_enabled = false;

 static bool VK_KHR_dedicated_allocation_enabled = false;

 

@@ -102,6 +103,28 @@
 static VmaAllocation g_hTextureImageAlloc;

 static VkImageView g_hTextureImageView;

 

+static void* CustomCpuAllocation(

+    void* pUserData, size_t size, size_t alignment,

+    VkSystemAllocationScope allocationScope)

+{

+    assert(pUserData == CUSTOM_CPU_ALLOCATION_CALLBACK_USER_DATA);

+    return _aligned_malloc(size, alignment);

+}

+

+static void* CustomCpuReallocation(

+    void* pUserData, void* pOriginal, size_t size, size_t alignment,

+    VkSystemAllocationScope allocationScope)

+{

+    assert(pUserData == CUSTOM_CPU_ALLOCATION_CALLBACK_USER_DATA);

+    return _aligned_realloc(pOriginal, size, alignment);

+}

+

+static void CustomCpuFree(void* pUserData, void* pMemory)

+{

+    assert(pUserData == CUSTOM_CPU_ALLOCATION_CALLBACK_USER_DATA);

+    _aligned_free(pMemory);

+}

+

 static void BeginSingleTimeCommands()

 {

     VkCommandBufferBeginInfo cmdBufBeginInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };

@@ -1255,10 +1278,22 @@
     VmaAllocatorCreateInfo allocatorInfo = {};

     allocatorInfo.physicalDevice = g_hPhysicalDevice;

     allocatorInfo.device = g_hDevice;

+

     if(VK_KHR_dedicated_allocation_enabled)

     {

         allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;

     }

+

+    VkAllocationCallbacks cpuAllocationCallbacks = {};

+    if(USE_CUSTOM_CPU_ALLOCATION_CALLBACKS)

+    {

+        cpuAllocationCallbacks.pUserData = CUSTOM_CPU_ALLOCATION_CALLBACK_USER_DATA;

+        cpuAllocationCallbacks.pfnAllocation = &CustomCpuAllocation;

+        cpuAllocationCallbacks.pfnReallocation = &CustomCpuReallocation;

+        cpuAllocationCallbacks.pfnFree = &CustomCpuFree;

+        allocatorInfo.pAllocationCallbacks = &cpuAllocationCallbacks;

+    }

+

     ERR_GUARD_VULKAN( vmaCreateAllocator(&allocatorInfo, &g_hAllocator) );

 

     // Retrieve queue (doesn't need to be destroyed)