Memory priorities for custom pools are implemented now!
diff --git a/src/VulkanSample.cpp b/src/VulkanSample.cpp
index 2612dce..593cc76 100644
--- a/src/VulkanSample.cpp
+++ b/src/VulkanSample.cpp
@@ -1314,6 +1314,10 @@
     {

         allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;

     }

+    if(VK_KHR_memory_priority_enabled)

+    {

+        allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT;

+    }

 

     VkAllocationCallbacks cpuAllocationCallbacks = {};

     if(USE_CUSTOM_CPU_ALLOCATION_CALLBACKS)

diff --git a/src/vk_mem_alloc.h b/src/vk_mem_alloc.h
index e798531..5656b1b 100644
--- a/src/vk_mem_alloc.h
+++ b/src/vk_mem_alloc.h
@@ -3775,6 +3775,27 @@
     return true;

 }

 

+static inline float VmaMemoryPriorityToVulkanPriority(VmaMemoryPriority vmaPriority)

+{

+    switch(vmaPriority)

+    {

+    case VMA_MEMORY_PRIORITY_LOWEST:

+        return 0.f;

+    case VMA_MEMORY_PRIORITY_LOW:

+        return 0.25f;

+    case VMA_MEMORY_PRIORITY_UNKNOWN:

+    case VMA_MEMORY_PRIORITY_NORMAL:

+        return 0.5f;

+    case VMA_MEMORY_PRIORITY_HIGH:

+        return 0.75f;

+    case VMA_MEMORY_PRIORITY_HIGHEST:

+        return 1.f;

+    default:

+        VMA_ASSERT(0 && "Invalid memory priority.");

+        return 0.5f;

+    }

+}

+

 // Helper RAII class to lock a mutex in constructor and unlock it in destructor (at the end of scope).

 struct VmaMutexLock

 {

@@ -6802,6 +6823,7 @@
     VkResult AllocateVulkanMemory(

         VkDeviceSize allocationSize,

         uint32_t memoryTypeIndex,

+        VmaMemoryPriority priority,

         VkDeviceMemory* pMemory);

     void FreeVulkanMemory(uint32_t memoryType, VkDeviceSize size, VkDeviceMemory hMemory);

 

@@ -12134,7 +12156,7 @@
 VkResult VmaBlockVector::CreateBlock(VkDeviceSize blockSize, size_t* pNewBlockIndex)

 {

     VkDeviceMemory mem = VK_NULL_HANDLE;

-    VkResult res = m_hAllocator->AllocateVulkanMemory(blockSize, m_MemoryTypeIndex, &mem);

+    VkResult res = m_hAllocator->AllocateVulkanMemory(blockSize, m_MemoryTypeIndex, m_Priority, &mem);

     if(res < 0)

     {

         return res;

@@ -14671,7 +14693,8 @@
     VmaAllocation* pAllocation)

 {

     VkDeviceMemory hMemory = VK_NULL_HANDLE;

-    VkResult res = AllocateVulkanMemory(size, memTypeIndex, &hMemory);

+    VmaMemoryPriority priority = VMA_MEMORY_PRIORITY_UNKNOWN; // TODO!!!

+    VkResult res = AllocateVulkanMemory(size, memTypeIndex, priority, &hMemory);

     if(res < 0)

     {

         VMA_DEBUG_LOG("    vkAllocateMemory FAILED");

@@ -15347,6 +15370,7 @@
 VkResult VmaAllocator_T::AllocateVulkanMemory(

     VkDeviceSize allocationSize,

     uint32_t memoryTypeIndex,

+    VmaMemoryPriority priority,

     VkDeviceMemory* pMemory)

 {

     const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(memoryTypeIndex);

@@ -15356,6 +15380,17 @@
     allocInfo.allocationSize = allocationSize;

     allocInfo.memoryTypeIndex = memoryTypeIndex;

 

+#if VMA_EXT_MEMORY_PRIORITY

+    VkMemoryPriorityAllocateInfoEXT memoryPriorityAllocateInfo = { VK_STRUCTURE_TYPE_MEMORY_PRIORITY_ALLOCATE_INFO_EXT };

+    if(m_UseExtMemoryPriority &&

+        priority != VMA_MEMORY_PRIORITY_UNKNOWN &&

+        priority != VMA_MEMORY_PRIORITY_NORMAL)

+    {

+        memoryPriorityAllocateInfo.priority = VmaMemoryPriorityToVulkanPriority(priority);

+        allocInfo.pNext = &memoryPriorityAllocateInfo;

+    }

+#endif // #if VMA_EXT_MEMORY_PRIORITY

+

     VkResult res;

     if(m_HeapSizeLimit[heapIndex] != VK_WHOLE_SIZE)

     {