Add placeholder phases and improve test
This commit is contained in:
parent
25ef497821
commit
67f0eb6ef1
26
src/lib.rs
26
src/lib.rs
|
@ -70,6 +70,7 @@ pub mod gpu {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct DummyPass;
|
||||
|
||||
impl RenderPass for DummyPass {
|
||||
|
@ -81,6 +82,14 @@ mod tests {
|
|||
|
||||
fn begin_frame(&mut self, data: &mut Self::FrameData, phases: &mut PhaseList) {
|
||||
println!("begin_frame()");
|
||||
|
||||
for phase in PrePhase::iter() {
|
||||
phases.insert_pre(phase);
|
||||
}
|
||||
|
||||
for phase in ViewportPhase::iter() {
|
||||
phases.insert_viewport(phase);
|
||||
}
|
||||
}
|
||||
|
||||
fn render_pre(
|
||||
|
@ -106,11 +115,18 @@ mod tests {
|
|||
#[test]
|
||||
fn dummy_pass() {
|
||||
use std::sync::{Arc, RwLock};
|
||||
let dummy_pass = DummyPass;
|
||||
let dummy_pass = Arc::new(RwLock::new(dummy_pass));
|
||||
let dummy_pass = RenderPassBox::new(dummy_pass, 1);
|
||||
let render_passes = vec![dummy_pass];
|
||||
let render_passes = (0..10)
|
||||
.map(|_| {
|
||||
let dummy_pass = DummyPass;
|
||||
let dummy_pass = Arc::new(RwLock::new(dummy_pass));
|
||||
RenderPassBox::new(dummy_pass, 1)
|
||||
})
|
||||
.collect();
|
||||
let mut renderer = Renderer { render_passes };
|
||||
renderer.render();
|
||||
|
||||
for n in 0..10 {
|
||||
println!("Frame #{}", n);
|
||||
renderer.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
32
src/phase.rs
32
src/phase.rs
|
@ -13,12 +13,30 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
/// The rendering pre-phase group; before viewport acquisition.
|
||||
///
|
||||
/// These variants are temporary and for testing purposes.
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, Ord, PartialEq, PartialOrd, strum::EnumIter)]
|
||||
pub enum PrePhase {}
|
||||
pub enum PrePhase {
|
||||
VertexSkinning,
|
||||
}
|
||||
|
||||
/// The main viewport rendering phase group.
|
||||
///
|
||||
/// These variants are temporary and for testing purposes.
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, Ord, PartialEq, PartialOrd, strum::EnumIter)]
|
||||
pub enum ViewportPhase {}
|
||||
pub enum ViewportPhase {
|
||||
CullLights,
|
||||
CullPolys,
|
||||
ShadowRendering,
|
||||
Depth,
|
||||
DepthMips,
|
||||
AO,
|
||||
Opaque,
|
||||
Transparent,
|
||||
Bloom,
|
||||
Overlay,
|
||||
Composite
|
||||
}
|
||||
|
||||
/// A container of phases of each group.
|
||||
///
|
||||
|
@ -36,6 +54,16 @@ impl PhaseList {
|
|||
self.pre.clear();
|
||||
self.viewport.clear();
|
||||
}
|
||||
|
||||
/// Inserts a [PrePhase].
|
||||
pub fn insert_pre(&mut self, phase: PrePhase) {
|
||||
self.pre.push(phase);
|
||||
}
|
||||
|
||||
/// Inserts a [ViewportPhase].
|
||||
pub fn insert_viewport(&mut self, phase: ViewportPhase) {
|
||||
self.viewport.push(phase);
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps phases of each group to sets of values.
|
||||
|
|
Loading…
Reference in New Issue