Skip to main content

oidn_wgpu/
lib.rs

1//! # oidn-wgpu
2//!
3//! [Intel Open Image Denoise](https://www.openimagedenoise.org) (OIDN) integration for [wgpu](https://docs.rs/wgpu).
4//! Denoise path-traced or ray-traced images produced on the GPU by copying to CPU, running OIDN, and copying back.
5//!
6//! This crate targets **OIDN 2.4.x** and **wgpu 27**. It does not depend on `oidn-rs`.
7//!
8//! ## Setup
9//!
10//! Build and install OIDN 2.4.x (e.g. from <https://github.com/OpenImageDenoise/oidn>), then either:
11//!
12//! - Set **`OIDN_DIR`** to the install directory (containing `include/` and `lib/`), or
13//! - Use **pkg-config** (Linux/macOS) with `OpenImageDenoise` installed.
14//!
15//! ## Example: denoise a wgpu texture
16//!
17//! ```ignore
18//! # use std::error::Error;
19//! # fn main() -> Result<(), Box<dyn Error>> {
20//! use oidn_wgpu::{OidnDevice, denoise_texture, DenoiseTextureFormat, DenoiseOptions};
21//!
22//! let oidn = OidnDevice::new()?;
23//! let format = DenoiseTextureFormat::Rgba16Float;
24//! denoise_texture(
25//!     &oidn,
26//!     &wgpu_device,
27//!     &wgpu_queue,
28//!     &input_texture,
29//!     &output_texture,
30//!     format,
31//!     &DenoiseOptions::default(), // or set quality, hdr, srgb, input_scale
32//! )?;
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! ## Example: denoise CPU buffers (no wgpu)
38//!
39//! ```ignore
40//! # use std::error::Error;
41//! # fn main() -> Result<(), Box<dyn Error>> {
42//! use oidn_wgpu::{OidnDevice, RtFilter};
43//!
44//! let device = OidnDevice::new()?;
45//! let mut filter = RtFilter::new(&device)?;
46//! filter.set_dimensions(width, height).set_hdr(true);
47//! filter.execute_in_place(&mut color_rgb_f32)?;
48//! # Ok(())
49//! # }
50//! ```
51
52pub mod buffer;
53pub mod device;
54pub mod error;
55pub mod filter;
56mod sys;
57pub mod wgpu_integration;
58
59#[cfg(test)]
60mod tests;
61
62/// UUID size for physical device (bytes). Use with [`OidnDevice::new_by_uuid`].
63pub const OIDN_UUID_SIZE: usize = 16;
64/// LUID size for physical device (bytes). Use with [`OidnDevice::new_by_luid`].
65pub const OIDN_LUID_SIZE: usize = 8;
66
67pub use buffer::{BufferStorage, ExternalMemoryTypeFlag, OidnBuffer};
68pub use device::{
69    get_physical_device_bool, get_physical_device_data, get_physical_device_int,
70    get_physical_device_string, is_cpu_device_supported, is_cuda_device_supported,
71    is_hip_device_supported, is_metal_device_supported, num_physical_devices, OidnDevice,
72    OidnDeviceType, take_global_error,
73};
74pub use error::Error;
75pub use filter::{Filter, ImageFormat, OIDNFormat, Quality, RtFilter, RtLightmapFilter};
76pub use wgpu_integration::{
77    denoise_texture, denoise_texture_with_aux, DenoiseOptions, DenoiseTextureFormat,
78};