From e10e17907fc0b7f8a0ab164581969486cee02cd6 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 1 Jul 2025 18:01:52 +0200 Subject: [PATCH] remove `DeviceError::ResourceCreationFailed` --- wgpu-core/src/device/mod.rs | 6 +----- wgpu-core/src/device/queue.rs | 1 - wgpu-core/src/device/resource.rs | 1 - wgpu-hal/src/gles/adapter.rs | 2 +- wgpu-hal/src/lib.rs | 2 -- wgpu-hal/src/metal/device.rs | 4 ++-- wgpu-hal/src/vulkan/device.rs | 4 ++-- 7 files changed, 6 insertions(+), 14 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index b062a22d4..e9eda2721 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -336,8 +336,6 @@ pub enum DeviceError { Lost, #[error("Not enough memory left.")] OutOfMemory, - #[error("Creation of a resource failed for a reason other than running out of memory.")] - ResourceCreationFailed, #[error(transparent)] DeviceMismatch(#[from] Box), } @@ -345,8 +343,7 @@ pub enum DeviceError { impl WebGpuError for DeviceError { fn webgpu_error_type(&self) -> ErrorType { match self { - DeviceError::DeviceMismatch(e) => e.webgpu_error_type(), - Self::ResourceCreationFailed => ErrorType::OutOfMemory, + Self::DeviceMismatch(e) => e.webgpu_error_type(), Self::Lost => ErrorType::DeviceLost, Self::OutOfMemory => ErrorType::OutOfMemory, } @@ -361,7 +358,6 @@ impl DeviceError { match error { hal::DeviceError::Lost => Self::Lost, hal::DeviceError::OutOfMemory => Self::OutOfMemory, - hal::DeviceError::ResourceCreationFailed => Self::ResourceCreationFailed, hal::DeviceError::Unexpected => Self::Lost, } } diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 2b4fa1ef5..1a4849f3f 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -221,7 +221,6 @@ impl Drop for Queue { self.device.handle_hal_error(e); // will lose the device break; } - hal::DeviceError::ResourceCreationFailed => unreachable!(), hal::DeviceError::Unexpected => { panic!( "We ran into an unexpected error while waiting on the last successful submission to complete!" diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index ef044f2f9..f68b8d693 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -378,7 +378,6 @@ impl Device { match error { hal::DeviceError::OutOfMemory | hal::DeviceError::Lost - | hal::DeviceError::ResourceCreationFailed | hal::DeviceError::Unexpected => { self.lose(&error.to_string()); } diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index e97968f94..952ff0c91 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -996,7 +996,7 @@ impl crate::Adapter for super::Adapter { { Some(unsafe { Self::create_shader_clear_program(gl, self.shared.es) - .ok_or(crate::DeviceError::ResourceCreationFailed)? + .ok_or(crate::DeviceError::Lost)? }) } else { // If we don't need the workaround, don't waste time and resources compiling the clear program diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index c5d81b286..6f05edbb1 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -375,8 +375,6 @@ pub enum DeviceError { OutOfMemory, #[error("Device is 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)")] Unexpected, } diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index 6b3aeb3f9..ef8e7c83a 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -1463,7 +1463,7 @@ impl crate::Device for super::Device { Some(counter) => counter, None => { 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); @@ -1473,7 +1473,7 @@ impl crate::Device for super::Device { Ok(buffer) => buffer, Err(err) => { log::error!("Failed to create counter sample buffer: {:?}", err); - return Err(crate::DeviceError::ResourceCreationFailed); + return Err(crate::DeviceError::Unexpected); } }; diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index b6c8dba40..81f523929 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -752,7 +752,7 @@ impl super::Device { .contains(wgt::Features::VULKAN_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() @@ -780,7 +780,7 @@ impl super::Device { image.requirements.memory_type_bits, vk::MemoryPropertyFlags::DEVICE_LOCAL, ) - .ok_or(crate::DeviceError::ResourceCreationFailed)?; + .ok_or(crate::DeviceError::Unexpected)?; let memory_allocate_info = vk::MemoryAllocateInfo::default() .allocation_size(image.requirements.size)