Skip to content

Commit

Permalink
Panic less in initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Jul 11, 2024
1 parent 6e21035 commit a477c20
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions blade-graphics/src/vulkan/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,14 @@ impl super::Context {
}
};

let vk_surface = surface_handles.map(|(wh, dh)| {
ash_window::create_surface(&entry, &core_instance, dh.as_raw(), wh.as_raw(), None)
.unwrap()
});
let vk_surface = if let Some((wh, dh)) = surface_handles {
Some(
ash_window::create_surface(&entry, &core_instance, dh.as_raw(), wh.as_raw(), None)
.map_err(|e| NotSupportedError::VulkanError(e))?,
)
} else {
None
};

let instance =
super::Instance {
Expand All @@ -381,7 +385,10 @@ impl super::Context {
core: core_instance,
};

let physical_devices = instance.core.enumerate_physical_devices().unwrap();
let physical_devices = instance
.core
.enumerate_physical_devices()
.map_err(|e| NotSupportedError::VulkanError(e))?;
let (physical_device, capabilities) = physical_devices
.into_iter()
.find_map(|phd| {
Expand Down

0 comments on commit a477c20

Please sign in to comment.