1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use smallvec::SmallVec;
use command_buffer::submit::SubmitCommandBufferBuilder;
use command_buffer::submit::SubmitPresentBuilder;
use sync::PipelineStages;
use sync::Semaphore;
#[derive(Debug)]
pub struct SubmitSemaphoresWaitBuilder<'a> {
semaphores: SmallVec<[&'a Semaphore; 8]>,
}
impl<'a> SubmitSemaphoresWaitBuilder<'a> {
#[inline]
pub fn new() -> SubmitSemaphoresWaitBuilder<'a> {
SubmitSemaphoresWaitBuilder { semaphores: SmallVec::new() }
}
#[inline]
pub unsafe fn add_wait_semaphore(&mut self, semaphore: &'a Semaphore) {
self.semaphores.push(semaphore);
}
#[inline]
pub fn merge(&mut self, mut other: SubmitSemaphoresWaitBuilder<'a>) {
self.semaphores.extend(other.semaphores.drain());
}
}
impl<'a> Into<SubmitCommandBufferBuilder<'a>> for SubmitSemaphoresWaitBuilder<'a> {
#[inline]
fn into(mut self) -> SubmitCommandBufferBuilder<'a> {
unsafe {
let mut builder = SubmitCommandBufferBuilder::new();
for sem in self.semaphores.drain() {
builder.add_wait_semaphore(sem,
PipelineStages {
all_commands: true,
..PipelineStages::none()
});
}
builder
}
}
}
impl<'a> Into<SubmitPresentBuilder<'a>> for SubmitSemaphoresWaitBuilder<'a> {
#[inline]
fn into(mut self) -> SubmitPresentBuilder<'a> {
unsafe {
let mut builder = SubmitPresentBuilder::new();
for sem in self.semaphores.drain() {
builder.add_wait_semaphore(sem);
}
builder
}
}
}