summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2023-06-18 10:59:12 +0200
committerGPUCode <geoster3d@gmail.com>2023-06-18 11:45:12 +0200
commit6448eade2ef126a88068cde66b77e7788c3fab08 (patch)
treeac7ff6d8d31defedca403be72068dcdfb07e48ff
parentMerge pull request #10797 from lat9nq/tzdb-patch (diff)
downloadyuzu-6448eade2ef126a88068cde66b77e7788c3fab08.tar
yuzu-6448eade2ef126a88068cde66b77e7788c3fab08.tar.gz
yuzu-6448eade2ef126a88068cde66b77e7788c3fab08.tar.bz2
yuzu-6448eade2ef126a88068cde66b77e7788c3fab08.tar.lz
yuzu-6448eade2ef126a88068cde66b77e7788c3fab08.tar.xz
yuzu-6448eade2ef126a88068cde66b77e7788c3fab08.tar.zst
yuzu-6448eade2ef126a88068cde66b77e7788c3fab08.zip
Diffstat (limited to '')
-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 @@
[submodule "tzdb_to_nx"]
path = externals/nx_tzdb/tzdb_to_nx
url = https://github.com/lat9nq/tzdb_to_nx.git
+[submodule "externals/vma/vma"]
+ path = externals/vma/vma
+ 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()
# TZDB (Time Zone Database)
add_subdirectory(nx_tzdb)
+# VMA
+add_library(vma vma/vma.cpp)
+target_include_directories(vma PUBLIC ./vma/vma/include)
+target_link_libraries(vma PRIVATE Vulkan::Headers)
+
if (NOT TARGET LLVM::Demangle)
add_library(demangle demangle/ItaniumDemangle.cpp)
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 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#define VMA_IMPLEMENTATION
+#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})
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})
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 @@
#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 {
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 @@
#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.