pub struct Merger { /* private fields */ }Expand description
See the module doc. Shared by reference between the pool’s lane threads (which
add) and any observer thread (which reads
snapshot_into / total).
Implementations§
Source§impl Merger
impl Merger
Sourcepub const fn new(pixels: usize, first_sample: u32) -> Self
pub const fn new(pixels: usize, first_sample: u32) -> Self
An empty merge for a pixels-pixel image whose sample range starts at
first_sample.
Sourcepub const fn pixel_count(&self) -> usize
pub const fn pixel_count(&self) -> usize
The image’s pixel count.
Sourcepub const fn first_sample(&self) -> u32
pub const fn first_sample(&self) -> u32
The first sample index of the range this merger was built for.
Sourcepub fn add(
&self,
first_sample: u32,
done: u32,
sum: Vec<Vec3>,
) -> Result<u32, MergeError>
pub fn add( &self, first_sample: u32, done: u32, sum: Vec<Vec3>, ) -> Result<u32, MergeError>
Adds the chunk [first_sample, first_sample + done) whose summed radiance is
sum, returning the new exact total count. done == 0 is a no-op (and sum
may then be empty).
§Errors
MergeError when sum has the wrong length or the chunk overlaps samples
already added; nothing is merged then.
Sourcepub fn snapshot_into(&self, dst: &mut [Vec3]) -> u32
pub fn snapshot_into(&self, dst: &mut [Vec3]) -> u32
Adds everything merged so far into dst (folded buffer first, then parked
chunks in first_sample order) and returns exactly the sample count that
represents. dst must be pixel_count long; any other length adds nothing and
returns 0, so the returned count always matches what was added.
Sourcepub fn into_parts(self) -> (Vec<Vec3>, u32)
pub fn into_parts(self) -> (Vec<Vec3>, u32)
Consumes the merger: the merged buffer (pixel_count long, zeros if nothing
was added) and its exact sample count. Parked chunks left behind by an
incomplete run (cancel, lanes lost) are folded in first_sample order, so this
is deterministic too.