mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-11-28 15:03:07 +00:00
externals: Add vma and initialize it
video_core: Move vma implementation to library
This commit is contained in:
parent
6e293be20b
commit
6448eade2e
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -55,3 +55,6 @@
|
||||||
[submodule "tzdb_to_nx"]
|
[submodule "tzdb_to_nx"]
|
||||||
path = externals/nx_tzdb/tzdb_to_nx
|
path = externals/nx_tzdb/tzdb_to_nx
|
||||||
url = https://github.com/lat9nq/tzdb_to_nx.git
|
url = https://github.com/lat9nq/tzdb_to_nx.git
|
||||||
|
[submodule "externals/vma/vma"]
|
||||||
|
path = externals/vma/vma
|
||||||
|
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
|
||||||
|
|
5
externals/CMakeLists.txt
vendored
5
externals/CMakeLists.txt
vendored
|
@ -143,6 +143,11 @@ endif()
|
||||||
# TZDB (Time Zone Database)
|
# TZDB (Time Zone Database)
|
||||||
add_subdirectory(nx_tzdb)
|
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)
|
if (NOT TARGET LLVM::Demangle)
|
||||||
add_library(demangle demangle/ItaniumDemangle.cpp)
|
add_library(demangle demangle/ItaniumDemangle.cpp)
|
||||||
target_include_directories(demangle PUBLIC ./demangle)
|
target_include_directories(demangle PUBLIC ./demangle)
|
||||||
|
|
1
externals/vma/vma
vendored
Submodule
1
externals/vma/vma
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 0aa3989b8f382f185fdf646cc83a1d16fa31d6ab
|
5
externals/vma/vma.cpp
vendored
Normal file
5
externals/vma/vma.cpp
vendored
Normal file
|
@ -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>
|
|
@ -291,7 +291,7 @@ target_link_options(video_core PRIVATE ${FFmpeg_LDFLAGS})
|
||||||
|
|
||||||
add_dependencies(video_core host_shaders)
|
add_dependencies(video_core host_shaders)
|
||||||
target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE})
|
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 (ENABLE_NSIGHT_AFTERMATH)
|
||||||
if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK})
|
if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK})
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
#include <adrenotools/bcenabler.h>
|
#include <adrenotools/bcenabler.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||||
|
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||||
|
#include <vk_mem_alloc.h>
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
using namespace Common::Literals;
|
using namespace Common::Literals;
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -592,9 +596,26 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
||||||
|
|
||||||
graphics_queue = logical.GetQueue(graphics_family);
|
graphics_queue = logical.GetQueue(graphics_family);
|
||||||
present_queue = logical.GetQueue(present_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,
|
VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags wanted_usage,
|
||||||
FormatType format_type) const {
|
FormatType format_type) const {
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||||
|
|
||||||
|
VK_DEFINE_HANDLE(VmaAllocator)
|
||||||
|
|
||||||
// Define all features which may be used by the implementation here.
|
// Define all features which may be used by the implementation here.
|
||||||
// Vulkan version in the macro describes the minimum version required for feature availability.
|
// 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.
|
// If the Vulkan version is lower than the required version, the named extension is required.
|
||||||
|
@ -618,6 +620,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VkInstance instance; ///< Vulkan instance.
|
VkInstance instance; ///< Vulkan instance.
|
||||||
|
VmaAllocator allocator; ///< VMA allocator.
|
||||||
vk::DeviceDispatch dld; ///< Device function pointers.
|
vk::DeviceDispatch dld; ///< Device function pointers.
|
||||||
vk::PhysicalDevice physical; ///< Physical device.
|
vk::PhysicalDevice physical; ///< Physical device.
|
||||||
vk::Device logical; ///< Logical device.
|
vk::Device logical; ///< Logical device.
|
||||||
|
|
Loading…
Reference in a new issue