pub struct Denoiser { /* private fields */ }Implementations§
Source§impl Denoiser
impl Denoiser
Sourcepub fn create(
accelerators: &[Accelerator],
device: &Device,
width: u32,
height: u32,
options: DenoiserOptions,
) -> Result<Self, DenoiserError>
pub fn create( accelerators: &[Accelerator], device: &Device, width: u32, height: u32, options: DenoiserOptions, ) -> Result<Self, DenoiserError>
Probe each accelerator in accelerators in order and build a
denoiser on the first one that’s available. device lets the
caller pick a non-default device for the chosen runtime.
§Thread stack size
cubecl spawns an internal per-device worker thread (named
DS{U,D}-…) on which GPU kernel codegen runs. It uses Rust’s
default thread stack (RUST_MIN_STACK, or 2 MiB if unset). The
windowed NLM kernels here contain (2·search_radius + 1)²-times
#[unroll]ed bodies, so large search_radius (≳ 5) values can
overflow that 2 MiB default and abort the process.
Callers planning to use search_radius > 4 should set
RUST_MIN_STACK to at least 16 MiB before any cubecl thread
spawns (typically at the very top of main), e.g.:
if std::env::var_os("RUST_MIN_STACK").is_none() {
// SAFETY: single-threaded at startup.
unsafe { std::env::set_var("RUST_MIN_STACK", "16777216") };
}Sourcepub fn selected_accelerator(&self) -> Accelerator
pub fn selected_accelerator(&self) -> Accelerator
The accelerator picked by sniff_best_accelerator.
Sourcepub fn push_frame(&mut self, frame: &[f32]) -> Result<(), DenoiserError>
pub fn push_frame(&mut self, frame: &[f32]) -> Result<(), DenoiserError>
Upload one frame into the temporal window. frame must contain
width * height * channels f32 values in [0, 1]. Once the
window is full and the in-flight pipeline has room, this also
kicks off the kernels for the next denoised frame.
Up to MAX_PENDING outputs may be in flight simultaneously:
the GPU runs frame N+1’s kernels while frame N’s readback is in
flight. Returns DenoiserError::QueueFull once that ceiling
is reached; the caller must drain via Self::recv_frame before
pushing more.
Sourcepub fn recv_frame(&mut self) -> Result<Option<Vec<f32>>, DenoiserError>
pub fn recv_frame(&mut self) -> Result<Option<Vec<f32>>, DenoiserError>
Block until the in-flight denoise completes and return the
denoised frame. Returns Ok(None) if nothing is in flight
(e.g. the temporal window isn’t full yet).
Sourcepub fn try_recv_frame(&mut self) -> Result<Option<Vec<f32>>, DenoiserError>
pub fn try_recv_frame(&mut self) -> Result<Option<Vec<f32>>, DenoiserError>
Drain the in-flight denoise if one is ready. May block briefly while the runtime confirms the readback has landed; on workloads where kernels are already complete, the wait is effectively immediate.
Sourcepub fn flush(&mut self, sink: impl FnMut(Vec<f32>)) -> Result<(), DenoiserError>
pub fn flush(&mut self, sink: impl FnMut(Vec<f32>)) -> Result<(), DenoiserError>
Drain in-flight frames and the trailing temporal tail (padded by duplicating
the last pushed frame), handing each produced frame to sink.
On success the denoiser is left ready to accept a fresh,
independent stream of the same dimensions and parameters.
Pushing more frames after flush starts a new temporal window from
scratch. May be called multiple times.
If flush returns Err, the denoiser is left in an undefined
state and should be dropped rather than reused.