Skip to main content

crcbl_render/
timing.rs

1//! Per-pass GPU timestamps — `crcbl_frame::timing`, re-exported — and how many
2//! passes this crate's renderers record.
3//!
4//! The timers are the frame core's; what is this crate's is the sum below,
5//! because the renderers it adds up are.
6
7pub use crcbl_frame::timing::*;
8
9use crate::forward::ForwardRenderer;
10use crate::skinning::Skinning;
11use crate::sprite_pass::SpriteRenderer;
12use crate::ui_pass::UiRenderer;
13
14/// How many passes one frame of this crate's renderers records, at most.
15///
16/// **What a caller passes [`PassTimers::new`] instead of a number of its own.**
17/// Every renderer here says how many passes it adds — [`ForwardRenderer`],
18/// [`SpriteRenderer`] and [`UiRenderer`] each carry a
19/// `MAX_PASSES`, and [`Skinning`] carries one for the dispatch
20/// [`ForwardRenderer::add_skinned_passes`] puts in front of them — and this is
21/// their sum, so a pass added anywhere below moves this number with it. A game is in no position to know the count: it is a fact
22/// about the renderer, and every sample that guessed it guessed low. The
23/// samples' `8` was picked when a frame had three passes and was still `8` when
24/// the shadow cascades and the light grid had taken it to fourteen, at which
25/// point the timers bracketed the first eight and dropped the rest.
26///
27/// A caller that declares passes of its own — a clear, a readback, a pass of its
28/// own devising — records that many more than this. The samples' clears fit
29/// because none of them also runs a [`ForwardRenderer`], and a caller that
30/// outgrows the bound gets the one warning [`PassTimers`] logs rather than a
31/// silent truncation.
32pub const MAX_TIMED_PASSES: u32 = ForwardRenderer::MAX_PASSES
33    + Skinning::MAX_PASSES
34    + SpriteRenderer::MAX_PASSES
35    + UiRenderer::MAX_PASSES;