Skip to main content

Merger

Struct Merger 

Source
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

Source

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.

Source

pub const fn pixel_count(&self) -> usize

The image’s pixel count.

Source

pub const fn first_sample(&self) -> u32

The first sample index of the range this merger was built for.

Source

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.

Source

pub fn total(&self) -> u32

The exact number of samples added so far (folded plus parked).

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Merger

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more