Don't raise AlreadyDestroyed error on repeated destroy() calls (#7686)

* Don't raise `AlreadyDestroyed` error on repeated `destroy()` calls

* Add changelog entry
This commit is contained in:
Andy Leiserson 2025-05-13 03:10:48 -04:00 committed by GitHub
parent f04391d916
commit 0dc6bfdd67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

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

View File

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