@@ -322,7 +322,7 @@ impl gpu_alloc::MemoryDevice<vk::DeviceMemory> for super::DeviceShared {
322
322
Err ( vk:: Result :: ERROR_OUT_OF_HOST_MEMORY ) => {
323
323
Err ( gpu_alloc:: OutOfMemory :: OutOfHostMemory )
324
324
}
325
- Err ( err) => panic ! ( "Unexpected Vulkan error: `{ err}`" ) ,
325
+ Err ( err) => handle_unexpected ( err) ,
326
326
}
327
327
}
328
328
@@ -351,7 +351,7 @@ impl gpu_alloc::MemoryDevice<vk::DeviceMemory> for super::DeviceShared {
351
351
Err ( gpu_alloc:: DeviceMapError :: OutOfHostMemory )
352
352
}
353
353
Err ( vk:: Result :: ERROR_MEMORY_MAP_FAILED ) => Err ( gpu_alloc:: DeviceMapError :: MapFailed ) ,
354
- Err ( err) => panic ! ( "Unexpected Vulkan error: `{ err}`" ) ,
354
+ Err ( err) => handle_unexpected ( err) ,
355
355
}
356
356
}
357
357
@@ -450,10 +450,7 @@ impl
450
450
Err ( vk:: Result :: ERROR_FRAGMENTATION ) => {
451
451
Err ( gpu_descriptor:: CreatePoolError :: Fragmentation )
452
452
}
453
- Err ( other) => {
454
- log:: error!( "create_descriptor_pool: {:?}" , other) ;
455
- Err ( gpu_descriptor:: CreatePoolError :: OutOfHostMemory )
456
- }
453
+ Err ( err) => handle_unexpected ( err) ,
457
454
}
458
455
}
459
456
@@ -494,10 +491,7 @@ impl
494
491
Err ( vk:: Result :: ERROR_FRAGMENTED_POOL ) => {
495
492
Err ( gpu_descriptor:: DeviceAllocationError :: FragmentedPool )
496
493
}
497
- Err ( other) => {
498
- log:: error!( "allocate_descriptor_sets: {:?}" , other) ;
499
- Err ( gpu_descriptor:: DeviceAllocationError :: OutOfHostMemory )
500
- }
494
+ Err ( err) => handle_unexpected ( err) ,
501
495
}
502
496
}
503
497
514
508
} ;
515
509
match result {
516
510
Ok ( ( ) ) => { }
517
- Err ( err) => log :: error! ( "free_descriptor_sets: {:?}" , err) ,
511
+ Err ( err) => handle_unexpected ( err) ,
518
512
}
519
513
}
520
514
}
@@ -2502,3 +2496,13 @@ impl From<gpu_descriptor::AllocationError> for crate::DeviceError {
2502
2496
}
2503
2497
}
2504
2498
}
2499
+
2500
+ /// We usually map unexpected vulkan errors to the [`crate::DeviceError::Lost`]
2501
+ /// variant to be more robust even in cases where the driver is not
2502
+ /// complying with the spec.
2503
+ ///
2504
+ /// However, we implement a few Trait methods that don't have an equivalent
2505
+ /// error variant. In those cases we use this function.
2506
+ fn handle_unexpected ( err : vk:: Result ) -> ! {
2507
+ panic ! ( "Unexpected Vulkan error: `{err}`" )
2508
+ }
0 commit comments