Skip to main content

RasterTarget

Struct RasterTarget 

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

Source

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).

Source

pub fn fb_len(self) -> usize

Framebuffer length in u32 elements.

Source

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.

Source

pub fn zb_ptr(self) -> *mut f32

Raw mutable zbuffer pointer. Same contract as Self::fb_ptr.

Source

pub unsafe fn write_color(self, idx: usize, color: u32)

Write one ARGB pixel.

§Safety

idx < self.fb_len(), plus the parallel-use invariant.

Source

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>

Source§

fn clone(&self) -> RasterTarget<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for RasterTarget<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Copy for RasterTarget<'a>

Source§

impl Send for RasterTarget<'_>

Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.