diff options
| author | liamwhite <liamwhite@users.noreply.github.com> | 2023-06-27 11:21:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-27 11:21:36 -0400 |
| commit | c6959449d1e28f16d6eaf3a215f2bce5fab5ed0f (patch) | |
| tree | 1ceac7222976e40bb12c3919cd3412d36b7ec93b /src/video_core/vulkan_common/vulkan_device.cpp | |
| parent | 20111c86b65afef07923fdb2f15867b7f8c69e32 (diff) | |
| parent | b6c6dcc5760ebaf08460c176c42d1c4729e2eb21 (diff) | |
Merge pull request #10473 from GPUCode/vma
Use vulkan memory allocator
Diffstat (limited to 'src/video_core/vulkan_common/vulkan_device.cpp')
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index b11abe311..e4ca65b58 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -22,6 +22,8 @@ #include <adrenotools/bcenabler.h> #endif +#include <vk_mem_alloc.h> + namespace Vulkan { using namespace Common::Literals; namespace { @@ -596,9 +598,31 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR graphics_queue = logical.GetQueue(graphics_family); present_queue = logical.GetQueue(present_family); + + VmaVulkanFunctions functions{}; + functions.vkGetInstanceProcAddr = dld.vkGetInstanceProcAddr; + functions.vkGetDeviceProcAddr = dld.vkGetDeviceProcAddr; + + const VmaAllocatorCreateInfo allocator_info = { + .flags = VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT, + .physicalDevice = physical, + .device = *logical, + .preferredLargeHeapBlockSize = 0, + .pAllocationCallbacks = nullptr, + .pDeviceMemoryCallbacks = nullptr, + .pHeapSizeLimit = nullptr, + .pVulkanFunctions = &functions, + .instance = instance, + .vulkanApiVersion = VK_API_VERSION_1_1, + .pTypeExternalMemoryHandleTypes = nullptr, + }; + + vk::Check(vmaCreateAllocator(&allocator_info, &allocator)); } -Device::~Device() = default; +Device::~Device() { + vmaDestroyAllocator(allocator); +} VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags wanted_usage, FormatType format_type) const { |
