Skip to main content

Cadence

Struct Cadence 

Source
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: u32

The 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: usize

Tiles a frame may redraw — r_shadow_faces.

Implementations§

Source§

impl Cadence

Source

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.

Source

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.

Source

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) % period is 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::faces tiles 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 rule super::Selection::update follows 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.

Trait Implementations§

Source§

impl Clone for Cadence

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Cadence

Source§

impl Debug for Cadence

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Cadence

Source§

impl PartialEq for Cadence

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Cadence

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HalThreadSafe for T
where T: Send + Sync,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.