Expand description
RasterTarget — a Copy borrowed view of the framebuffer +
zbuffer as raw pointers, the compositing primitive shared by the
DDA terrain renderer (crate::dda) and the DDA sprite raycaster
(crate::dda_sprite).
Holding &'a mut [u32] / &'a mut [f32] directly would force an
exclusive borrow per instance, blocking the renderer’s tile bands
from running on multiple threads even though their pixel writes are
disjoint. RasterTarget is constructed safely from exclusive slice
borrows, then re-exposes the memory as raw pointers tied to lifetime
'a via PhantomData. Once it exists it is the sole path to the
underlying memory for the duration of 'a.
§Safety contract for parallel use
Callers that copy a RasterTarget and pass copies to multiple
threads MUST guarantee the threads collectively write to
pairwise-disjoint pixel indices. The parallel DDA driver enforces
this via per-band row ranges; single-threaded callers hold one copy
and trivially satisfy the invariant.