remove DeviceError::ResourceCreationFailed

This commit is contained in:
teoxoy 2025-07-01 18:01:52 +02:00 committed by Teodor Tanasoaia
parent 918fdc98b5
commit e10e17907f
7 changed files with 6 additions and 14 deletions

View File

@ -336,8 +336,6 @@ pub enum DeviceError {
Lost, Lost,
#[error("Not enough memory left.")] #[error("Not enough memory left.")]
OutOfMemory, OutOfMemory,
#[error("Creation of a resource failed for a reason other than running out of memory.")]
ResourceCreationFailed,
#[error(transparent)] #[error(transparent)]
DeviceMismatch(#[from] Box<DeviceMismatch>), DeviceMismatch(#[from] Box<DeviceMismatch>),
} }
@ -345,8 +343,7 @@ pub enum DeviceError {
impl WebGpuError for DeviceError { impl WebGpuError for DeviceError {
fn webgpu_error_type(&self) -> ErrorType { fn webgpu_error_type(&self) -> ErrorType {
match self { match self {
DeviceError::DeviceMismatch(e) => e.webgpu_error_type(), Self::DeviceMismatch(e) => e.webgpu_error_type(),
Self::ResourceCreationFailed => ErrorType::OutOfMemory,
Self::Lost => ErrorType::DeviceLost, Self::Lost => ErrorType::DeviceLost,
Self::OutOfMemory => ErrorType::OutOfMemory, Self::OutOfMemory => ErrorType::OutOfMemory,
} }
@ -361,7 +358,6 @@ impl DeviceError {
match error { match error {
hal::DeviceError::Lost => Self::Lost, hal::DeviceError::Lost => Self::Lost,
hal::DeviceError::OutOfMemory => Self::OutOfMemory, hal::DeviceError::OutOfMemory => Self::OutOfMemory,
hal::DeviceError::ResourceCreationFailed => Self::ResourceCreationFailed,
hal::DeviceError::Unexpected => Self::Lost, hal::DeviceError::Unexpected => Self::Lost,
} }
} }

View File

@ -221,7 +221,6 @@ impl Drop for Queue {
self.device.handle_hal_error(e); // will lose the device self.device.handle_hal_error(e); // will lose the device
break; break;
} }
hal::DeviceError::ResourceCreationFailed => unreachable!(),
hal::DeviceError::Unexpected => { hal::DeviceError::Unexpected => {
panic!( panic!(
"We ran into an unexpected error while waiting on the last successful submission to complete!" "We ran into an unexpected error while waiting on the last successful submission to complete!"

View File

@ -378,7 +378,6 @@ impl Device {
match error { match error {
hal::DeviceError::OutOfMemory hal::DeviceError::OutOfMemory
| hal::DeviceError::Lost | hal::DeviceError::Lost
| hal::DeviceError::ResourceCreationFailed
| hal::DeviceError::Unexpected => { | hal::DeviceError::Unexpected => {
self.lose(&error.to_string()); self.lose(&error.to_string());
} }

View File

@ -996,7 +996,7 @@ impl crate::Adapter for super::Adapter {
{ {
Some(unsafe { Some(unsafe {
Self::create_shader_clear_program(gl, self.shared.es) Self::create_shader_clear_program(gl, self.shared.es)
.ok_or(crate::DeviceError::ResourceCreationFailed)? .ok_or(crate::DeviceError::Lost)?
}) })
} else { } else {
// If we don't need the workaround, don't waste time and resources compiling the clear program // If we don't need the workaround, don't waste time and resources compiling the clear program

View File

@ -375,8 +375,6 @@ pub enum DeviceError {
OutOfMemory, OutOfMemory,
#[error("Device is lost")] #[error("Device is lost")]
Lost, 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)")] #[error("Unexpected error variant (driver implementation is at fault)")]
Unexpected, Unexpected,
} }

View File

@ -1463,7 +1463,7 @@ impl crate::Device for super::Device {
Some(counter) => counter, Some(counter) => counter,
None => { None => {
log::error!("Failed to obtain timestamp counter set."); log::error!("Failed to obtain timestamp counter set.");
return Err(crate::DeviceError::ResourceCreationFailed); return Err(crate::DeviceError::Unexpected);
} }
}; };
csb_desc.set_counter_set(timestamp_counter); csb_desc.set_counter_set(timestamp_counter);
@ -1473,7 +1473,7 @@ impl crate::Device for super::Device {
Ok(buffer) => buffer, Ok(buffer) => buffer,
Err(err) => { Err(err) => {
log::error!("Failed to create counter sample buffer: {:?}", err); log::error!("Failed to create counter sample buffer: {:?}", err);
return Err(crate::DeviceError::ResourceCreationFailed); return Err(crate::DeviceError::Unexpected);
} }
}; };

View File

@ -752,7 +752,7 @@ impl super::Device {
.contains(wgt::Features::VULKAN_EXTERNAL_MEMORY_WIN32) .contains(wgt::Features::VULKAN_EXTERNAL_MEMORY_WIN32)
{ {
log::error!("Vulkan driver does not support VK_KHR_external_memory_win32"); log::error!("Vulkan driver does not support VK_KHR_external_memory_win32");
return Err(crate::DeviceError::ResourceCreationFailed); return Err(crate::DeviceError::Unexpected);
} }
let mut external_memory_image_info = vk::ExternalMemoryImageCreateInfo::default() let mut external_memory_image_info = vk::ExternalMemoryImageCreateInfo::default()
@ -780,7 +780,7 @@ impl super::Device {
image.requirements.memory_type_bits, image.requirements.memory_type_bits,
vk::MemoryPropertyFlags::DEVICE_LOCAL, vk::MemoryPropertyFlags::DEVICE_LOCAL,
) )
.ok_or(crate::DeviceError::ResourceCreationFailed)?; .ok_or(crate::DeviceError::Unexpected)?;
let memory_allocate_info = vk::MemoryAllocateInfo::default() let memory_allocate_info = vk::MemoryAllocateInfo::default()
.allocation_size(image.requirements.size) .allocation_size(image.requirements.size)