mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
adding internal error filter (#5160)
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
This commit is contained in:
parent
950d765a4d
commit
8afb441ca7
@ -6915,6 +6915,7 @@ webidl.converters["GPUErrorFilter"] = webidl.createEnumConverter(
|
|||||||
[
|
[
|
||||||
"out-of-memory",
|
"out-of-memory",
|
||||||
"validation",
|
"validation",
|
||||||
|
"internal"
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -1176,6 +1176,7 @@ interface GPUOutOfMemoryError
|
|||||||
enum GPUErrorFilter {
|
enum GPUErrorFilter {
|
||||||
"validation",
|
"validation",
|
||||||
"out-of-memory",
|
"out-of-memory",
|
||||||
|
"internal"
|
||||||
};
|
};
|
||||||
|
|
||||||
partial interface GPUDevice {
|
partial interface GPUDevice {
|
||||||
|
|||||||
@ -2009,6 +2009,7 @@ impl crate::context::Context for ContextWebGpu {
|
|||||||
device_data.0.push_error_scope(match filter {
|
device_data.0.push_error_scope(match filter {
|
||||||
crate::ErrorFilter::OutOfMemory => web_sys::GpuErrorFilter::OutOfMemory,
|
crate::ErrorFilter::OutOfMemory => web_sys::GpuErrorFilter::OutOfMemory,
|
||||||
crate::ErrorFilter::Validation => web_sys::GpuErrorFilter::Validation,
|
crate::ErrorFilter::Validation => web_sys::GpuErrorFilter::Validation,
|
||||||
|
crate::ErrorFilter::Internal => web_sys::GpuErrorFilter::Internal,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2959,6 +2959,7 @@ impl ErrorSinkRaw {
|
|||||||
let filter = match err {
|
let filter = match err {
|
||||||
crate::Error::OutOfMemory { .. } => crate::ErrorFilter::OutOfMemory,
|
crate::Error::OutOfMemory { .. } => crate::ErrorFilter::OutOfMemory,
|
||||||
crate::Error::Validation { .. } => crate::ErrorFilter::Validation,
|
crate::Error::Validation { .. } => crate::ErrorFilter::Validation,
|
||||||
|
crate::Error::Internal { .. } => crate::ErrorFilter::Internal,
|
||||||
};
|
};
|
||||||
match self
|
match self
|
||||||
.scopes
|
.scopes
|
||||||
|
|||||||
@ -163,6 +163,8 @@ pub enum ErrorFilter {
|
|||||||
OutOfMemory,
|
OutOfMemory,
|
||||||
/// Catch only validation errors.
|
/// Catch only validation errors.
|
||||||
Validation,
|
Validation,
|
||||||
|
/// Catch only internal errors.
|
||||||
|
Internal,
|
||||||
}
|
}
|
||||||
static_assertions::assert_impl_all!(ErrorFilter: Send, Sync);
|
static_assertions::assert_impl_all!(ErrorFilter: Send, Sync);
|
||||||
|
|
||||||
@ -5143,6 +5145,21 @@ pub enum Error {
|
|||||||
/// Description of the validation error.
|
/// Description of the validation error.
|
||||||
description: String,
|
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)]
|
#[cfg(send_sync)]
|
||||||
static_assertions::assert_impl_all!(Error: Send);
|
static_assertions::assert_impl_all!(Error: Send);
|
||||||
@ -5152,6 +5169,7 @@ impl error::Error for Error {
|
|||||||
match self {
|
match self {
|
||||||
Error::OutOfMemory { source } => Some(source.as_ref()),
|
Error::OutOfMemory { source } => Some(source.as_ref()),
|
||||||
Error::Validation { 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 {
|
match self {
|
||||||
Error::OutOfMemory { .. } => f.write_str("Out of Memory"),
|
Error::OutOfMemory { .. } => f.write_str("Out of Memory"),
|
||||||
Error::Validation { description, .. } => f.write_str(description),
|
Error::Validation { description, .. } => f.write_str(description),
|
||||||
|
Error::Internal { description, .. } => f.write_str(description),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user