renderer_vulkan: Misc fixes (#6974)

* vk_platform: Check if library was loaded

* pica_to_vk: Dont crash on unknow blend equation
This commit is contained in:
GPUCode 2023-09-15 00:21:12 +03:00 committed by GitHub
parent ee3eab5054
commit 30fcdc5474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -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;
}

View File

@ -77,7 +77,12 @@ inline vk::BlendOp BlendEquation(Pica::FramebufferRegs::BlendEquation equation)
}};
const auto index = static_cast<std::size_t>(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];
}

View File

@ -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<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
if (!vkGetInstanceProcAddr) {