diff options
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | externals/CMakeLists.txt | 5 | ||||
| m--------- | externals/vma/vma | 0 | ||||
| -rw-r--r-- | externals/vma/vma.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 23 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.h | 3 |
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) |
| 144 | add_subdirectory(nx_tzdb) | 144 | add_subdirectory(nx_tzdb) |
| 145 | 145 | ||
| 146 | # VMA | ||
| 147 | add_library(vma vma/vma.cpp) | ||
| 148 | target_include_directories(vma PUBLIC ./vma/vma/include) | ||
| 149 | target_link_libraries(vma PRIVATE Vulkan::Headers) | ||
| 150 | |||
| 146 | if (NOT TARGET LLVM::Demangle) | 151 | if (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 | ||
| 292 | add_dependencies(video_core host_shaders) | 292 | add_dependencies(video_core host_shaders) |
| 293 | target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE}) | 293 | target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE}) |
| 294 | target_link_libraries(video_core PRIVATE sirit Vulkan::Headers) | 294 | target_link_libraries(video_core PRIVATE sirit Vulkan::Headers vma) |
| 295 | 295 | ||
| 296 | if (ENABLE_NSIGHT_AFTERMATH) | 296 | if (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 | |||
| 25 | namespace Vulkan { | 29 | namespace Vulkan { |
| 26 | using namespace Common::Literals; | 30 | using namespace Common::Literals; |
| 27 | namespace { | 31 | namespace { |
| @@ -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 | ||
| 597 | Device::~Device() = default; | 616 | Device::~Device() { |
| 617 | vmaDestroyAllocator(allocator); | ||
| 618 | } | ||
| 598 | 619 | ||
| 599 | VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags wanted_usage, | 620 | VkFormat 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 | ||
| 16 | VK_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 | ||
| 619 | private: | 621 | private: |
| 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. |