1use {
2 super::*,
3 crate::command::{
4 Capability, CommandBuffer, CommandPool, ExecutableState, IndividualReset, InitialState,
5 Level, MultiShot, NoSimultaneousUse, OutsideRenderPass, PendingState, PrimaryLevel,
6 RenderPassRelation, Submit,
7 },
8};
9
10pub type CommandCirque<B, C, P = OutsideRenderPass, L = PrimaryLevel> = Cirque<
12 CommandBuffer<B, C, ExecutableState<MultiShot, P>, L, IndividualReset>,
13 CommandBuffer<B, C, InitialState, L, IndividualReset>,
14 CommandBuffer<B, C, PendingState<ExecutableState<MultiShot, P>>, L, IndividualReset>,
15>;
16
17pub type CommandCirqueRef<'a, B, C, P = OutsideRenderPass, L = PrimaryLevel> = CirqueRef<
19 'a,
20 CommandBuffer<B, C, ExecutableState<MultiShot, P>, L, IndividualReset>,
21 CommandBuffer<B, C, InitialState, L, IndividualReset>,
22 CommandBuffer<B, C, PendingState<ExecutableState<MultiShot, P>>, L, IndividualReset>,
23>;
24
25pub type CommandInitialRef<'a, B, C, P = OutsideRenderPass, L = PrimaryLevel> = InitialRef<
27 'a,
28 CommandBuffer<B, C, ExecutableState<MultiShot, P>, L, IndividualReset>,
29 CommandBuffer<B, C, InitialState, L, IndividualReset>,
30 CommandBuffer<B, C, PendingState<ExecutableState<MultiShot, P>>, L, IndividualReset>,
31>;
32
33pub type CommandReadyRef<'a, B, C, P = OutsideRenderPass, L = PrimaryLevel> = ReadyRef<
35 'a,
36 CommandBuffer<B, C, ExecutableState<MultiShot, P>, L, IndividualReset>,
37 CommandBuffer<B, C, InitialState, L, IndividualReset>,
38 CommandBuffer<B, C, PendingState<ExecutableState<MultiShot, P>>, L, IndividualReset>,
39>;
40
41impl<B, C, P, L> CommandCirque<B, C, P, L>
42where
43 B: rendy_core::hal::Backend,
44 L: Level,
45 C: Capability,
46 P: RenderPassRelation<L>,
47{
48 pub fn encode<'a>(
50 &'a mut self,
51 frames: &Frames<B>,
52 pool: &mut CommandPool<B, C, IndividualReset>,
53 encode: impl FnOnce(CommandCirqueRef<'a, B, C, P, L>) -> CommandReadyRef<'a, B, C, P, L>,
54 ) -> Submit<B, NoSimultaneousUse, L, P> {
55 let cr = self.get(
56 frames,
57 || pool.allocate_buffers(1).pop().unwrap(),
58 |pending| unsafe { pending.mark_complete() },
59 );
60
61 let ready = encode(cr);
62
63 let mut slot = None;
64
65 ready.finish(|executable| {
66 let (submit, pending) = executable.submit();
67 slot = Some(submit);
68 pending
69 });
70
71 slot.unwrap()
72 }
73}