From 6fdb2a16f2994b5b8cc72e285c81d7edaf3795ff Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 12 Nov 2024 20:20:09 +0100 Subject: [PATCH] destroy subsequent command buffers if we encountered an error at submission This gets the `wgpu_test::ray_tracing::as_build::out_of_order_as_build` test to pass. This seems to be an issue even on trunk, looking at the nr of calls to `create_command_encoder` & `destroy_command_encoder` in hal, they are not equal. So, I'm not sure why the validation layers don't raise the `VUID-vkDestroyDevice-device-05137`. There is still an issue with previous command buffers being leaked but I will fix this in a follow-up. --- wgpu-core/src/device/queue.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index fe53fb6521..370880a931 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -1209,6 +1209,13 @@ impl Queue { } } + if first_error.is_some() { + if let Ok(cmd_buf_data) = cmd_buf_data { + cmd_buf_data.destroy(&command_buffer.device); + } + continue; + } + let mut baked = match cmd_buf_data { Ok(cmd_buf_data) => { let res = validate_command_buffer( @@ -1232,10 +1239,6 @@ impl Queue { } }; - if first_error.is_some() { - continue; - } - // execute resource transitions if let Err(e) = unsafe { baked.encoder.begin_encoding(hal_label(