diff --git a/CHANGELOG.md b/CHANGELOG.md index 94b50b45a9..48cba06066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,14 @@ Bottom level categories: - `tan` - `tanh` +## v0.19.3 (2024-03-01) + +### Bug Fixes + +#### General + +- Fix an issue where command encoders weren't properly freed if an error occurred during command encoding. By @ErichDonGubler in [#5251](https://github.com/gfx-rs/wgpu/pull/5251). + ## v0.19.2 (2024-02-29) ### Added/New Features diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 784d158bce..e517f572e1 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -78,7 +78,7 @@ impl CommandEncoder { Ok(()) } - fn discard(&mut self) { + pub(crate) fn discard(&mut self) { if self.is_open { self.is_open = false; unsafe { self.raw.discard_encoding() }; @@ -115,7 +115,7 @@ pub(crate) struct DestroyedBufferError(pub id::BufferId); pub(crate) struct DestroyedTextureError(pub id::TextureId); pub struct CommandBufferMutable { - encoder: CommandEncoder, + pub(crate) encoder: CommandEncoder, status: CommandEncoderStatus, pub(crate) trackers: Tracker, buffer_memory_init_actions: Vec>, diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 9d9fdf3c27..334c370544 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -1354,6 +1354,8 @@ impl Global { let hub = A::hub(self); if let Some(cmd_buf) = hub.command_buffers.unregister(command_encoder_id) { + cmd_buf.data.lock().as_mut().unwrap().encoder.discard(); + cmd_buf .device .untrack(&cmd_buf.data.lock().as_ref().unwrap().trackers);