diff options
| author | 2023-02-18 23:42:07 -0800 | |
|---|---|---|
| committer | 2023-06-03 00:05:31 -0700 | |
| commit | 4c38220a644f8292f4915eaabb2f80d3d0badab0 (patch) | |
| tree | d6a2291e26e3723ec0e3124f9bb117487dd3966c /src/video_core | |
| parent | core: frontend: Refactor GraphicsContext to its own module. (diff) | |
| download | yuzu-4c38220a644f8292f4915eaabb2f80d3d0badab0.tar.gz yuzu-4c38220a644f8292f4915eaabb2f80d3d0badab0.tar.xz yuzu-4c38220a644f8292f4915eaabb2f80d3d0badab0.zip | |
android: native: Add support for custom Vulkan driver loading.
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.h | 2 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_library.cpp | 18 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_library.h | 6 |
5 files changed, 28 insertions, 16 deletions
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index fbcf4c1d3..30dc69f13 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp | |||
| @@ -84,8 +84,8 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_, | |||
| 84 | Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, | 84 | Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, |
| 85 | std::unique_ptr<Core::Frontend::GraphicsContext> context_) try | 85 | std::unique_ptr<Core::Frontend::GraphicsContext> context_) try |
| 86 | : RendererBase(emu_window, std::move(context_)), telemetry_session(telemetry_session_), | 86 | : RendererBase(emu_window, std::move(context_)), telemetry_session(telemetry_session_), |
| 87 | cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary()), | 87 | cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary(context.get())), |
| 88 | instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, | 88 | instance(CreateInstance(*library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, |
| 89 | Settings::values.renderer_debug.GetValue())), | 89 | Settings::values.renderer_debug.GetValue())), |
| 90 | debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), | 90 | debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), |
| 91 | surface(CreateSurface(instance, render_window.GetWindowInfo())), | 91 | surface(CreateSurface(instance, render_window.GetWindowInfo())), |
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.h b/src/video_core/renderer_vulkan/renderer_vulkan.h index f44367cb2..3c63a2004 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.h +++ b/src/video_core/renderer_vulkan/renderer_vulkan.h | |||
| @@ -63,7 +63,7 @@ private: | |||
| 63 | Core::Memory::Memory& cpu_memory; | 63 | Core::Memory::Memory& cpu_memory; |
| 64 | Tegra::GPU& gpu; | 64 | Tegra::GPU& gpu; |
| 65 | 65 | ||
| 66 | Common::DynamicLibrary library; | 66 | std::shared_ptr<Common::DynamicLibrary> library; |
| 67 | vk::InstanceDispatch dld; | 67 | vk::InstanceDispatch dld; |
| 68 | 68 | ||
| 69 | vk::Instance instance; | 69 | vk::Instance instance; |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 63e1c7d63..40cdf2fde 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -314,10 +314,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 314 | const bool is_intel_anv = driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA; | 314 | const bool is_intel_anv = driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA; |
| 315 | const bool is_nvidia = driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY; | 315 | const bool is_nvidia = driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY; |
| 316 | const bool is_mvk = driver_id == VK_DRIVER_ID_MOLTENVK; | 316 | const bool is_mvk = driver_id == VK_DRIVER_ID_MOLTENVK; |
| 317 | const bool is_adreno = driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY; | 317 | const bool is_qualcomm = driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY; |
| 318 | const bool is_arm = driver_id == VK_DRIVER_ID_ARM_PROPRIETARY; | 318 | const bool is_turnip = driver_id == VK_DRIVER_ID_MESA_TURNIP; |
| 319 | 319 | ||
| 320 | if ((is_mvk || is_adreno) && !is_suitable) { | 320 | if ((is_mvk || is_qualcomm || is_turnip) && !is_suitable) { |
| 321 | LOG_WARNING(Render_Vulkan, "Unsuitable driver is MoltenVK, continuing anyway"); | 321 | LOG_WARNING(Render_Vulkan, "Unsuitable driver is MoltenVK, continuing anyway"); |
| 322 | } else if (!is_suitable) { | 322 | } else if (!is_suitable) { |
| 323 | throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER); | 323 | throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER); |
| @@ -362,14 +362,15 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 362 | CollectToolingInfo(); | 362 | CollectToolingInfo(); |
| 363 | 363 | ||
| 364 | #ifdef ANDROID | 364 | #ifdef ANDROID |
| 365 | if (is_adreno) { | 365 | if (is_qualcomm) { |
| 366 | must_emulate_scaled_formats = true; | 366 | must_emulate_scaled_formats = true; |
| 367 | 367 | ||
| 368 | LOG_WARNING(Render_Vulkan, "Adreno drivers have broken VK_EXT_extended_dynamic_state"); | 368 | LOG_WARNING(Render_Vulkan, "Adreno drivers have broken VK_EXT_extended_dynamic_state"); |
| 369 | extensions.extended_dynamic_state = false; | 369 | extensions.extended_dynamic_state = false; |
| 370 | loaded_extensions.erase(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); | 370 | loaded_extensions.erase(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); |
| 371 | 371 | ||
| 372 | LOG_WARNING(Render_Vulkan, "Adreno drivers have a slow VK_KHR_push_descriptor implementation"); | 372 | LOG_WARNING(Render_Vulkan, |
| 373 | "Adreno drivers have a slow VK_KHR_push_descriptor implementation"); | ||
| 373 | extensions.push_descriptor = false; | 374 | extensions.push_descriptor = false; |
| 374 | loaded_extensions.erase(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); | 375 | loaded_extensions.erase(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
| 375 | 376 | ||
| @@ -392,6 +393,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 392 | } | 393 | } |
| 393 | } | 394 | } |
| 394 | 395 | ||
| 396 | const bool is_arm = driver_id == VK_DRIVER_ID_ARM_PROPRIETARY; | ||
| 395 | if (is_arm) { | 397 | if (is_arm) { |
| 396 | must_emulate_scaled_formats = true; | 398 | must_emulate_scaled_formats = true; |
| 397 | 399 | ||
| @@ -513,7 +515,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 513 | LOG_WARNING(Render_Vulkan, "Intel proprietary drivers do not support MSAA image blits"); | 515 | LOG_WARNING(Render_Vulkan, "Intel proprietary drivers do not support MSAA image blits"); |
| 514 | cant_blit_msaa = true; | 516 | cant_blit_msaa = true; |
| 515 | } | 517 | } |
| 516 | if (is_intel_anv || is_adreno) { | 518 | if (is_intel_anv || is_qualcomm) { |
| 517 | LOG_WARNING(Render_Vulkan, "Driver does not support native BGR format"); | 519 | LOG_WARNING(Render_Vulkan, "Driver does not support native BGR format"); |
| 518 | must_emulate_bgr565 = true; | 520 | must_emulate_bgr565 = true; |
| 519 | } | 521 | } |
diff --git a/src/video_core/vulkan_common/vulkan_library.cpp b/src/video_core/vulkan_common/vulkan_library.cpp index 4eb3913ee..9a7d369f3 100644 --- a/src/video_core/vulkan_common/vulkan_library.cpp +++ b/src/video_core/vulkan_common/vulkan_library.cpp | |||
| @@ -10,29 +10,35 @@ | |||
| 10 | 10 | ||
| 11 | namespace Vulkan { | 11 | namespace Vulkan { |
| 12 | 12 | ||
| 13 | Common::DynamicLibrary OpenLibrary() { | 13 | std::shared_ptr<Common::DynamicLibrary> OpenLibrary( |
| 14 | [[maybe_unused]] Core::Frontend::GraphicsContext* context) { | ||
| 14 | LOG_DEBUG(Render_Vulkan, "Looking for a Vulkan library"); | 15 | LOG_DEBUG(Render_Vulkan, "Looking for a Vulkan library"); |
| 15 | Common::DynamicLibrary library; | 16 | #ifdef ANDROID |
| 17 | // Android manages its Vulkan driver from the frontend. | ||
| 18 | return context->GetDriverLibrary(); | ||
| 19 | #else | ||
| 20 | auto library = std::make_shared<Common::DynamicLibrary>(); | ||
| 16 | #ifdef __APPLE__ | 21 | #ifdef __APPLE__ |
| 17 | // Check if a path to a specific Vulkan library has been specified. | 22 | // Check if a path to a specific Vulkan library has been specified. |
| 18 | char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); | 23 | char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); |
| 19 | if (!libvulkan_env || !library.Open(libvulkan_env)) { | 24 | if (!libvulkan_env || !library->Open(libvulkan_env)) { |
| 20 | // Use the libvulkan.dylib from the application bundle. | 25 | // Use the libvulkan.dylib from the application bundle. |
| 21 | const auto filename = | 26 | const auto filename = |
| 22 | Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.dylib"; | 27 | Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.dylib"; |
| 23 | void(library.Open(Common::FS::PathToUTF8String(filename).c_str())); | 28 | void(library->Open(Common::FS::PathToUTF8String(filename).c_str())); |
| 24 | } | 29 | } |
| 25 | #else | 30 | #else |
| 26 | std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); | 31 | std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); |
| 27 | LOG_DEBUG(Render_Vulkan, "Trying Vulkan library: {}", filename); | 32 | LOG_DEBUG(Render_Vulkan, "Trying Vulkan library: {}", filename); |
| 28 | if (!library.Open(filename.c_str())) { | 33 | if (!library->Open(filename.c_str())) { |
| 29 | // Android devices may not have libvulkan.so.1, only libvulkan.so. | 34 | // Android devices may not have libvulkan.so.1, only libvulkan.so. |
| 30 | filename = Common::DynamicLibrary::GetVersionedFilename("vulkan"); | 35 | filename = Common::DynamicLibrary::GetVersionedFilename("vulkan"); |
| 31 | LOG_DEBUG(Render_Vulkan, "Trying Vulkan library (second attempt): {}", filename); | 36 | LOG_DEBUG(Render_Vulkan, "Trying Vulkan library (second attempt): {}", filename); |
| 32 | void(library.Open(filename.c_str())); | 37 | void(library->Open(filename.c_str())); |
| 33 | } | 38 | } |
| 34 | #endif | 39 | #endif |
| 35 | return library; | 40 | return library; |
| 41 | #endif | ||
| 36 | } | 42 | } |
| 37 | 43 | ||
| 38 | } // namespace Vulkan | 44 | } // namespace Vulkan |
diff --git a/src/video_core/vulkan_common/vulkan_library.h b/src/video_core/vulkan_common/vulkan_library.h index 364ca979b..e1734525e 100644 --- a/src/video_core/vulkan_common/vulkan_library.h +++ b/src/video_core/vulkan_common/vulkan_library.h | |||
| @@ -3,10 +3,14 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | ||
| 7 | |||
| 6 | #include "common/dynamic_library.h" | 8 | #include "common/dynamic_library.h" |
| 9 | #include "core/frontend/graphics_context.h" | ||
| 7 | 10 | ||
| 8 | namespace Vulkan { | 11 | namespace Vulkan { |
| 9 | 12 | ||
| 10 | Common::DynamicLibrary OpenLibrary(); | 13 | std::shared_ptr<Common::DynamicLibrary> OpenLibrary( |
| 14 | [[maybe_unused]] Core::Frontend::GraphicsContext* context = nullptr); | ||
| 11 | 15 | ||
| 12 | } // namespace Vulkan | 16 | } // namespace Vulkan |