Skip to main content

OidnBuffer

Struct OidnBuffer 

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

OIDN buffer. Owns or wraps device-accessible memory.

Implementations§

Source§

impl OidnBuffer

Source

pub fn new(device: &OidnDevice, byte_size: usize) -> Result<Self, Error>

Creates a buffer (host and device accessible) of the given size in bytes.

§Errors

Returns Error::OutOfMemory if allocation fails, or an OIDN error from the device.

Source

pub fn new_with_storage( device: &OidnDevice, byte_size: usize, storage: BufferStorage, ) -> Result<Self, Error>

Creates a buffer with the specified storage mode.

§Errors

Returns Error::OutOfMemory if allocation fails, or an OIDN error from the device.

Source

pub unsafe fn new_shared( device: &OidnDevice, dev_ptr: *mut c_void, byte_size: usize, ) -> Result<Self, Error>

Creates a shared buffer from user-owned device memory. OIDN does not take ownership.

§Safety

dev_ptr must point to valid device memory of at least byte_size bytes, and remain valid for the lifetime of OIDN operations using this buffer.

§Errors

Returns Error::OutOfMemory or an OIDN error if creation fails.

Source

pub fn new_shared_from_fd( device: &OidnDevice, fd_type: ExternalMemoryTypeFlag, fd: i32, byte_size: usize, ) -> Result<Self, Error>

Creates a shared buffer from a POSIX file descriptor (e.g. DMA-BUF).

§Errors

Returns Error::OutOfMemory or an OIDN error if creation fails.

Source

pub unsafe fn new_shared_from_win32_handle( device: &OidnDevice, handle_type: ExternalMemoryTypeFlag, handle: *mut c_void, name: *const c_void, byte_size: usize, ) -> Result<Self, Error>

Creates a shared buffer from a Win32 handle.

§Safety

handle and name must be valid for the given handle_type and remain valid for the lifetime of OIDN operations using this buffer.

§Errors

Returns Error::OutOfMemory or an OIDN error if creation fails.

Source

pub unsafe fn new_shared_from_metal( device: &OidnDevice, metal_buffer: *mut c_void, ) -> Result<Self, Error>

Creates a shared buffer from a Metal buffer (MTLBuffer). Only shared/private with hazard tracking.

§Safety

metal_buffer must be a valid MTLBuffer and remain valid for the lifetime of OIDN operations.

§Errors

Returns Error::OutOfMemory or an OIDN error if creation fails.

Source

pub fn size(&self) -> usize

Size in bytes.

Source

pub fn storage(&self) -> BufferStorage

Storage mode.

Source

pub fn data(&self) -> *mut c_void

Raw pointer to buffer data (device-accessible; may be null for device-only storage).

Source

pub unsafe fn read( &self, byte_offset: usize, byte_size: usize, dst: *mut c_void, )

Copies from buffer to host memory (synchronous).

§Safety

dst must point to at least byte_size bytes of valid, writable memory.

Source

pub unsafe fn read_async( &self, byte_offset: usize, byte_size: usize, dst: *mut c_void, )

Copies from buffer to host memory (asynchronous). Call device.sync() before using dst.

§Safety

dst must point to at least byte_size bytes of valid, writable memory.

Source

pub unsafe fn write( &self, byte_offset: usize, byte_size: usize, src: *const c_void, )

Copies from host memory to buffer (synchronous).

§Safety

src must point to at least byte_size bytes of valid, readable memory.

Source

pub unsafe fn write_async( &self, byte_offset: usize, byte_size: usize, src: *const c_void, )

Copies from host memory to buffer (asynchronous). Call device.sync() before using buffer in a filter.

§Safety

src must point to at least byte_size bytes of valid, readable memory.

Source

pub fn retain(&self)

Retains the buffer (increments OIDN reference count). For advanced interop when sharing the buffer.

Trait Implementations§

Source§

impl Debug for OidnBuffer

Source§

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

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

impl Drop for OidnBuffer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for OidnBuffer

Source§

impl Sync for OidnBuffer

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> 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, 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,