pub struct DrawTarget<'a> {
pub pitch_pixels: usize,
pub width: u32,
pub height: u32,
/* private fields */
}Expand description
Borrowed framebuffer + zbuffer the per-voxel rasterizer fills.
Mirrors voxlap’s kv6frameplace + zbuffermem but in
row-major-pixel form rather than byte-pointer form. width /
height must match the OpticastSettings.xres / yres used
when the per-frame Kv6FullState was built — the bounds derived from
qsum0 / qsum1 assume that geometry.
Internally a raw-pointer view (similar to
crate::scalar_rasterizer::RasterTarget) so the type is `Copy
- Send + Sync
and the R12.4.2 [draw_sprites_parallel`] entry point can hand per-thread copies into rayon worker closures. Each parallel sprite-draw competes for the framebuffer / zbuffer via z-test; for non-overlapping sprites this is race-free, for overlapping pixels a tied-z race may leak (visually indistinguishable, hash non-deterministic).
Fields§
§pitch_pixels: usizeRow stride in pixels.
width: u32§height: u32Implementations§
Source§impl<'a> DrawTarget<'a>
impl<'a> DrawTarget<'a>
Sourcepub fn new(
framebuffer: &'a mut [u32],
zbuffer: &'a mut [f32],
pitch_pixels: usize,
width: u32,
height: u32,
) -> Self
pub fn new( framebuffer: &'a mut [u32], zbuffer: &'a mut [f32], pitch_pixels: usize, width: u32, height: u32, ) -> Self
Build a target from exclusive slice borrows + framebuffer
dimensions. The slices are consumed (their &'a mut
re-borrow is what gates lifetime); subsequent access happens
via the raw pointers held in the struct.
Sourcepub unsafe fn fb_write(self, idx: usize, color: u32)
pub unsafe fn fb_write(self, idx: usize, color: u32)
Unconditional framebuffer write. Used by sequential 2D
blitters (drawtile) that don’t engage z-testing.
§Safety
idx < self.fb_len. The disjoint-write contract still
applies if multiple Copy instances of DrawTarget are in
flight across threads — this method does NOT arbitrate via
z-test.
Sourcepub unsafe fn fb_read(self, idx: usize) -> u32
pub unsafe fn fb_read(self, idx: usize) -> u32
Read one framebuffer pixel. Used by alpha-blend paths
(drawtile modulate-and-blend) that read-modify-write.
§Safety
idx < self.fb_len. Concurrent writers to the same idx
from another thread invalidate the read; sequential blits
are race-free.
Sourcepub unsafe fn z_test_write(self, idx: usize, color: u32, z: f32) -> bool
pub unsafe fn z_test_write(self, idx: usize, color: u32, z: f32) -> bool
Z-tested pixel write. If z < zbuffer[idx], the new color +
z stamp the buffers; otherwise nothing changes.
§Safety
idx < self.fb_len. For parallel callers, the wedge / z-test
arbitration contract on DrawTarget applies (see struct
doc).
Trait Implementations§
Source§impl<'a> Clone for DrawTarget<'a>
impl<'a> Clone for DrawTarget<'a>
Source§fn clone(&self) -> DrawTarget<'a>
fn clone(&self) -> DrawTarget<'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 DrawTarget<'a>
impl<'a> Debug for DrawTarget<'a>
impl<'a> Copy for DrawTarget<'a>
impl Send for DrawTarget<'_>
impl Sync for DrawTarget<'_>
Auto Trait Implementations§
impl<'a> Freeze for DrawTarget<'a>
impl<'a> RefUnwindSafe for DrawTarget<'a>
impl<'a> Unpin for DrawTarget<'a>
impl<'a> UnsafeUnpin for DrawTarget<'a>
impl<'a> !UnwindSafe for DrawTarget<'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