From 918fdc98b589a68f0955e8caaa3474663f368956 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 1 Jul 2025 17:50:42 +0200 Subject: [PATCH] remove `reason` from `ErrorType::DeviceLost` since it's always "unknown" and users should register the lost callback instead --- deno_webgpu/error.rs | 2 +- wgpu-core/src/device/mod.rs | 4 +--- wgpu-types/src/error.rs | 7 +------ wgpu-types/src/lib.rs | 3 +-- wgpu/src/backend/wgpu_core.rs | 2 +- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/deno_webgpu/error.rs b/deno_webgpu/error.rs index 6831d93aa..066b2a4e8 100644 --- a/deno_webgpu/error.rs +++ b/deno_webgpu/error.rs @@ -188,7 +188,7 @@ impl GPUError { fn from_webgpu(e: impl WebGpuError) -> Self { match e.webgpu_error_type() { ErrorType::Internal => GPUError::Internal, - ErrorType::DeviceLost { reason } => GPUError::Lost(reason.into()), + ErrorType::DeviceLost => GPUError::Lost(GPUDeviceLostReason::Unknown), // TODO: this variant should be ignored, register the lost callback instead. ErrorType::OutOfMemory => GPUError::OutOfMemory, ErrorType::Validation => GPUError::Validation(fmt_err(&e)), } diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 40b01b5b4..b062a22d4 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -347,9 +347,7 @@ impl WebGpuError for DeviceError { match self { DeviceError::DeviceMismatch(e) => e.webgpu_error_type(), Self::ResourceCreationFailed => ErrorType::OutOfMemory, - Self::Lost => ErrorType::DeviceLost { - reason: DeviceLostReason::Unknown, - }, + Self::Lost => ErrorType::DeviceLost, Self::OutOfMemory => ErrorType::OutOfMemory, } } diff --git a/wgpu-types/src/error.rs b/wgpu-types/src/error.rs index 33b2601ae..96cc7453a 100644 --- a/wgpu-types/src/error.rs +++ b/wgpu-types/src/error.rs @@ -1,8 +1,6 @@ //! Shared types for WebGPU errors. See also: //! -use crate::DeviceLostReason; - /// A classification of WebGPU error for implementers of the WebGPU API to use in their own error /// layer(s). /// @@ -30,10 +28,7 @@ pub enum ErrorType { /// property should be `resolve`d. /// /// [`GPUDevice.lost`]: https://www.w3.org/TR/webgpu/#dom-gpudevice-lost - DeviceLost { - /// The reason the device was lost. - reason: DeviceLostReason, - }, + DeviceLost, } /// A trait for querying the [`ErrorType`] classification of an error. diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index aa9b6a4d8..9330dc287 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -7743,8 +7743,7 @@ mod send_sync { impl WasmNotSync for T {} } -/// Corresponds to a [`GPUDeviceLostReason`]; usually seen by implementers of WebGPU with -/// [`error::ErrorType::DeviceLost::reason`]. +/// Corresponds to a [`GPUDeviceLostReason`]. /// /// [`GPUDeviceLostReason`]: https://www.w3.org/TR/webgpu/#enumdef-gpudevicelostreason #[repr(u8)] diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 98e52687f..6a86d44b2 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -335,7 +335,7 @@ impl ContextWgpuCore { description, } } - ErrorType::DeviceLost { reason: _ } => return, + ErrorType::DeviceLost => return, // will be surfaced via callback }; sink.handle_error(error); }