pub struct OidnBuffer { /* private fields */ }Expand description
OIDN buffer. Owns or wraps device-accessible memory.
Implementations§
Source§impl OidnBuffer
impl OidnBuffer
Sourcepub fn new(device: &OidnDevice, byte_size: usize) -> Result<Self, Error>
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.
Sourcepub fn new_with_storage(
device: &OidnDevice,
byte_size: usize,
storage: BufferStorage,
) -> Result<Self, Error>
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.
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.
Creates a shared buffer from a POSIX file descriptor (e.g. DMA-BUF).
§Errors
Returns Error::OutOfMemory or an OIDN error if creation fails.
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.
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.
Sourcepub fn storage(&self) -> BufferStorage
pub fn storage(&self) -> BufferStorage
Storage mode.
Sourcepub fn data(&self) -> *mut c_void
pub fn data(&self) -> *mut c_void
Raw pointer to buffer data (device-accessible; may be null for device-only storage).
Sourcepub unsafe fn read(
&self,
byte_offset: usize,
byte_size: usize,
dst: *mut c_void,
)
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.
Sourcepub unsafe fn read_async(
&self,
byte_offset: usize,
byte_size: usize,
dst: *mut c_void,
)
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.
Sourcepub unsafe fn write(
&self,
byte_offset: usize,
byte_size: usize,
src: *const c_void,
)
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.