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 // DXVK workaround, it creates the instance twice with different properties
if ext_names.contains(&VkString::new("VK_KHR_surface")) { if ext_names.contains(&VkString::new("VK_KHR_surface")) {
unsafe { unsafe {
let ins = match Instance::preinitialized( let panic_result =
match std::panic::catch_unwind(|| -> anyhow::Result<std::sync::Arc<Instance>> {
Instance::preinitialized(
*instance, *instance,
proc_addr, proc_addr,
&ext_names, &ext_names,
(*(*create_info).pApplicationInfo).apiVersion, (*(*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, Ok(ins) => ins,
Err(err) => { Err(err) => {
write_log!(format!("-> local instance creation failed: {:?}", err)); write_log!(format!("-> local instance creation failed: {:?}", err));