pub struct Cadence {
pub hold: u32,
pub faces: usize,
}Expand description
The two limits a frame’s redraws are spent under.
Read off the console with Cadence::from_console once a frame, so the
value cannot move between the decision and the pass that acts on it — which
is the same freeze crate::forward gives its render effects and for the same
reason.
Fields§
§hold: u32The longest any group may go unredrawn, in frames — r_shadow_cadence.
One is the whole ladder switched off: every period clamps to one, every group that wants redrawing is due, and the schedule is what shipped before this module existed.
faces: usizeTiles a frame may redraw — r_shadow_faces.
Implementations§
Source§impl Cadence
impl Cadence
Sourcepub const EVERY_FRAME: Self
pub const EVERY_FRAME: Self
Every group that wants redrawing gets it, this frame.
What the console’s defaults resolve to, and what crate::forward passes
on a frame that has reset — see Cadence::schedule’s note on a map
whose own region has moved.
Sourcepub fn from_console() -> Self
pub fn from_console() -> Self
The pair as the console holds them.
Clamped through the variables’ own ranges rather than trusted, on
crate::ssao::slice_count’s terms: the range is the console’s guard and
this is the one that holds if a range ever moves.
Sourcepub fn schedule(self, frame: u64, wanted: &[Option<Group>; 6]) -> [bool; 6]
pub fn schedule(self, frame: u64, wanted: &[Option<Group>; 6]) -> [bool; 6]
Which of wanted’s groups this frame redraws.
wanted[group] is Some where the image no longer holds what the
frame would draw into that group, and None where it does — a free
slot, a frame with shadows off, or a map whose inputs have not moved
since it was drawn. So this decides when an out-of-date map is
redrawn and never whether an up-to-date one is.
§Two gates, in this order
- The cadence. A group is due on the frames where
(frame + group) % periodis zero. The group index is in the modulus so two groups on one tier fall on different frames rather than arriving together — which is what makes the budget below reachable rather than a cliff every period. - The budget. The due groups are admitted until
Cadence::facestiles are spoken for. A group that does not fit is skipped and the walk continues, so a cascade behind a point light’s cube is still redrawn — the same rulesuper::Selection::updatefollows when a run of tiles will not fit, and for the same reason. A frame that admitted nothing takes the first candidate anyway: a budget smaller than one map is not a budget, it is a map nothing ever draws.
§The tier decides how often a map asks, not who is served
The budget is spent in the group index rotated by the frame and in nothing else — deliberately not in tier order, which would starve every coarse map outright: a tier-0 group is due on every frame, so a budget that served tiers in order would be spent before a tier-1 group was ever reached, for ever. Rotating instead serves the due groups round-robin, and the ladder still comes out of it — a group due twice as often asks twice as often and is served twice as often.
§A group that is stale wins nothing over one that is due
Cadence is the outer gate and staleness the inner one: a group whose inputs moved but whose turn has not come holds the texels it has and is redrawn on its turn. The alternative — staleness overriding the cadence — is a schedule that binds only while nothing moves, which is the case that never needed bounding.
What that leaves is a map drawn for a region that has since moved out
from under it, which is worse than a lagging shadow — and that is
Group::forced, which bypasses the period and takes the budget first.
A frame whose whole atlas was relaid has nothing to hold at all, and
crate::forward passes Cadence::EVERY_FRAME there rather than
making it a case here.