From a29a8fcf6e293d3e667e4d03fc9965e8b9778986 Mon Sep 17 00:00:00 2001 From: sotaroikeda Date: Wed, 8 Apr 2026 16:50:40 +0900 Subject: [PATCH] Add Queue::remove_signal_semaphore() (#9388) --- wgpu-hal/src/vulkan/mod.rs | 8 ++++++++ wgpu-hal/src/vulkan/semaphore_list.rs | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 2fbb62989..b53497606 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -1378,6 +1378,14 @@ impl Queue { guard.push_signal(SemaphoreType::Binary(semaphore)); } } + + /// Remove `semaphore` from the pending signal list if it is still present. + /// + /// Returns `true` if the semaphore was found and removed. If the submit + /// already consumed it, this is a harmless no-op that returns `false`. + pub fn remove_signal_semaphore(&self, semaphore: vk::Semaphore) -> bool { + self.signal_semaphores.lock().remove(semaphore) + } } /// Maps diff --git a/wgpu-hal/src/vulkan/semaphore_list.rs b/wgpu-hal/src/vulkan/semaphore_list.rs index 91e031008..045bfe845 100644 --- a/wgpu-hal/src/vulkan/semaphore_list.rs +++ b/wgpu-hal/src/vulkan/semaphore_list.rs @@ -147,6 +147,29 @@ impl SemaphoreList { self.check(); } + /// Remove all entries matching `semaphore` from the list. Returns `true` + /// if anything was removed. + pub fn remove(&mut self, semaphore: vk::Semaphore) -> bool { + let mut removed = false; + let mut i = 0; + while i < self.semaphores.len() { + if self.semaphores[i] == semaphore { + self.semaphores.swap_remove(i); + if !self.values.is_empty() { + self.values.swap_remove(i); + } + if !self.stage_masks.is_empty() { + self.stage_masks.swap_remove(i); + } + removed = true; + } else { + i += 1; + } + } + self.check(); + removed + } + /// Append `other` to `self`, leaving `other` empty. pub fn append(&mut self, other: &mut Self) { assert_eq!(self.mode, other.mode);