From e11526e23c780430997bd18a2f81e7d1a5316e97 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 16 Aug 2023 06:23:31 -0700 Subject: [PATCH] [vulkan] Don't free command buffers before destroying the pool. (#4059) Calling `vkDestroyCommandPool` automatically frees all command buffers allocated from that pool, so there is no need for `Device::destroy_command_encoder` to explicitly call `vkFreeCommandBuffers` on the `CommandEncoder`'s `free` and `discarded` lists. --- CHANGELOG.md | 4 ++++ wgpu-hal/src/vulkan/device.rs | 14 ++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f47fc075..2324e939b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,10 @@ By @Valaphee in [#3402](https://github.com/gfx-rs/wgpu/pull/3402) - Validate `DownlevelFlags::READ_ONLY_DEPTH_STENCIL`. By @teoxoy in [#4031](https://github.com/gfx-rs/wgpu/pull/4031) - Add validation in accordance with WebGPU `setViewport` valid usage for `x`, `y` and `this.[[attachment_size]]`. By @James2022-rgb in [#4058](https://github.com/gfx-rs/wgpu/pull/4058) +#### Vulkan + +- Don't bother calling `vkFreeCommandBuffers` when `vkDestroyCommandPool` will take care of that for us. By @jimblandy in [#4059](https://github.com/gfx-rs/wgpu/pull/4059) + ### Bug Fixes #### General diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index a69897a32..4f2a0feb8 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -1193,16 +1193,10 @@ impl crate::Device for super::Device { } unsafe fn destroy_command_encoder(&self, cmd_encoder: super::CommandEncoder) { unsafe { - if !cmd_encoder.free.is_empty() { - self.shared - .raw - .free_command_buffers(cmd_encoder.raw, &cmd_encoder.free) - } - if !cmd_encoder.discarded.is_empty() { - self.shared - .raw - .free_command_buffers(cmd_encoder.raw, &cmd_encoder.discarded) - } + // `vkDestroyCommandPool` also frees any command buffers allocated + // from that pool, so there's no need to explicitly call + // `vkFreeCommandBuffers` on `cmd_encoder`'s `free` and `discarded` + // fields. self.shared.raw.destroy_command_pool(cmd_encoder.raw, None); } }