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(); ~DynamicLibrary();
/// Returns true if the library is loaded, otherwise false. /// Returns true if the library is loaded, otherwise false.
[[nodiscard]] bool IsLoaded() { [[nodiscard]] bool IsLoaded() const noexcept {
return handle != nullptr; 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); 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]; return blend_equation_table[index];
} }

View file

@ -277,6 +277,10 @@ vk::InstanceCreateFlags GetInstanceFlags() {
vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library, vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library,
Frontend::WindowSystemType window_type, bool enable_validation, Frontend::WindowSystemType window_type, bool enable_validation,
bool dump_command_buffers) { bool dump_command_buffers) {
if (!library.IsLoaded()) {
throw std::runtime_error("Failed to load Vulkan driver library");
}
const auto vkGetInstanceProcAddr = const auto vkGetInstanceProcAddr =
library.GetSymbol<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr"); library.GetSymbol<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
if (!vkGetInstanceProcAddr) { if (!vkGetInstanceProcAddr) {