[−][src]Trait gpu_alloc::MemoryDevice 
Abstract device that can be used to allocate memory objects.
Required methods
unsafe fn allocate_memory(
    &self, 
    size: u64, 
    memory_type: u32, 
    flags: AllocationFlags
) -> Result<M, OutOfMemory>
&self,
size: u64,
memory_type: u32,
flags: AllocationFlags
) -> Result<M, OutOfMemory>
Allocates new memory object from device. This function may be expensive and even limit maximum number of memory objects allocated. Which is the reason for sub-allocation this crate provides.
Safety
memory_type must be valid index for memory type associated with this device.
Retreiving this information is implementation specific.
flags must be supported by the device.
unsafe fn deallocate_memory(&self, memory: M)
Deallocate memory object.
Safety
Memory object must have been allocated from this device.
All clones of specified memory handle must be dropped before calling this function.
unsafe fn map_memory(
    &self, 
    memory: &M, 
    offset: u64, 
    size: u64
) -> Result<NonNull<u8>, DeviceMapError>
&self,
memory: &M,
offset: u64,
size: u64
) -> Result<NonNull<u8>, DeviceMapError>
Map region of device memory to host memory space.
Safety
- Memory object must have been allocated from this device.
- Memory object must not be already mapped.
- Memory must be allocated from type with HOST_VISIBLEproperty.
- offset + sizemust not overflow.
- offset + sizemust not be larger than memory object size specified when memory object was allocated from this device.
unsafe fn unmap_memory(&self, memory: &M)
Unmap previously mapped memory region.
Safety
- Memory object must have been allocated from this device.
- Memory object must be mapped
unsafe fn invalidate_memory_ranges(
    &self, 
    ranges: &[MappedMemoryRange<'_, M>]
) -> Result<(), OutOfMemory>
&self,
ranges: &[MappedMemoryRange<'_, M>]
) -> Result<(), OutOfMemory>
Invalidates ranges of memory mapped regions.
Safety
- Memory objects must have been allocated from this device.
- offsetand- sizein each element of- rangesmust specify subregion of currently mapped memory region
- if memoryin some element ofrangesdoes not containHOST_COHERENTproperty thenoffsetandsizeof that element must be multiple ofnon_coherent_atom_size.
unsafe fn flush_memory_ranges(
    &self, 
    ranges: &[MappedMemoryRange<'_, M>]
) -> Result<(), OutOfMemory>
&self,
ranges: &[MappedMemoryRange<'_, M>]
) -> Result<(), OutOfMemory>
Flushes ranges of memory mapped regions.
Safety
- Memory objects must have been allocated from this device.
- offsetand- sizein each element of- rangesmust specify subregion of currently mapped memory region
- if memoryin some element ofrangesdoes not containHOST_COHERENTproperty thenoffsetandsizeof that element must be multiple ofnon_coherent_atom_size.