add an Unexpected variant to DeviceError

This commit is contained in:
teoxoy 2024-08-15 10:25:36 +01:00 committed by Teodor Tanasoaia
parent 24134e049f
commit 2c31414517
5 changed files with 7 additions and 3 deletions

View File

@ -404,6 +404,7 @@ impl From<hal::DeviceError> for DeviceError {
hal::DeviceError::Lost => DeviceError::Lost,
hal::DeviceError::OutOfMemory => DeviceError::OutOfMemory,
hal::DeviceError::ResourceCreationFailed => DeviceError::ResourceCreationFailed,
hal::DeviceError::Unexpected => DeviceError::Lost,
}
}
}

View File

@ -342,6 +342,7 @@ impl Adapter {
hal::DeviceError::Lost => RequestDeviceError::DeviceLost,
hal::DeviceError::OutOfMemory => RequestDeviceError::OutOfMemory,
hal::DeviceError::ResourceCreationFailed => RequestDeviceError::Internal,
hal::DeviceError::Unexpected => RequestDeviceError::DeviceLost,
})?;
self.create_device_and_queue_from_hal(open, desc, instance_flags, trace_path)

View File

@ -314,6 +314,8 @@ pub enum DeviceError {
Lost,
#[error("Creation of a resource failed for a reason other than running out of memory.")]
ResourceCreationFailed,
#[error("Unexpected error variant (driver implementation is at fault)")]
Unexpected,
}
#[derive(Clone, Debug, Eq, PartialEq, Error)]

View File

@ -2559,7 +2559,7 @@ impl From<gpu_descriptor::AllocationError> for crate::DeviceError {
}
}
/// We usually map unexpected vulkan errors to the [`crate::DeviceError::Lost`]
/// We usually map unexpected vulkan errors to the [`crate::DeviceError::Unexpected`]
/// variant to be more robust even in cases where the driver is not
/// complying with the spec.
///

View File

@ -1266,14 +1266,14 @@ fn map_pipeline_err(err: vk::Result) -> crate::DeviceError {
map_host_device_oom_err(err)
}
/// Returns [`crate::DeviceError::Lost`] or panics if the `internal_error_panic`
/// Returns [`crate::DeviceError::Unexpected`] or panics if the `internal_error_panic`
/// feature flag is enabled.
fn get_unexpected_err(_err: vk::Result) -> crate::DeviceError {
#[cfg(feature = "internal_error_panic")]
panic!("Unexpected Vulkan error: {_err:?}");
#[allow(unreachable_code)]
crate::DeviceError::Lost
crate::DeviceError::Unexpected
}
/// Returns [`crate::DeviceError::OutOfMemory`] or panics if the `oom_panic`