renderer_vulkan: Drop dependency on Vulkan-SDK
* Dynamically fetch vulkan function pointers and checkout Vulkan-Headers. This way we are not tied by the installed SDK version
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -61,3 +61,6 @@
|
||||
[submodule "externals/shaderc"]
|
||||
path = externals/shaderc
|
||||
url = https://github.com/google/shaderc
|
||||
[submodule "externals/Vulkan-Headers"]
|
||||
path = externals/Vulkan-Headers
|
||||
url = https://github.com/KhronosGroup/Vulkan-Headers
|
||||
|
@ -199,11 +199,6 @@ if (ENABLE_QT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ENABLE_VULKAN)
|
||||
# Vulkan Memory Allocator
|
||||
set(VMA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/vma/include)
|
||||
endif()
|
||||
|
||||
# Ensure libusb is properly configured (based on dolphin libusb include)
|
||||
if(NOT APPLE)
|
||||
include(FindPkgConfig)
|
||||
|
1
externals/CMakeLists.txt
vendored
1
externals/CMakeLists.txt
vendored
@ -132,6 +132,7 @@ if (ENABLE_WEB_SERVICE)
|
||||
SET(CPP_JWT_USE_VENDORED_NLOHMANN_JSON ON CACHE BOOL "Use included json-hpp")
|
||||
add_library(cpp-jwt INTERFACE)
|
||||
target_include_directories(cpp-jwt INTERFACE ./cpp-jwt/include)
|
||||
target_compile_definitions(cpp-jwt INTERFACE CPP_JWT_USE_VENDORED_NLOHMANN_JSON)
|
||||
endif()
|
||||
|
||||
# lodepng
|
||||
|
1
externals/Vulkan-Headers
vendored
Submodule
1
externals/Vulkan-Headers
vendored
Submodule
Submodule externals/Vulkan-Headers added at 2c823b7f27
@ -75,12 +75,12 @@ add_library(video_core STATIC
|
||||
renderer_vulkan/renderer_vulkan.h
|
||||
renderer_vulkan/vk_buffer.cpp
|
||||
renderer_vulkan/vk_buffer.h
|
||||
renderer_vulkan/vk_common.cpp
|
||||
renderer_vulkan/vk_common.h
|
||||
renderer_vulkan/vk_format_reinterpreter.cpp
|
||||
renderer_vulkan/vk_format_reinterpreter.h
|
||||
renderer_vulkan/vk_instance.cpp
|
||||
renderer_vulkan/vk_instance.h
|
||||
renderer_vulkan/vk_memory.cpp
|
||||
renderer_vulkan/vk_memory.h
|
||||
renderer_vulkan/vk_pipeline_builder.cpp
|
||||
renderer_vulkan/vk_pipeline_builder.h
|
||||
renderer_vulkan/vk_rasterizer_cache.cpp
|
||||
@ -177,11 +177,11 @@ create_target_directory_groups(video_core)
|
||||
target_link_libraries(video_core PUBLIC common core)
|
||||
target_link_libraries(video_core PRIVATE glad nihstro-headers Boost::serialization)
|
||||
|
||||
# Include Vulkan headers
|
||||
target_include_directories(video_core PRIVATE ../../externals/Vulkan-Headers/include)
|
||||
target_include_directories(video_core PRIVATE ../../externals/vma/include)
|
||||
target_link_libraries(video_core PRIVATE ${SHADERC_DEP})
|
||||
|
||||
if (ARCHITECTURE_x86_64)
|
||||
target_link_libraries(video_core PUBLIC xbyak)
|
||||
endif()
|
||||
|
||||
if (ENABLE_VULKAN)
|
||||
target_include_directories(video_core PRIVATE ${Vulkan_INCLUDE_DIRS} ${VMA_INCLUDE_DIR})
|
||||
target_link_libraries(video_core PRIVATE ${Vulkan_LIBRARIES} ${SHADERC_DEP})
|
||||
endif()
|
||||
|
@ -5,17 +5,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <glad/glad.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "video_core/regs_framebuffer.h"
|
||||
#include "video_core/regs_lighting.h"
|
||||
#include "video_core/regs_texturing.h"
|
||||
#include "video_core/renderer_vulkan/vk_common.h"
|
||||
|
||||
namespace PicaToVK {
|
||||
|
||||
|
@ -2,6 +2,22 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
// Enable vulkan platforms
|
||||
#if defined(ANDROID) || defined (__ANDROID__)
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR 1
|
||||
#elif defined(_WIN32)
|
||||
#define VK_USE_PLATFORM_WIN32_KHR 1
|
||||
#elif defined(__APPLE__)
|
||||
#define VK_USE_PLATFORM_MACOS_MVK 1
|
||||
#define VK_USE_PLATFORM_METAL_EXT 1
|
||||
#else
|
||||
#ifdef WAYLAND_DISPLAY
|
||||
#define VK_USE_PLATFORM_WAYLAND_KHR 1
|
||||
#else // wayland
|
||||
#define VK_USE_PLATFORM_XLIB_KHR 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
@ -21,6 +37,8 @@
|
||||
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
||||
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
||||
#include "video_core/renderer_vulkan/vk_pipeline_builder.h"
|
||||
#include "video_core/renderer_vulkan/vk_swapchain.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
// Include these late to avoid polluting previous headers
|
||||
@ -38,12 +56,12 @@
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
vk::SurfaceKHR CreateSurface(const VkInstance& instance,
|
||||
vk::SurfaceKHR CreateSurface(const vk::Instance& instance,
|
||||
const Frontend::EmuWindow& emu_window) {
|
||||
const auto& window_info = emu_window.GetWindowInfo();
|
||||
VkSurfaceKHR unsafe_surface = nullptr;
|
||||
vk::SurfaceKHR surface;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if VK_USE_PLATFORM_WIN32_KHR
|
||||
if (window_info.type == Core::Frontend::WindowSystemType::Windows) {
|
||||
const HWND hWnd = static_cast<HWND>(window_info.render_surface);
|
||||
const VkWin32SurfaceCreateInfoKHR win32_ci{VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR,
|
||||
@ -53,36 +71,35 @@ vk::SurfaceKHR CreateSurface(const VkInstance& instance,
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
#elif VK_USE_PLATFORM_XLIB_KHR
|
||||
if (window_info.type == Frontend::WindowSystemType::X11) {
|
||||
const VkXlibSurfaceCreateInfoKHR xlib_ci{
|
||||
VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, nullptr, 0,
|
||||
const vk::XlibSurfaceCreateInfoKHR xlib_ci{{},
|
||||
static_cast<Display*>(window_info.display_connection),
|
||||
reinterpret_cast<Window>(window_info.render_surface)};
|
||||
if (vkCreateXlibSurfaceKHR(instance, &xlib_ci, nullptr, &unsafe_surface) != VK_SUCCESS) {
|
||||
if (instance.createXlibSurfaceKHR(&xlib_ci, nullptr, &surface) != vk::Result::eSuccess) {
|
||||
LOG_ERROR(Render_Vulkan, "Failed to initialize Xlib surface");
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
#elif VK_USE_PLATFORM_WAYLAND_KHR
|
||||
if (window_info.type == Frontend::WindowSystemType::Wayland) {
|
||||
/*const VkWaylandSurfaceCreateInfoKHR wayland_ci{
|
||||
const VkWaylandSurfaceCreateInfoKHR wayland_ci{
|
||||
VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR, nullptr, 0,
|
||||
static_cast<wl_display*>(window_info.display_connection),
|
||||
static_cast<wl_surface*>(window_info.render_surface)};
|
||||
if (vkCreateWaylandSurfaceKHR(instance, &wayland_ci, nullptr, &unsafe_surface) != VK_SUCCESS) {
|
||||
LOG_ERROR(Render_Vulkan, "Failed to initialize Wayland surface");
|
||||
UNREACHABLE();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!unsafe_surface) {
|
||||
if (!surface) {
|
||||
LOG_ERROR(Render_Vulkan, "Presentation not supported on this platform");
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return vk::SurfaceKHR(unsafe_surface);
|
||||
return surface;
|
||||
}
|
||||
|
||||
std::vector<const char*> RequiredExtensions(Frontend::WindowSystemType window_type, bool enable_debug_utils) {
|
||||
@ -568,23 +585,29 @@ void RendererVulkan::EndPresent() {
|
||||
|
||||
/// Initialize the renderer
|
||||
VideoCore::ResultStatus RendererVulkan::Init() {
|
||||
// Create vulkan instance
|
||||
vk::ApplicationInfo app_info{"Citra", VK_MAKE_VERSION(1, 0, 0), nullptr, 0, VK_API_VERSION_1_3};
|
||||
// Fetch instance independant function pointers
|
||||
vk::DynamicLoader dl;
|
||||
auto vkGetInstanceProcAddr = dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
|
||||
|
||||
// Get required extensions
|
||||
vk::ApplicationInfo app_info{"Citra", VK_MAKE_VERSION(1, 0, 0), nullptr, 0, VK_API_VERSION_1_3};
|
||||
auto extensions = RequiredExtensions(render_window.GetWindowInfo().type, true);
|
||||
|
||||
const char* layers = "VK_LAYER_KHRONOS_validation";
|
||||
vk::InstanceCreateInfo instance_info{{}, &app_info, layers, extensions};
|
||||
|
||||
// Create vulkan instance
|
||||
auto instance = vk::createInstance(instance_info);
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(instance);
|
||||
|
||||
auto physical_devices = instance.enumeratePhysicalDevices();
|
||||
|
||||
// Create global instance
|
||||
auto surface = CreateSurface(instance, render_window);
|
||||
g_vk_instace = std::make_unique<Instance>();
|
||||
g_vk_task_scheduler = std::make_unique<TaskScheduler>();
|
||||
g_vk_instace->Create(instance, physical_devices[1], surface, true);
|
||||
g_vk_instace->Create(instance, physical_devices[2], surface, true);
|
||||
g_vk_task_scheduler->Create();
|
||||
|
||||
//auto& layout = render_window.GetFramebufferLayout();
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "common/math_util.h"
|
||||
#include "core/hw/gpu.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "video_core/renderer_vulkan/vk_swapchain.h"
|
||||
#include "video_core/renderer_vulkan/vk_state.h"
|
||||
|
||||
namespace Layout {
|
||||
@ -18,6 +17,8 @@ struct FramebufferLayout;
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
class Swapchain;
|
||||
|
||||
/// Structure used for storing information about the display target for each 3DS screen
|
||||
struct ScreenInfo {
|
||||
Texture* display_texture;
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <span>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/renderer_vulkan/vk_common.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
|
@ -3,4 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
#include "vk_memory.h"
|
||||
#include "video_core/renderer_vulkan/vk_common.h"
|
||||
|
||||
// Store the dispatch loader here
|
||||
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
|
@ -4,16 +4,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#ifndef VMA_STATIC_VULKAN_FUNCTIONS
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#endif
|
||||
|
||||
#ifndef VMA_DYNAMIC_VULKAN_FUNCTIONS
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||
#endif
|
||||
// Include vulkan-hpp header
|
||||
#define VK_NO_PROTOTYPES 1
|
||||
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
// Include Vulkan memory allocator
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||
#define VMA_VULKAN_VERSION 1001000 // Vulkan 1.1
|
||||
#include "vk_mem_alloc.h"
|
||||
#include <vk_mem_alloc.h>
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <map>
|
||||
#include <type_traits>
|
||||
#include <glad/glad.h>
|
||||
#include "common/common_types.h"
|
||||
#include "common/math_util.h"
|
||||
#include "video_core/renderer_vulkan/vk_surface_params.h"
|
||||
|
@ -98,6 +98,7 @@ bool Instance::CreateDevice(vk::SurfaceKHR surface, bool validation_enabled) {
|
||||
|
||||
// Create logical device
|
||||
device = physical_device.createDevice(device_info);
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(device);
|
||||
|
||||
// Grab the graphics and present queues.
|
||||
graphics_queue = device.getQueue(graphics_queue_family_index, 0);
|
||||
@ -133,14 +134,11 @@ bool Instance::FindFeatures() {
|
||||
vk13_features.dynamicRendering = true;
|
||||
dynamic_state_features.extendedDynamicState = true;
|
||||
dynamic_state2_features.extendedDynamicState2 = true;
|
||||
dynamic_state2_features.extendedDynamicState2LogicOp = true;
|
||||
color_write_features.colorWriteEnable = true;
|
||||
|
||||
// Include features in device creation
|
||||
vk12_features.pNext = &vk13_features;
|
||||
vk13_features.pNext = &dynamic_state_features;
|
||||
dynamic_state_features.pNext = &dynamic_state2_features;
|
||||
dynamic_state2_features.pNext = &color_write_features;
|
||||
features = vk::PhysicalDeviceFeatures2{vk_features, &vk12_features};
|
||||
|
||||
return true;
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/renderer_vulkan/vk_common.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <boost/icl/interval_map.hpp>
|
||||
#include <boost/icl/interval_set.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include "common/assert.h"
|
||||
#include "common/common_funcs.h"
|
||||
|
@ -5,16 +5,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include "common/hash.h"
|
||||
#include "video_core/regs.h"
|
||||
#include "video_core/shader/shader.h"
|
||||
#include "video_core/renderer_vulkan/vk_common.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
|
@ -2,13 +2,9 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <span>
|
||||
#include "video_core/renderer_vulkan/vk_state.h"
|
||||
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
||||
#include "video_core/renderer_vulkan/vk_rasterizer_cache.h"
|
||||
#include "video_core/renderer_vulkan/vk_rasterizer.h"
|
||||
#include "video_core/renderer_vulkan/vk_shader_gen.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
@ -5,8 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <variant>
|
||||
#include <optional>
|
||||
#include <bitset>
|
||||
#include "video_core/regs.h"
|
||||
#include "video_core/renderer_vulkan/vk_shader_state.h"
|
||||
|
@ -2,11 +2,7 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <limits>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
#include "common/logging/log.h"
|
||||
#include "video_core/renderer_vulkan/vk_swapchain.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include "core/frontend/emu_window.h"
|
||||
#include "video_core/renderer_vulkan/vk_texture.h"
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
#include "video_core/renderer_vulkan/vk_state.h"
|
||||
#include "video_core/renderer_vulkan/vk_swapchain.h"
|
||||
#include "common/assert.h"
|
||||
|
@ -5,17 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/threadsafe_queue.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
#include "video_core/renderer_vulkan/vk_buffer.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "video_core/renderer_vulkan/vk_texture.h"
|
||||
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
||||
#include "video_core/renderer_vulkan/vk_state.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
|
Reference in New Issue
Block a user