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
//! The components that make up a rendering pipeline.

/// A single, atomic rendering operation.
#[derive(Debug)]
pub enum Step {
    /// Clears the current render target.
    ClearTarget {
        /// Which buffers to clear. Possible values: "all", "color", "stencil".
        buffers: String,
        /// The RGBA value to clear the buffers with. If `None`, this will
        /// default to `[0.0; 4]`.
        value: Option<[f32; 4]>,
    },
    /// Draws all objects in the scene.
    DrawObjects,
    /// Selects a render target to write to. If the given string is empty
    /// (`""`), we render directly to the window surface.
    UseTarget(String),
}

/// A set of steps that accomplishes some task in the rendering pipeline.
#[derive(Debug)]
pub struct Stage {
    pub name: String,
    pub steps: Vec<Step>,
}

impl Stage {
    /// Defines a new pipeline stage and assigns it a descriptive name.
    pub fn new(name: &str) -> Stage {
        Stage {
            name: name.to_string(),
            steps: Vec::new(),
        }
    }
}