pub struct ScratchPool { /* private fields */ }Expand description
N-slot pool of ScanScratch buffers — one slot per render
thread.
R12.0 introduced this as the host-owned ownership root for
per-thread scratch. R12.1 wires it through crate::opticast()
(single slot in use). R12.2 will fan slots 0..4 across the four
quadrant scan loops via rayon::join; R12.3 will distribute
slots across N row strips via par_iter.
Per-frame setters (Self::set_skycast / Self::set_fog /
Self::set_side_shades) broadcast to every slot — so once
R12.2 fans out, each thread already sees the current frame’s
fog / sky / shading state on its private slot.
One slot is ~7.6 MB at 640 × 480 / vsid = 2048 (see
PORTING-MULTICORE.md § “Memory cost”). Hosts allocate one
pool at startup and reuse it across frames; the rasterizer is
the per-frame object that borrows the framebuffer / zbuffer.
Implementations§
Source§impl ScratchPool
impl ScratchPool
Sourcepub fn new(xres: u32, yres: u32, vsid: u32) -> Self
pub fn new(xres: u32, yres: u32, vsid: u32) -> Self
Single-slot pool — single-threaded rendering. Equivalent to
one ScanScratch::new_for_size allocation. The R12.0
default; preserves the pre-R12 single-threaded shape.
Sourcepub fn new_parallel(xres: u32, yres: u32, vsid: u32, n_threads: usize) -> Self
pub fn new_parallel(xres: u32, yres: u32, vsid: u32, n_threads: usize) -> Self
n_threads-slot pool. Each slot holds its own ~7.6 MB
ScanScratch. Pass the value the host wants rayon to
fan out across; n_threads = 0 is treated as 1 so
Self::slot_mut(0) is always valid.
R12.1 only consumes slot 0; later sub-substages (R12.2 / R12.3) start indexing additional slots.
Sourcepub fn slot(&self, idx: usize) -> &ScanScratch
pub fn slot(&self, idx: usize) -> &ScanScratch
Sourcepub fn slot_mut(&mut self, idx: usize) -> &mut ScanScratch
pub fn slot_mut(&mut self, idx: usize) -> &mut ScanScratch
Sourcepub fn set_skycast(&mut self, col: i32, dist: i32)
pub fn set_skycast(&mut self, col: i32, dist: i32)
Per-frame sky (col, dist) push, broadcast to every slot.
See ScanScratch::set_skycast.
Sourcepub fn set_fog(&mut self, col: i32, max_scan_dist: i32)
pub fn set_fog(&mut self, col: i32, max_scan_dist: i32)
Per-frame fog push, broadcast to every slot. See
ScanScratch::set_fog.
Sourcepub fn set_side_shades(
&mut self,
top: i8,
bot: i8,
left: i8,
right: i8,
up: i8,
down: i8,
)
pub fn set_side_shades( &mut self, top: i8, bot: i8, left: i8, right: i8, up: i8, down: i8, )
Per-frame side-shading push, broadcast to every slot. See
ScanScratch::set_side_shades.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScratchPool
impl RefUnwindSafe for ScratchPool
impl Send for ScratchPool
impl Sync for ScratchPool
impl Unpin for ScratchPool
impl UnsafeUnpin for ScratchPool
impl UnwindSafe for ScratchPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more