summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar lat9nq2023-06-18 04:59:12 -0400
committerGravatar GPUCode2023-06-18 12:45:12 +0300
commit6448eade2ef126a88068cde66b77e7788c3fab08 (patch)
treeac7ff6d8d31defedca403be72068dcdfb07e48ff
parentMerge pull request #10797 from lat9nq/tzdb-patch (diff)
downloadyuzu-6448eade2ef126a88068cde66b77e7788c3fab08.tar.gz
yuzu-6448eade2ef126a88068cde66b77e7788c3fab08.tar.xz
yuzu-6448eade2ef126a88068cde66b77e7788c3fab08.zip
externals: Add vma and initialize it
video_core: Move vma implementation to library
-rw-r--r--.gitmodules3
-rw-r--r--externals/CMakeLists.txt5
m---------externals/vma/vma0
-rw-r--r--externals/vma/vma.cpp5
-rw-r--r--src/video_core/CMakeLists.txt2
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp23
-rw-r--r--src/video_core/vulkan_common/vulkan_device.h3
7 files changed, 39 insertions, 2 deletions
diff --git a/.gitmodules b/.gitmodules
index 89f2ad924..cc0e97a85 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -55,3 +55,6 @@
55[submodule "tzdb_to_nx"] 55[submodule "tzdb_to_nx"]
56 path = externals/nx_tzdb/tzdb_to_nx 56 path = externals/nx_tzdb/tzdb_to_nx
57 url = https://github.com/lat9nq/tzdb_to_nx.git 57 url = https://github.com/lat9nq/tzdb_to_nx.git
58[submodule "externals/vma/vma"]
59 path = externals/vma/vma
60 url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index 7cce27d51..ca4ebe4b9 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -143,6 +143,11 @@ endif()
143# TZDB (Time Zone Database) 143# TZDB (Time Zone Database)
144add_subdirectory(nx_tzdb) 144add_subdirectory(nx_tzdb)
145 145
146# VMA
147add_library(vma vma/vma.cpp)
148target_include_directories(vma PUBLIC ./vma/vma/include)
149target_link_libraries(vma PRIVATE Vulkan::Headers)
150
146if (NOT TARGET LLVM::Demangle) 151if (NOT TARGET LLVM::Demangle)
147 add_library(demangle demangle/ItaniumDemangle.cpp) 152 add_library(demangle demangle/ItaniumDemangle.cpp)
148 target_include_directories(demangle PUBLIC ./demangle) 153 target_include_directories(demangle PUBLIC ./demangle)
diff --git a/externals/vma/vma b/externals/vma/vma
new file mode 160000
Subproject 0aa3989b8f382f185fdf646cc83a1d16fa31d6a
diff --git a/externals/vma/vma.cpp b/externals/vma/vma.cpp
new file mode 100644
index 000000000..7f7df9cff
--- /dev/null
+++ b/externals/vma/vma.cpp
@@ -0,0 +1,5 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#define VMA_IMPLEMENTATION
5#include <vk_mem_alloc.h> \ No newline at end of file
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index bf6439530..e9e6f278d 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -291,7 +291,7 @@ target_link_options(video_core PRIVATE ${FFmpeg_LDFLAGS})
291 291
292add_dependencies(video_core host_shaders) 292add_dependencies(video_core host_shaders)
293target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE}) 293target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE})
294target_link_libraries(video_core PRIVATE sirit Vulkan::Headers) 294target_link_libraries(video_core PRIVATE sirit Vulkan::Headers vma)
295 295
296if (ENABLE_NSIGHT_AFTERMATH) 296if (ENABLE_NSIGHT_AFTERMATH)
297 if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK}) 297 if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK})
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index 3d2e9a16a..631d5e378 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -22,6 +22,10 @@
22#include <adrenotools/bcenabler.h> 22#include <adrenotools/bcenabler.h>
23#endif 23#endif
24 24
25#define VMA_STATIC_VULKAN_FUNCTIONS 0
26#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
27#include <vk_mem_alloc.h>
28
25namespace Vulkan { 29namespace Vulkan {
26using namespace Common::Literals; 30using namespace Common::Literals;
27namespace { 31namespace {
@@ -592,9 +596,26 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
592 596
593 graphics_queue = logical.GetQueue(graphics_family); 597 graphics_queue = logical.GetQueue(graphics_family);
594 present_queue = logical.GetQueue(present_family); 598 present_queue = logical.GetQueue(present_family);
599
600 const VmaVulkanFunctions functions = {
601 .vkGetInstanceProcAddr = dld.vkGetInstanceProcAddr,
602 .vkGetDeviceProcAddr = dld.vkGetDeviceProcAddr,
603 };
604
605 const VmaAllocatorCreateInfo allocator_info = {
606 .physicalDevice = physical,
607 .device = *logical,
608 .pVulkanFunctions = &functions,
609 .instance = instance,
610 .vulkanApiVersion = VK_API_VERSION_1_1,
611 };
612
613 vk::Check(vmaCreateAllocator(&allocator_info, &allocator));
595} 614}
596 615
597Device::~Device() = default; 616Device::~Device() {
617 vmaDestroyAllocator(allocator);
618}
598 619
599VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags wanted_usage, 620VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags wanted_usage,
600 FormatType format_type) const { 621 FormatType format_type) const {
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h
index f314d0ffe..123d3b1c4 100644
--- a/src/video_core/vulkan_common/vulkan_device.h
+++ b/src/video_core/vulkan_common/vulkan_device.h
@@ -13,6 +13,8 @@
13#include "common/settings.h" 13#include "common/settings.h"
14#include "video_core/vulkan_common/vulkan_wrapper.h" 14#include "video_core/vulkan_common/vulkan_wrapper.h"
15 15
16VK_DEFINE_HANDLE(VmaAllocator)
17
16// Define all features which may be used by the implementation here. 18// Define all features which may be used by the implementation here.
17// Vulkan version in the macro describes the minimum version required for feature availability. 19// Vulkan version in the macro describes the minimum version required for feature availability.
18// If the Vulkan version is lower than the required version, the named extension is required. 20// If the Vulkan version is lower than the required version, the named extension is required.
@@ -618,6 +620,7 @@ private:
618 620
619private: 621private:
620 VkInstance instance; ///< Vulkan instance. 622 VkInstance instance; ///< Vulkan instance.
623 VmaAllocator allocator; ///< VMA allocator.
621 vk::DeviceDispatch dld; ///< Device function pointers. 624 vk::DeviceDispatch dld; ///< Device function pointers.
622 vk::PhysicalDevice physical; ///< Physical device. 625 vk::PhysicalDevice physical; ///< Physical device.
623 vk::Device logical; ///< Logical device. 626 vk::Device logical; ///< Logical device.