pub struct MemoryBlock<M> { /* private fields */ }Expand description
Memory block allocated by GpuAllocator.
Implementations§
Source§impl<M> MemoryBlock<M>
impl<M> MemoryBlock<M>
Sourcepub fn offset(&self) -> u64
pub fn offset(&self) -> u64
Returns offset in bytes from start of memory object to start of this block.
Sourcepub fn props(&self) -> MemoryPropertyFlags
pub fn props(&self) -> MemoryPropertyFlags
Returns memory property flags for parent memory object.
Sourcepub fn memory_type(&self) -> u32
pub fn memory_type(&self) -> u32
Returns index of type of parent memory object.
Sourcepub unsafe fn map<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
size: usize,
) -> Result<NonNull<u8>, MapError>where
MD: MemoryDevice<M>,
pub unsafe fn map<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
size: usize,
) -> Result<NonNull<u8>, MapError>where
MD: MemoryDevice<M>,
Returns pointer to mapped memory range of this block. This blocks becomes mapped.
The user of returned pointer must guarantee that any previously submitted command that writes to this range has completed
before the host reads from or writes to that range,
and that any previously submitted command that reads from that range has completed
before the host writes to that region.
If the device memory was allocated without the HOST_COHERENT property flag set,
these guarantees must be made for an extended range:
the user must round down the start of the range to the nearest multiple of non_coherent_atom_size,
and round the end of the range up to the nearest multiple of non_coherent_atom_size.
§Panics
This function panics if block is currently mapped.
§Safety
block must have been allocated from specified device.
Sourcepub unsafe fn unmap<MD>(&mut self, device: &impl AsRef<MD>) -> boolwhere
MD: MemoryDevice<M>,
pub unsafe fn unmap<MD>(&mut self, device: &impl AsRef<MD>) -> boolwhere
MD: MemoryDevice<M>,
Sourcepub unsafe fn flush_range<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
size: u64,
) -> Result<(), MapError>where
MD: MemoryDevice<M>,
pub unsafe fn flush_range<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
size: u64,
) -> Result<(), MapError>where
MD: MemoryDevice<M>,
Flushes memory range of this block that was previously written to by the host. This function is a no-op if the memory is host-coherent.
Sourcepub unsafe fn invalidate_range<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
size: u64,
) -> Result<(), MapError>where
MD: MemoryDevice<M>,
pub unsafe fn invalidate_range<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
size: u64,
) -> Result<(), MapError>where
MD: MemoryDevice<M>,
Invalidates memory range of this block that was previously written to by the device. This function is a no-op if the memory is host-coherent.
Sourcepub unsafe fn write_bytes<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
data: &[u8],
) -> Result<(), MapError>where
MD: MemoryDevice<M>,
pub unsafe fn write_bytes<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
data: &[u8],
) -> Result<(), MapError>where
MD: MemoryDevice<M>,
Transiently maps block memory range and copies specified data to the mapped memory range.
§Panics
This function panics if block is currently mapped.
§Safety
block must have been allocated from specified device.
The caller must guarantee that any previously submitted command that reads or writes to this range has completed.
Sourcepub unsafe fn read_bytes<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
data: &mut [u8],
) -> Result<(), MapError>where
MD: MemoryDevice<M>,
pub unsafe fn read_bytes<MD>(
&mut self,
device: &impl AsRef<MD>,
offset: u64,
data: &mut [u8],
) -> Result<(), MapError>where
MD: MemoryDevice<M>,
Transiently maps block memory range and copies specified data from the mapped memory range.
§Panics
This function panics if block is currently mapped.
§Safety
block must have been allocated from specified device.
The caller must guarantee that any previously submitted command that reads to this range has completed.