aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/draw/draw_passes/cons.rs
blob: 76e2f32837f1e0d2e390cebe43c7d11202a8ea35 (plain)
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
//! Code for using multiple draw passes in place of just one
//! Note that this can be extended to an arbitrary amount of draw passes.

use super::DrawPass;
use crate::{draw::queue_negotiator::QueueNegotiator, types::*};
use stockton_types::Session;

use anyhow::Result;

/// One draw pass, then another.
pub struct ConsDrawPass<A: DrawPass, B: DrawPass> {
    a: A,
    b: B,
}

impl<A: DrawPass, B: DrawPass> DrawPass for ConsDrawPass<A, B> {
    fn queue_draw(&self, session: &Session, cmd_buffer: &mut CommandBufferT) -> Result<()> {
        self.a.queue_draw(&session, cmd_buffer)?;
        self.b.queue_draw(&session, cmd_buffer)?;

        Ok(())
    }

    fn find_aux_queues<'a>(
        adapter: &'a Adapter,
        queue_negotiator: &mut QueueNegotiator,
    ) -> Result<Vec<(&'a QueueFamilyT, Vec<f32>)>> {
        let mut vec = Vec::new();

        vec.extend(A::find_aux_queues(adapter, queue_negotiator)?);
        vec.extend(B::find_aux_queues(adapter, queue_negotiator)?);

        Ok(vec)
    }
}

/// A draw pass that does nothing. Can be used at the end of sequences if there's an odd number of draw passes.
pub struct NilDrawPass;

impl DrawPass for NilDrawPass {

    fn queue_draw(&self, _input: &Session, _cmd_buffer: &mut CommandBufferT) -> Result<()> {
        Ok(())
    }

    fn find_aux_queues<'a>(
        _adapter: &'a Adapter,
        _queue_negotiator: &mut QueueNegotiator,
    ) -> Result<Vec<(&'a QueueFamilyT, Vec<f32>)>> {
        Ok(vec![])
    }
}