diff --git a/CHANGELOG.md b/CHANGELOG.md index d6939c18c..e41b14006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ Naga now infers the correct binding layout when a resource appears only in an as #### General - Removed `MaintainBase` in favor of using `PollType`. By @waywardmonkeys in [#7508](https://github.com/gfx-rs/wgpu/pull/7508). +- wgpu-core no longer raises an error if `destroy` is called multiple times for a buffer or texture. This only affects the wgpu-core API; the wgpu API already allowed multiple `destroy` calls. By @andyleiserson in [#7686](https://github.com/gfx-rs/wgpu/pull/7686). #### Naga diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 9fc220ac5..00998b2ef 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -713,7 +713,8 @@ impl Buffer { let raw = match self.raw.snatch(&mut snatch_guard) { Some(raw) => raw, None => { - return Err(DestroyError::AlreadyDestroyed); + // Per spec, it is valid to call `destroy` multiple times. + return Ok(()); } }; @@ -1189,7 +1190,8 @@ impl Texture { return Ok(()); } None => { - return Err(DestroyError::AlreadyDestroyed); + // Per spec, it is valid to call `destroy` multiple times. + return Ok(()); } }; @@ -1953,8 +1955,6 @@ impl QuerySet { #[derive(Clone, Debug, Error)] #[non_exhaustive] pub enum DestroyError { - #[error("Resource is already destroyed")] - AlreadyDestroyed, #[error(transparent)] InvalidResource(#[from] InvalidResourceError), }