pub struct Buffer { /* private fields */ }Expand description
GPU memory in unified (shared) storage: the CPU reads and writes it in place.
Buffers come from the device’s caching allocator and return to it when dropped. Hazard
tracking is disabled at the Metal level (as in MLX); nuvec orders accesses itself. CPU
access is refused while submitted GPU work uses the buffer, and GPU writes require
&mut Buffer, so the CPU and the GPU never race on it.
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn in_use(&self) -> bool
pub fn in_use(&self) -> bool
Whether submitted GPU work still uses (reads or writes) the buffer.
Sourcepub fn contents(&self) -> Result<&[u8]>
pub fn contents(&self) -> Result<&[u8]>
The bytes, if no submitted GPU work writes the buffer (concurrent GPU reads are fine).
Sourcepub fn contents_mut(&mut self) -> Result<&mut [u8]>
pub fn contents_mut(&mut self) -> Result<&mut [u8]>
The bytes, mutably, if no submitted GPU work uses (reads or writes) the buffer and it is not a read-only mapped file.
Trait Implementations§
Source§impl Drop for Buffer
impl Drop for Buffer
impl Send for Buffer
impl Sync for Buffer
Auto Trait Implementations§
impl !RefUnwindSafe for Buffer
impl !UnwindSafe for Buffer
impl Freeze for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more