aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/draw/draw_passes/mod.rs
blob: 566a64b5049df9b2eab03f1099dc79d865530078 (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
//! Traits and common draw passes.
use super::{queue_negotiator::QueueNegotiator, target::SwapchainProperties};
use crate::types::*;
use stockton_types::Session;

use std::sync::{Arc, RwLock};

use anyhow::Result;

mod cons;
mod level;

pub use level::LevelDrawPass;
pub use cons::{ConsDrawPass, NilDrawPass};

/// One of several 'passes' that draw on each frame.
pub trait DrawPass {
    /// Queue any necessary draw commands to cmd_buffer
    /// This should assume the command buffer isn't in the middle of a renderpass, and should leave it as such.
    fn queue_draw(&self, session: &Session, cmd_buffer: &mut CommandBufferT) -> Result<()>;

    /// This function should ask the queue negotatior to find families for any auxilary operations this draw pass needs to perform
    /// For example, .find(&TexLoadQueue)
    /// It should return then call .family_spec for each queue type negotiated and return the results.
    fn find_aux_queues<'a>(
        adapter: &'a Adapter,
        queue_negotiator: &mut QueueNegotiator,
    ) -> Result<Vec<(&'a QueueFamilyT, Vec<f32>)>>;
}

/// A type that can be made into a specific draw pass type.
/// This allows extra data to be used in initialisation without the Renderer needing to worry about it.
pub trait IntoDrawPass<O: DrawPass> {
    fn init(
        self,
        device: Arc<RwLock<DeviceT>>,
        queue_negotiator: &mut QueueNegotiator,
        swapchain_properties: &SwapchainProperties,
    ) -> Result<O>;
}