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
impl ChunkWindow
Sourcepub fn new(near_radius: i32, far_radius: i32, load_budget: usize) -> Self
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.
Sourcepub fn set_byte_budget(&mut self, budget: Option<u64>)
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.
Sourcepub fn byte_budget(&self) -> Option<u64>
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.
Sourcepub fn plan(&mut self, camera: ChunkCoord) -> ChunkPlan
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.
Sourcepub fn mark_resident(&mut self, coord: ChunkCoord, bytes: u64)
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.
Sourcepub fn resident_bytes(&self) -> u64
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.
Sourcepub fn forget(&mut self, coord: ChunkCoord)
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.
Sourcepub fn is_tracked(&self, coord: ChunkCoord) -> bool
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.
Sourcepub fn counts_by_detail(&self) -> (usize, usize)
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.