adding internal error filter (#5160)

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
This commit is contained in:
andristarrandErich Gubler authored and GitHub committed 2024-01-29 14:50:35 -05:00
1 parent 950d765a4d
commit 8afb441ca7
5 files changed
+23

No files matched your search

+1
View File
@@ -6915,6 +6915,7 @@ webidl.converters["GPUErrorFilter"] = webidl.createEnumConverter(
[
"out-of-memory",
"validation",
"internal"
],
);
+1
View File
@@ -1176,6 +1176,7 @@ interface GPUOutOfMemoryError
enum GPUErrorFilter {
"validation",
"out-of-memory",
"internal"
};
partial interface GPUDevice {
+1
View File
@@ -2009,6 +2009,7 @@ impl crate::context::Context for ContextWebGpu {
device_data.0.push_error_scope(match filter {
crate::ErrorFilter::OutOfMemory => web_sys::GpuErrorFilter::OutOfMemory,
crate::ErrorFilter::Validation => web_sys::GpuErrorFilter::Validation,
crate::ErrorFilter::Internal => web_sys::GpuErrorFilter::Internal,
});
}
+1
View File
@@ -2959,6 +2959,7 @@ impl ErrorSinkRaw {
let filter = match err {
crate::Error::OutOfMemory { .. } => crate::ErrorFilter::OutOfMemory,
crate::Error::Validation { .. } => crate::ErrorFilter::Validation,
crate::Error::Internal { .. } => crate::ErrorFilter::Internal,
};
match self
.scopes
+19
View File
@@ -163,6 +163,8 @@ pub enum ErrorFilter {
OutOfMemory,
/// Catch only validation errors.
Validation,
/// Catch only internal errors.
Internal,
}
static_assertions::assert_impl_all!(ErrorFilter: Send, Sync);
@@ -5143,6 +5145,21 @@ pub enum Error {
/// Description of the validation error.
description: String,
},
/// Internal error. Used for signalling any failures not explicitly expected by WebGPU.
///
/// These could be due to internal implementation or system limits being reached.
Internal {
/// Lower level source of the error.
#[cfg(send_sync)]
#[cfg_attr(docsrs, doc(cfg(all())))]
source: Box<dyn error::Error + Send + 'static>,
/// Lower level source of the error.
#[cfg(not(send_sync))]
#[cfg_attr(docsrs, doc(cfg(all())))]
source: Box<dyn error::Error + 'static>,
/// Description of the internal GPU error.
description: String,
},
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(Error: Send);
@@ -5152,6 +5169,7 @@ impl error::Error for Error {
match self {
Error::OutOfMemory { source } => Some(source.as_ref()),
Error::Validation { source, .. } => Some(source.as_ref()),
Error::Internal { source, .. } => Some(source.as_ref()),
}
}
}
@@ -5161,6 +5179,7 @@ impl fmt::Display for Error {
match self {
Error::OutOfMemory { .. } => f.write_str("Out of Memory"),
Error::Validation { description, .. } => f.write_str(description),
Error::Internal { description, .. } => f.write_str(description),
}
}
}