diff --git a/CHANGELOG.md b/CHANGELOG.md index ffc4f4bff2..1fc326c30c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -154,6 +154,7 @@ By @atlv24 in [#5383](https://github.com/gfx-rs/wgpu/pull/5383) - Ensure render pipelines have at least 1 target. By @ErichDonGubler in [#5715](https://github.com/gfx-rs/wgpu/pull/5715) - `wgpu::ComputePass` now internally takes ownership of `QuerySet` for both `wgpu::ComputePassTimestampWrites` as well as timestamp writes and statistics query, fixing crashes when destroying `QuerySet` before ending the pass. By @wumpf in [#5671](https://github.com/gfx-rs/wgpu/pull/5671) - Validate resources passed during compute pass recording for mismatching device. By @wumpf in [#5779](https://github.com/gfx-rs/wgpu/pull/5779) +- Fix a `CommandBuffer` leak. By @cwfitzgerald and @nical in [#5141](https://github.com/gfx-rs/wgpu/pull/5141) #### DX12 diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 4553dc03c2..1f63f766b3 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -2326,10 +2326,17 @@ impl crate::Context for ContextWgpuCore { .map(|(i, _)| i) .collect::>(); - match wgc::gfx_select!(*queue => self.0.queue_submit(*queue, &temp_command_buffers)) { + let index = match wgc::gfx_select!(*queue => self.0.queue_submit(*queue, &temp_command_buffers)) + { Ok(index) => index, Err(err) => self.handle_error_fatal(err, "Queue::submit"), + }; + + for cmdbuf in &temp_command_buffers { + wgc::gfx_select!(*queue => self.0.command_buffer_drop(*cmdbuf)); } + + index } fn queue_get_timestamp_period(