rendy_command/family/
submission.rs1use crate::buffer::{NoSimultaneousUse, OutsideRenderPass, PrimaryLevel, Submit, Submittable};
2
3#[allow(unused)]
4type NoWaits<B> = std::iter::Empty<(
5 &'static <B as rendy_core::hal::Backend>::Semaphore,
6 rendy_core::hal::pso::PipelineStage,
7)>;
8#[allow(unused)]
9type NoSignals<B> = std::iter::Empty<&'static <B as rendy_core::hal::Backend>::Semaphore>;
10#[allow(unused)]
11type NoSubmits<B> = std::iter::Empty<Submit<B, NoSimultaneousUse, PrimaryLevel, OutsideRenderPass>>;
12
13#[derive(Debug)]
15pub struct Submission<B, W = NoWaits<B>, C = NoSubmits<B>, S = NoSignals<B>> {
16 pub waits: W,
18
19 pub submits: C,
21
22 pub signals: S,
24
25 pub marker: std::marker::PhantomData<fn() -> B>,
27}
28
29impl<B> Submission<B>
30where
31 B: rendy_core::hal::Backend,
32{
33 pub fn new() -> Self {
35 Submission {
36 waits: std::iter::empty(),
37 submits: std::iter::empty(),
38 signals: std::iter::empty(),
39 marker: std::marker::PhantomData,
40 }
41 }
42}
43
44impl<B, W, S> Submission<B, W, NoSubmits<B>, S>
45where
46 B: rendy_core::hal::Backend,
47{
48 pub fn submits<C>(self, submits: C) -> Submission<B, W, C, S>
50 where
51 C: IntoIterator,
52 C::Item: Submittable<B>,
53 {
54 Submission {
55 waits: self.waits,
56 submits,
57 signals: self.signals,
58 marker: self.marker,
59 }
60 }
61}
62
63impl<B, C, S> Submission<B, NoWaits<B>, C, S>
64where
65 B: rendy_core::hal::Backend,
66{
67 pub fn wait<'a, W, E>(self, waits: W) -> Submission<B, W, C, S>
69 where
70 W: IntoIterator<Item = (&'a E, rendy_core::hal::pso::PipelineStage)>,
71 E: std::borrow::Borrow<B::Semaphore> + 'a,
72 {
73 Submission {
74 waits,
75 submits: self.submits,
76 signals: self.signals,
77 marker: self.marker,
78 }
79 }
80}
81
82impl<B, W, C> Submission<B, W, C, NoSignals<B>>
83where
84 B: rendy_core::hal::Backend,
85{
86 pub fn signal<'a, S, E>(self, signals: S) -> Submission<B, W, C, S>
88 where
89 S: IntoIterator<Item = &'a E>,
90 E: std::borrow::Borrow<B::Semaphore> + 'a,
91 {
92 Submission {
93 waits: self.waits,
94 submits: self.submits,
95 signals,
96 marker: self.marker,
97 }
98 }
99}