From a08eb2ead837b8de5dbd4c666474ee62ea45bd68 Mon Sep 17 00:00:00 2001 From: Takoroka <137927095+Takoroka@users.noreply.github.com> Date: Sun, 1 Nov 2026 02:42:38 -0500 Subject: vulkan: 16 MiB memory blocks With 32 MiB blocks title 1 still had ~0.5 GB of holes between images: a block drains only once all of its images are gone, and fewer per block drain sooner. Allocations over 8 MiB get memory of their own. (cherry picked from commit d3a4db818512221e6b0555e886e192c346c16ae7) --- src/video_core/vulkan_common/vulkan_device.cpp | 9 +++++---- src/video_core/vulkan_common/vulkan_device.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/video_core/vulkan_common') diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index bcf1743e11..10c9e501bf 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -779,13 +779,14 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR .flags = flags, .physicalDevice = physical, .device = *logical, - // 32 MiB blocks on discrete GPUs too: with 256 MiB ones, Switch 2 titles' mix of + // 16 MiB blocks on discrete GPUs too: with 256 MiB ones, Switch 2 titles' mix of // texture sizes left ~38% of the image blocks empty (2 GB of an 8 GB card in title // 1), which the texture cache counted as used and kept evicting textures for. With // 64 MiB ones textures created and deleted by the thousand still left ~1.7 GB of holes - // after ten minutes; VMA also gives allocations over half a block (16 MiB) their own - // memory, which goes back to the driver when they are freed. - .preferredLargeHeapBlockSize = 32u * 1024u * 1024u, + // after ten minutes, with 32 MiB ones ~0.5 GB: a block drains only once all of its + // images are gone, and fewer per block drain sooner. VMA gives allocations over half a + // block (8 MiB) their own memory, which goes back to the driver when they are freed. + .preferredLargeHeapBlockSize = 16u * 1024u * 1024u, .pAllocationCallbacks = nullptr, .pDeviceMemoryCallbacks = nullptr, .pHeapSizeLimit = heap_size_limit != 0 ? heap_size_limits.data() : nullptr, diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 77e1dba4d3..5c757bedc4 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h @@ -273,7 +273,7 @@ public: SparsePages, DeviceBuffers, }; - static constexpr VkDeviceSize SeparatePoolBlockSize = 32ULL << 20; + static constexpr VkDeviceSize SeparatePoolBlockSize = 16ULL << 20; /// The pool of that kind for a memory type, created on first use (null if that failed). VmaPool GetSeparatePool(SeparatePool kind, u32 memory_type) const; -- cgit v1.2.3