From 455823fcbff81f6c5627fdf1f5009714aed91ece Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Sat, 30 Oct 2021 12:26:09 +0200 Subject: [PATCH] Improved VmaBlockMetadata_Buddy when used as a virtual allocator, to support allocation sizes down to 1 --- include/vk_mem_alloc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index 8c174f2..5d1e378 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -5538,8 +5538,7 @@ public: virtual void SetAllocationUserData(VkDeviceSize offset, void* userData); private: - static const VkDeviceSize MIN_NODE_SIZE = 32; - static const size_t MAX_LEVELS = 30; + static const size_t MAX_LEVELS = 48; static VkDeviceSize AlignAllocationSize(VkDeviceSize size) { return VmaNextPow2(size); } @@ -10687,9 +10686,10 @@ void VmaBlockMetadata_Buddy::Init(VkDeviceSize size) m_SumFreeSize = m_UsableSize; // Calculate m_LevelCount. + const VkDeviceSize minNodeSize = IsVirtual() ? 1 : 16; m_LevelCount = 1; while(m_LevelCount < MAX_LEVELS && - LevelToNodeSize(m_LevelCount) >= MIN_NODE_SIZE) + LevelToNodeSize(m_LevelCount) >= minNodeSize) { ++m_LevelCount; }