diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 520c82545..8ec740d60 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -166,10 +166,6 @@ portable-atomic = ["dep:portable-atomic"] ### Internal Debugging Features ### ################################### -# Panic when running into an out-of-memory error (for debugging purposes). -# -# Only affects the d3d12 and vulkan backends. -oom_panic = [] # Panic when running into a device lost error (for debugging purposes). # Only affects the d3d12 and vulkan backends. device_lost_panic = [] diff --git a/wgpu-hal/src/auxil/dxgi/result.rs b/wgpu-hal/src/auxil/dxgi/result.rs index 61e3c6acf..23e1e0bea 100644 --- a/wgpu-hal/src/auxil/dxgi/result.rs +++ b/wgpu-hal/src/auxil/dxgi/result.rs @@ -1,32 +1,28 @@ -use windows::Win32::{Foundation, Graphics::Dxgi}; - -pub(crate) trait HResult { - fn into_device_result(self, description: &str) -> Result; -} -impl HResult for windows::core::Result { - fn into_device_result(self, description: &str) -> Result { - #![allow(unreachable_code)] - - self.map_err(|err| { - log::error!("{} failed: {}", description, err); - - match err.code() { - Foundation::E_OUTOFMEMORY => { - #[cfg(feature = "oom_panic")] - panic!("{description} failed: Out of memory"); - crate::DeviceError::OutOfMemory - } - Dxgi::DXGI_ERROR_DEVICE_RESET | Dxgi::DXGI_ERROR_DEVICE_REMOVED => { - #[cfg(feature = "device_lost_panic")] - panic!("{description} failed: Device lost ({err})"); - crate::DeviceError::Lost - } - _ => { - #[cfg(feature = "internal_error_panic")] - panic!("{description} failed: {err}"); - crate::DeviceError::Unexpected - } - } - }) - } -} +use windows::Win32::{Foundation, Graphics::Dxgi}; + +pub(crate) trait HResult { + fn into_device_result(self, description: &str) -> Result; +} +impl HResult for windows::core::Result { + fn into_device_result(self, description: &str) -> Result { + #![allow(unreachable_code)] + + self.map_err(|err| { + log::error!("{} failed: {}", description, err); + + match err.code() { + Foundation::E_OUTOFMEMORY => crate::DeviceError::OutOfMemory, + Dxgi::DXGI_ERROR_DEVICE_RESET | Dxgi::DXGI_ERROR_DEVICE_REMOVED => { + #[cfg(feature = "device_lost_panic")] + panic!("{description} failed: Device lost ({err})"); + crate::DeviceError::Lost + } + _ => { + #[cfg(feature = "internal_error_panic")] + panic!("{description} failed: {err}"); + crate::DeviceError::Unexpected + } + } + }) + } +} diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 4ba4a6c3d..f499b455e 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -1470,13 +1470,8 @@ fn get_unexpected_err(_err: vk::Result) -> crate::DeviceError { crate::DeviceError::Unexpected } -/// Returns [`crate::DeviceError::OutOfMemory`] or panics if the `oom_panic` -/// feature flag is enabled. +/// Returns [`crate::DeviceError::OutOfMemory`]. fn get_oom_err(_err: vk::Result) -> crate::DeviceError { - #[cfg(feature = "oom_panic")] - panic!("Out of memory ({_err:?})"); - - #[allow(unreachable_code)] crate::DeviceError::OutOfMemory }