From 30fcdc54743de640f0250d8528839e2714cd58f9 Mon Sep 17 00:00:00 2001 From: GPUCode <47210458+GPUCode@users.noreply.github.com> Date: Fri, 15 Sep 2023 00:21:12 +0300 Subject: [PATCH] renderer_vulkan: Misc fixes (#6974) * vk_platform: Check if library was loaded * pica_to_vk: Dont crash on unknow blend equation --- src/common/dynamic_library/dynamic_library.h | 2 +- src/video_core/renderer_vulkan/pica_to_vk.h | 7 ++++++- src/video_core/renderer_vulkan/vk_platform.cpp | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/dynamic_library/dynamic_library.h b/src/common/dynamic_library/dynamic_library.h index 9a0c2083f..143b85f1d 100644 --- a/src/common/dynamic_library/dynamic_library.h +++ b/src/common/dynamic_library/dynamic_library.h @@ -16,7 +16,7 @@ public: ~DynamicLibrary(); /// Returns true if the library is loaded, otherwise false. - [[nodiscard]] bool IsLoaded() { + [[nodiscard]] bool IsLoaded() const noexcept { return handle != nullptr; } diff --git a/src/video_core/renderer_vulkan/pica_to_vk.h b/src/video_core/renderer_vulkan/pica_to_vk.h index 96776ce70..c591df08e 100644 --- a/src/video_core/renderer_vulkan/pica_to_vk.h +++ b/src/video_core/renderer_vulkan/pica_to_vk.h @@ -77,7 +77,12 @@ inline vk::BlendOp BlendEquation(Pica::FramebufferRegs::BlendEquation equation) }}; const auto index = static_cast(equation); - ASSERT_MSG(index < blend_equation_table.size(), "Unknown blend equation {}", index); + if (index >= blend_equation_table.size()) { + LOG_CRITICAL(Render_Vulkan, "Unknown blend equation {}", index); + + // This return value is hwtested, not just a stub + return vk::BlendOp::eAdd; + } return blend_equation_table[index]; } diff --git a/src/video_core/renderer_vulkan/vk_platform.cpp b/src/video_core/renderer_vulkan/vk_platform.cpp index 7b4c6e230..46390889a 100644 --- a/src/video_core/renderer_vulkan/vk_platform.cpp +++ b/src/video_core/renderer_vulkan/vk_platform.cpp @@ -277,6 +277,10 @@ vk::InstanceCreateFlags GetInstanceFlags() { vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library, Frontend::WindowSystemType window_type, bool enable_validation, bool dump_command_buffers) { + if (!library.IsLoaded()) { + throw std::runtime_error("Failed to load Vulkan driver library"); + } + const auto vkGetInstanceProcAddr = library.GetSymbol("vkGetInstanceProcAddr"); if (!vkGetInstanceProcAddr) {