mod emit;
mod filters;
mod layers;
mod primitives;
mod replay;
mod route;
mod segments;
mod text;
use valo_dl::DisplayList;
use crate::frame::{FramePlan, PassColor, PlannedPass};
use crate::host_buffer::HostBuffer;
use crate::pool::TargetPool;
use crate::renderer::{RenderStats, RenderTarget};
use emit::StepEmitter;
use layers::PassFrame;
use replay::ReplayState;
pub(crate) struct Planner<'a> {
emit: StepEmitter<'a>,
pool: &'a mut TargetPool,
contours: &'a mut crate::contours::ContourCache,
glyphs: &'a mut crate::glyphs::GlyphStore,
rasters: &'a mut crate::raster::ListRasterCache,
format: wgpu::TextureFormat,
frames: Vec<PassFrame>,
elisions: Vec<f32>,
passes: Vec<PlannedPass>,
filling_raster: bool,
stats: RenderStats,
}
impl<'a> Planner<'a> {
#[expect(
clippy::too_many_arguments,
reason = "one-shot wiring of the renderer's caches"
)]
pub fn new(
device: &'a wgpu::Device,
queue: &'a wgpu::Queue,
host: &'a mut HostBuffer,
images: &'a mut crate::images::ImageStore,
pool: &'a mut TargetPool,
pipelines: &'a crate::pipelines::PipelineCache,
glyphs: &'a mut crate::glyphs::GlyphStore,
contours: &'a mut crate::contours::ContourCache,
ramps: &'a mut crate::ramps::RampCache,
rasters: &'a mut crate::raster::ListRasterCache,
sampler: &wgpu::Sampler,
target: &RenderTarget,
dl: &DisplayList,
) -> Self {
let transient = target.clear.is_some();
let scratch = pool.main_scratch(target.size, target.format, transient);
let main = PassFrame::main(
PassColor::Main { msaa: scratch.msaa },
scratch.depth,
target,
dl,
transient,
);
Self {
emit: StepEmitter::new(
host,
device,
queue,
pipelines,
images,
ramps,
sampler.clone(),
target.format,
),
pool,
contours,
glyphs,
rasters,
format: target.format,
frames: vec![main],
elisions: Vec::new(),
passes: Vec::new(),
filling_raster: false,
stats: RenderStats::default(),
}
}
pub fn run(mut self, dl: &DisplayList) -> FramePlan {
let mut state = ReplayState::root();
self.replay_list(dl, &mut state);
self.emit_segment();
FramePlan {
passes: self.passes,
stats: self.stats,
}
}
}