Catch panic from Instance::preinitialized

This commit is contained in:
hodasemi 2023-01-21 12:54:30 +01:00
parent ea8b6fd734
commit 4697105fbc

View file

@ -165,12 +165,26 @@ pub(crate) extern "system" fn create_instance(
// DXVK workaround, it creates the instance twice with different properties
if ext_names.contains(&VkString::new("VK_KHR_surface")) {
unsafe {
let ins = match Instance::preinitialized(
*instance,
proc_addr,
&ext_names,
(*(*create_info).pApplicationInfo).apiVersion,
) {
let panic_result =
match std::panic::catch_unwind(|| -> anyhow::Result<std::sync::Arc<Instance>> {
Instance::preinitialized(
*instance,
proc_addr,
&ext_names,
(*(*create_info).pApplicationInfo).apiVersion,
)
}) {
Ok(panic_ok) => panic_ok,
Err(err) => {
write_log!(format!(
"catched a panic from Instance::preinitialized: {:?}",
err
));
return VK_ERROR_INITIALIZATION_FAILED;
}
};
let ins = match panic_result {
Ok(ins) => ins,
Err(err) => {
write_log!(format!("-> local instance creation failed: {:?}", err));