Skip to content

Commit

Permalink
Make BufferAccessError (de)serializable
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <[email protected]>
  • Loading branch information
sagudev authored and cwfitzgerald committed Jul 19, 2024
1 parent d03b7e2 commit fc87033
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ fn map_buffer<A: HalApi>(
}

#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
pub struct DeviceMismatch {
pub(super) res: ResourceErrorIdent,
pub(super) res_device: ResourceErrorIdent,
Expand All @@ -388,6 +390,8 @@ impl std::fmt::Display for DeviceMismatch {
impl std::error::Error for DeviceMismatch {}

#[derive(Clone, Debug, Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
#[non_exhaustive]
pub enum DeviceError {
#[error("{0} is invalid.")]
Expand Down
7 changes: 7 additions & 0 deletions wgpu-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl TrackingData {
}

#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ResourceErrorIdent {
r#type: &'static str,
label: String,
Expand Down Expand Up @@ -341,6 +342,8 @@ pub struct BufferMapOperation {
}

#[derive(Clone, Debug, Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
#[non_exhaustive]
pub enum BufferAccessError {
#[error(transparent)]
Expand Down Expand Up @@ -389,6 +392,8 @@ pub enum BufferAccessError {
}

#[derive(Clone, Debug, Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
#[error("Usage flags {actual:?} of {res} do not contain required usage flags {expected:?}")]
pub struct MissingBufferUsageError {
pub(crate) res: ResourceErrorIdent,
Expand All @@ -405,6 +410,8 @@ pub struct MissingTextureUsageError {
}

#[derive(Clone, Debug, Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
#[error("{0} has been destroyed")]
pub struct DestroyedResourceError(pub ResourceErrorIdent);

Expand Down

0 comments on commit fc87033

Please sign in to comment.