Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/wgpu-hal/src/auxil/dxgi/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  result.rs   Sprache: unbekannt

 
use windows::Win32::{Foundation, Graphics::Dxgi};

pub(crate) trait HResult<O> {
    fn into_device_result(self, description: &str) -> Result<O, crate::DeviceError>;
}
impl<T> HResult<T> for windows::core::Result<T> {
    fn into_device_result(self, description: &str) -> Result<T, crate::DeviceError> {
        #![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
                }
            }
        })
    }
}

[ Dauer der Verarbeitung: 0.2 Sekunden  (vorverarbeitet)  ]