Skip to main content

ChunkWindow

Struct ChunkWindow 

Source
pub struct ChunkWindow { /* private fields */ }
Expand description

Decides which chunks stream in and out of the camera-centred view window, and at which detail.

The window owns only residency bookkeeping – it never generates a chunk or touches a GPU resource. Each frame the driver calls plan with the camera’s current chunk, dispatches the loads, applies the evictions, and reports completed loads back via mark_resident.

Implementations§

Source§

impl ChunkWindow

Source

pub fn new(near_radius: i32, far_radius: i32, load_budget: usize) -> Self

A window with a full-detail radius of near_radius, an outer impostor radius of far_radius, and a per-frame load budget of load_budget chunks.

near_radius is floored at 0 (a lone chunk), far_radius at near_radius (so it never undercuts the full-detail band; equal means “no impostors”), and load_budget at 1 so a stray 0 cannot wedge streaming permanently.

Source

pub fn set_byte_budget(&mut self, budget: Option<u64>)

Set (or clear with None) the total resident-chunk-byte budget. None keeps the pure radius-based window; Some(b) additionally clamps the effective view radius down until resident bytes fit b. Off by default so worlds that never set it behave exactly as the radius-only window.

Source

pub fn byte_budget(&self) -> Option<u64>

The active resident-byte budget, or None when byte accounting is off (the pure radius window). For diagnostics.

Source

pub fn plan(&mut self, camera: ChunkCoord) -> ChunkPlan

Decide this frame’s chunk loads and evictions for a camera in chunk camera.

First reconciles the effective view radius against the byte budget (a no-op when none is set), then evicts every tracked chunk now beyond the effective evict radius, re-details any tracked chunk that has crossed the near/far boundary (evict + reload at the new detail), and dispatches the nearest in-window chunks not yet tracked, up to the load budget, marking each Pending.

Source

pub fn mark_resident(&mut self, coord: ChunkCoord, bytes: u64)

Mark a dispatched chunk resident once its mesh is on the GPU, recording its GPU footprint in bytes (the decoded vertex + index buffer size). bytes may be 0 when nothing was uploaded (e.g. a generation that deterministically failed and is being retired to stop retrying it).

A no-op if the chunk is no longer tracked – the camera may have moved far enough to evict it while its load was still in flight.

Source

pub fn resident_bytes(&self) -> u64

Total bytes of all currently Resident chunks, for diagnostics and the byte-budget clamp. Pending chunks (not yet uploaded) are excluded.

Source

pub fn forget(&mut self, coord: ChunkCoord)

Drop coord from tracking so a later plan will re-dispatch it.

The driver calls this when a dispatch could not be delivered to the background worker, so the chunk is retried rather than stuck Pending.

Source

pub fn is_tracked(&self, coord: ChunkCoord) -> bool

Whether the window is still tracking coord (pending or resident).

The driver checks this when a background load completes: a chunk evicted mid-flight is no longer tracked and its mesh should be dropped.

Source

pub fn counts(&self) -> (usize, usize)

(resident, pending) chunk counts – for diagnostics.

Source

pub fn counts_by_detail(&self) -> (usize, usize)

(near_resident, far_resident) counts – resident full chunks vs resident impostors, for diagnostics / verifying the far band is active.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more