remove reason from ErrorType::DeviceLost since it's always "unknown" and users should register the lost callback instead

This commit is contained in:
teoxoy 2025-07-01 17:50:42 +02:00 committed by Teodor Tanasoaia
parent 25d75e2a02
commit 918fdc98b5
5 changed files with 5 additions and 13 deletions

View File

@ -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)),
}

View File

@ -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,
}
}

View File

@ -1,8 +1,6 @@
//! Shared types for WebGPU errors. See also:
//! <https://gpuweb.github.io/gpuweb/#errors-and-debugging>
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.

View File

@ -7743,8 +7743,7 @@ mod send_sync {
impl<T> 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)]

View File

@ -335,7 +335,7 @@ impl ContextWgpuCore {
description,
}
}
ErrorType::DeviceLost { reason: _ } => return,
ErrorType::DeviceLost => return, // will be surfaced via callback
};
sink.handle_error(error);
}