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).
For reused memory (Device::new_gpu_buffer) whose previous owner’s GPU work is
still running, it first blocks until that work has completed.
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.