Skip to content

Commit 0dc6bfd

Browse files
Don't raise AlreadyDestroyed error on repeated destroy() calls (#7686)
* Don't raise `AlreadyDestroyed` error on repeated `destroy()` calls * Add changelog entry
1 parent f04391d commit 0dc6bfd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Naga now infers the correct binding layout when a resource appears only in an as
8080
#### General
8181

8282
- Removed `MaintainBase` in favor of using `PollType`. By @waywardmonkeys in [#7508](https://github.com/gfx-rs/wgpu/pull/7508).
83+
- 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).
8384

8485
#### Naga
8586

wgpu-core/src/resource.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ impl Buffer {
713713
let raw = match self.raw.snatch(&mut snatch_guard) {
714714
Some(raw) => raw,
715715
None => {
716-
return Err(DestroyError::AlreadyDestroyed);
716+
// Per spec, it is valid to call `destroy` multiple times.
717+
return Ok(());
717718
}
718719
};
719720

@@ -1189,7 +1190,8 @@ impl Texture {
11891190
return Ok(());
11901191
}
11911192
None => {
1192-
return Err(DestroyError::AlreadyDestroyed);
1193+
// Per spec, it is valid to call `destroy` multiple times.
1194+
return Ok(());
11931195
}
11941196
};
11951197

@@ -1953,8 +1955,6 @@ impl QuerySet {
19531955
#[derive(Clone, Debug, Error)]
19541956
#[non_exhaustive]
19551957
pub enum DestroyError {
1956-
#[error("Resource is already destroyed")]
1957-
AlreadyDestroyed,
19581958
#[error(transparent)]
19591959
InvalidResource(#[from] InvalidResourceError),
19601960
}

0 commit comments

Comments
 (0)