From d189cf27e86dc934f6d22622b6fde8f4a8593583 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Wed, 14 Feb 2024 14:14:35 -0500 Subject: [PATCH] fix: discard cmd. enc. buf. on `wgpu_core::Global::command_encoder_drop` --- CHANGELOG.md | 8 ++++++++ wgpu-core/src/command/mod.rs | 4 ++-- wgpu-core/src/device/global.rs | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94b50b45a..48cba0606 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 784d158bc..e517f572e 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 9d9fdf3c2..334c37054 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);