Skip to main content

OidnDevice

Struct OidnDevice 

Source
pub struct OidnDevice { /* private fields */ }
Expand description

Open Image Denoise logical device.

Prefer creating one per application and reusing it; filter creation is relatively expensive. See Self::new, Self::cpu, and backend-specific constructors.

Implementations§

Source§

impl OidnDevice

Source

pub fn new() -> Result<Self, Error>

Creates a device using the default backend (auto-selects CPU or GPU when available).

§Errors

Returns Error::DeviceCreationFailed if no backend is available. Use take_global_error() to retrieve the underlying OIDN message.

Source

pub fn cpu() -> Result<Self, Error>

Creates a CPU-only device (most portable).

Source

pub fn cuda() -> Result<Self, Error>

Creates a CUDA device for NVIDIA GPU-accelerated denoising. Requires OIDN built with CUDA support; returns DeviceCreationFailed otherwise.

Source

pub fn sycl() -> Result<Self, Error>

Creates a SYCL device (Intel GPU/CPU via oneAPI). Requires OIDN built with SYCL.

Source

pub fn hip() -> Result<Self, Error>

Creates a HIP device (AMD GPU). Requires OIDN built with HIP.

Source

pub fn metal() -> Result<Self, Error>

Creates a Metal device (Apple GPU). Requires OIDN built with Metal.

Source

pub fn with_type(device_type: OidnDeviceType) -> Result<Self, Error>

Creates a device of the given type.

Source

pub fn new_by_id(physical_device_id: i32) -> Result<Self, Error>

Creates a device from a physical device ID (0 to num_physical_devices() - 1).

Source

pub fn new_by_uuid(uuid: &[u8; 16]) -> Result<Self, Error>

Creates a device from a physical device UUID (16 bytes; see crate::OIDN_UUID_SIZE).

Source

pub fn new_by_luid(luid: &[u8; 8]) -> Result<Self, Error>

Creates a device from a physical device LUID (8 bytes; see crate::OIDN_LUID_SIZE).

Source

pub fn new_by_pci_address( pci_domain: i32, pci_bus: i32, pci_device: i32, pci_function: i32, ) -> Result<Self, Error>

Creates a device from a PCI address (domain, bus, device, function).

Source

pub unsafe fn new_cuda_device( device_id: i32, stream: Option<*mut c_void>, ) -> Result<Self, Error>

Creates a CUDA device for the given device ID and optional stream. stream: None = default stream; otherwise a valid cudaStream_t (e.g. from rust CUDA bindings). Currently only one (device_id, stream) pair is supported.

Source

pub unsafe fn new_hip_device( device_id: i32, stream: Option<*mut c_void>, ) -> Result<Self, Error>

Creates a HIP device for the given device ID and optional stream. stream: None = default stream. Currently only one pair is supported.

Source

pub unsafe fn new_metal_device( command_queues: &[*mut c_void], ) -> Result<Self, Error>

Creates a Metal device from an array of Metal command queues (MTLCommandQueue). Currently only one queue is supported. Pass a single pointer.

Source

pub fn set_bool(&self, name: &str, value: bool)

Sets a boolean device parameter. Must call commit() before first use if you change parameters.

Source

pub fn set_int(&self, name: &str, value: i32)

Sets an integer device parameter.

Source

pub fn get_bool(&self, name: &str) -> bool

Gets a boolean device parameter.

Source

pub fn get_int(&self, name: &str) -> i32

Gets an integer device parameter.

Source

pub fn get_uint(&self, name: &str) -> u32

Gets an unsigned integer device parameter (OIDN exposes this as cast of get_int).

Source

pub fn commit(&self)

Commits all previous device parameter changes. Must be called before first filter creation.

Source

pub unsafe fn set_error_function_raw( &self, func: Option<unsafe extern "C" fn(user_ptr: *mut c_void, code: OIDNError, message: *const c_char)>, user_ptr: *mut c_void, )

Sets the error callback. The callback is invoked from OIDN; it must not panic. user_ptr is passed to the callback. Must remain valid until device is released or callback is cleared.

Source

pub fn take_error(&self) -> Option<Error>

Returns the first unqueried error and clears it.

Source

pub fn sync(&self)

Waits for all async operations on this device to complete.

Source

pub fn retain(&self)

Retains the device (increments OIDN reference count). For advanced interop only; our Clone uses Arc.

Trait Implementations§

Source§

impl Clone for OidnDevice

Source§

fn clone(&self) -> OidnDevice

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OidnDevice

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for OidnDevice

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for OidnDevice

Source§

impl Sync for OidnDevice

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,