Skip to content

Commit e1e7b6a

Browse files
sotaroikedaErichDonGubler
authored andcommitted
Add Queue::remove_signal_semaphore() (gfx-rs#9388)
1 parent 5a9b30f commit e1e7b6a

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

wgpu-hal/src/vulkan/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,14 @@ impl Queue {
13781378
guard.push_signal(SemaphoreType::Binary(semaphore));
13791379
}
13801380
}
1381+
1382+
/// Remove `semaphore` from the pending signal list if it is still present.
1383+
///
1384+
/// Returns `true` if the semaphore was found and removed. If the submit
1385+
/// already consumed it, this is a harmless no-op that returns `false`.
1386+
pub fn remove_signal_semaphore(&self, semaphore: vk::Semaphore) -> bool {
1387+
self.signal_semaphores.lock().remove(semaphore)
1388+
}
13811389
}
13821390

13831391
/// Maps

wgpu-hal/src/vulkan/semaphore_list.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,29 @@ impl SemaphoreList {
147147
self.check();
148148
}
149149

150+
/// Remove all entries matching `semaphore` from the list. Returns `true`
151+
/// if anything was removed.
152+
pub fn remove(&mut self, semaphore: vk::Semaphore) -> bool {
153+
let mut removed = false;
154+
let mut i = 0;
155+
while i < self.semaphores.len() {
156+
if self.semaphores[i] == semaphore {
157+
self.semaphores.swap_remove(i);
158+
if !self.values.is_empty() {
159+
self.values.swap_remove(i);
160+
}
161+
if !self.stage_masks.is_empty() {
162+
self.stage_masks.swap_remove(i);
163+
}
164+
removed = true;
165+
} else {
166+
i += 1;
167+
}
168+
}
169+
self.check();
170+
removed
171+
}
172+
150173
/// Append `other` to `self`, leaving `other` empty.
151174
pub fn append(&mut self, other: &mut Self) {
152175
assert_eq!(self.mode, other.mode);

0 commit comments

Comments
 (0)