From 95f07262a8c5e2d34912bda2e8c8c4f3be05c9c4 Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Fri, 19 Jan 2018 16:09:04 +0100 Subject: [PATCH] VmaAllocator_T::CalcPreferredBlockSize: Minor improvement - treating HOST_CACHED memory type as small heap. --- src/vk_mem_alloc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vk_mem_alloc.h b/src/vk_mem_alloc.h index b4565ad..0dbe9b6 100644 --- a/src/vk_mem_alloc.h +++ b/src/vk_mem_alloc.h @@ -6862,8 +6862,10 @@ VkDeviceSize VmaAllocator_T::CalcPreferredBlockSize(uint32_t memTypeIndex) { const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(memTypeIndex); const VkDeviceSize heapSize = m_MemProps.memoryHeaps[heapIndex].size; - return (heapSize <= VMA_SMALL_HEAP_MAX_SIZE) ? - m_PreferredSmallHeapBlockSize : m_PreferredLargeHeapBlockSize; + const bool isSmallHeap = heapSize <= VMA_SMALL_HEAP_MAX_SIZE || + // HOST_CACHED memory type is treated as small despite it has full size of CPU memory heap, because we usually don't use much of it. + (m_MemProps.memoryTypes[memTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) != 0; + return isSmallHeap ? m_PreferredSmallHeapBlockSize : m_PreferredLargeHeapBlockSize; } VkResult VmaAllocator_T::AllocateMemoryOfType(