From 6f4dbf4fcd3ad0516a0826df14a8cc10fc39e9dc Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 26 Jan 2021 23:47:26 +0300 Subject: [PATCH] vk/vma: Always use aligned requests - Performance optimization when combined with vma optimizations added by me --- rpcs3/Emu/RSX/VK/vkutils/memory.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/VK/vkutils/memory.cpp b/rpcs3/Emu/RSX/VK/vkutils/memory.cpp index aa73bc44cb..4781344e63 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/memory.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/memory.cpp @@ -1,6 +1,16 @@ #include "device.h" #include "memory.h" +namespace +{ + // Copied from rsx_utils.h. Move to a more convenient location + template + static inline T align2(T value, U alignment) + { + return ((value + alignment - 1) / alignment) * alignment; + } +} + namespace vk { mem_allocator_vma::mem_allocator_vma(VkDevice dev, VkPhysicalDevice pdev) : mem_allocator_base(dev, pdev) @@ -27,9 +37,10 @@ namespace vk VmaAllocationCreateInfo create_info = {}; mem_req.memoryTypeBits = 1u << memory_type_index; - mem_req.size = block_sz; + mem_req.size = ::align2(block_sz, alignment); mem_req.alignment = alignment; create_info.memoryTypeBits = 1u << memory_type_index; + create_info.flags = VMA_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT; if (VkResult result = vmaAllocateMemory(m_allocator, &mem_req, &create_info, &vma_alloc, nullptr); result != VK_SUCCESS)