externals: Add vma and initialize it

video_core: Move vma implementation to library
This commit is contained in:
lat9nq 2023-06-18 04:59:12 -04:00 committed by GPUCode
parent 6e293be20b
commit 6448eade2e
7 changed files with 40 additions and 2 deletions

View file

@ -291,7 +291,7 @@ target_link_options(video_core PRIVATE ${FFmpeg_LDFLAGS})
add_dependencies(video_core host_shaders)
target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE})
target_link_libraries(video_core PRIVATE sirit Vulkan::Headers)
target_link_libraries(video_core PRIVATE sirit Vulkan::Headers vma)
if (ENABLE_NSIGHT_AFTERMATH)
if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK})

View file

@ -22,6 +22,10 @@
#include <adrenotools/bcenabler.h>
#endif
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
#include <vk_mem_alloc.h>
namespace Vulkan {
using namespace Common::Literals;
namespace {
@ -592,9 +596,26 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
graphics_queue = logical.GetQueue(graphics_family);
present_queue = logical.GetQueue(present_family);
const VmaVulkanFunctions functions = {
.vkGetInstanceProcAddr = dld.vkGetInstanceProcAddr,
.vkGetDeviceProcAddr = dld.vkGetDeviceProcAddr,
};
const VmaAllocatorCreateInfo allocator_info = {
.physicalDevice = physical,
.device = *logical,
.pVulkanFunctions = &functions,
.instance = instance,
.vulkanApiVersion = VK_API_VERSION_1_1,
};
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 {

View file

@ -13,6 +13,8 @@
#include "common/settings.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"
VK_DEFINE_HANDLE(VmaAllocator)
// Define all features which may be used by the implementation here.
// Vulkan version in the macro describes the minimum version required for feature availability.
// If the Vulkan version is lower than the required version, the named extension is required.
@ -618,6 +620,7 @@ private:
private:
VkInstance instance; ///< Vulkan instance.
VmaAllocator allocator; ///< VMA allocator.
vk::DeviceDispatch dld; ///< Device function pointers.
vk::PhysicalDevice physical; ///< Physical device.
vk::Device logical; ///< Logical device.