Skip to main content

ScratchPool

Struct ScratchPool 

Source
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

Source

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.

Source

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.

Source

pub fn n_threads(&self) -> usize

Number of slots in this pool — one per render thread.

Source

pub fn slot(&self, idx: usize) -> &ScanScratch

Read-only access to one slot.

§Panics

If idx >= self.n_threads().

Source

pub fn slot_mut(&mut self, idx: usize) -> &mut ScanScratch

Mutable access to one slot.

§Panics

If idx >= self.n_threads().

Source

pub fn set_skycast(&mut self, col: i32, dist: i32)

Per-frame sky (col, dist) push, broadcast to every slot. See ScanScratch::set_skycast.

Source

pub fn set_fog(&mut self, col: i32, max_scan_dist: i32)

Per-frame fog push, broadcast to every slot. See ScanScratch::set_fog.

Source

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§

Source§

impl Debug for ScratchPool

Source§

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

Formats the value using the given formatter. Read more

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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.