pub struct RasterTarget<'a> { /* private fields */ }Expand description
Borrowed view of the framebuffer + zbuffer as raw pointers.
R12.2.0 introduces this so the per-frame ScalarRasterizer can be
Copy (for the per-thread fan-out R12.2.1 lands). Holding &'a mut [u32] / &'a mut [f32] directly forces exclusive borrows
per instance, blocking the four quadrants from running on four
threads even though their pixel writes are disjoint.
Constructed safely from exclusive slice borrows — the slices are
consumed and re-exposed as raw pointers tied to lifetime 'a
via PhantomData. Once a RasterTarget exists, it is the sole
path to the underlying memory; the slices cannot be used through
any other channel for the duration of 'a.
Copy lets opticast hand each quadrant thread its own copy of
the same target. The four threads write disjoint pixels (top /
bottom / left / right wedges of the screen, no overlap), so
pointer aliasing is safe under the documented invariant.
§Safety contract for parallel use
Callers that copy a RasterTarget and pass copies to multiple
threads MUST guarantee that the threads collectively write to
pairwise-disjoint pixel indices. opticast enforces this via the
four-quadrant wedge geometry (see scan_loops::{top,right, bottom,left}_quadrant). Single-threaded callers (R12.1 default)
hold one copy and trivially satisfy the invariant.
Implementations§
Source§impl<'a> RasterTarget<'a>
impl<'a> RasterTarget<'a>
Sourcepub fn new(framebuffer: &'a mut [u32], zbuffer: &'a mut [f32]) -> Self
pub fn new(framebuffer: &'a mut [u32], zbuffer: &'a mut [f32]) -> Self
Build a target from exclusive slice borrows. The slices are
consumed (their &'a mut reborrow is the load-bearing thing —
this constructor is the only way to mint a RasterTarget
from safe code).
Sourcepub fn fb_ptr(self) -> *mut u32
pub fn fb_ptr(self) -> *mut u32
Raw mutable framebuffer pointer. Used by SSE blocks that do their own arithmetic + bounds reasoning.
§Safety
Callers must respect fb_len and the parallel-use invariant.
Sourcepub fn zb_ptr(self) -> *mut f32
pub fn zb_ptr(self) -> *mut f32
Raw mutable zbuffer pointer. Same contract as
Self::fb_ptr.
Sourcepub unsafe fn write_color(self, idx: usize, color: u32)
pub unsafe fn write_color(self, idx: usize, color: u32)
Sourcepub unsafe fn write_depth(self, idx: usize, z: f32)
pub unsafe fn write_depth(self, idx: usize, z: f32)
Write one z-buffer entry.
§Safety
idx < self.fb_len() (zbuffer length matches fb), plus the
parallel-use invariant.
Trait Implementations§
Source§impl<'a> Clone for RasterTarget<'a>
impl<'a> Clone for RasterTarget<'a>
Source§fn clone(&self) -> RasterTarget<'a>
fn clone(&self) -> RasterTarget<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for RasterTarget<'a>
impl<'a> Debug for RasterTarget<'a>
impl<'a> Copy for RasterTarget<'a>
impl Send for RasterTarget<'_>
impl Sync for RasterTarget<'_>
Auto Trait Implementations§
impl<'a> Freeze for RasterTarget<'a>
impl<'a> RefUnwindSafe for RasterTarget<'a>
impl<'a> Unpin for RasterTarget<'a>
impl<'a> UnsafeUnpin for RasterTarget<'a>
impl<'a> !UnwindSafe for RasterTarget<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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