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 fn with_parked_budget(self, budget: Arc<dyn ParkedBudget>) -> Self
pub fn with_parked_budget(self, budget: Arc<dyn ParkedBudget>) -> Self
Charges every chunk this merger parks (see the module doc’s “Memory” section)
against budget, refusing (as MergeError::ParkedBudgetExceeded) instead of
parking once it says no; released again as each chunk folds.
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 frontier(&self) -> u32
pub fn frontier(&self) -> u32
The next sample index the fold expects: every sample below it is already folded into the merged prefix. Advances as the chunk at the frontier arrives.
Sourcepub fn dropped_pixels(&self) -> u64
pub fn dropped_pixels(&self) -> u64
How many pixels of added chunks were zeroed for a non-finite or negative component (module doc, “Invalid values”).
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, the chunk overlaps samples
already added, or parking it would exceed Self::with_parked_budget’s budget;
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.