[][src]Trait gpu_alloc_types::MemoryDevice

pub trait MemoryDevice<M> {
    pub unsafe fn allocate_memory(
        &self,
        size: u64,
        memory_type: u32,
        flags: AllocationFlags
    ) -> Result<M, OutOfMemory>;
pub unsafe fn deallocate_memory(&self, memory: M);
pub unsafe fn map_memory(
        &self,
        memory: &mut M,
        offset: u64,
        size: u64
    ) -> Result<NonNull<u8>, DeviceMapError>;
pub unsafe fn unmap_memory(&self, memory: &mut M);
pub unsafe fn invalidate_memory_ranges(
        &self,
        ranges: &[MappedMemoryRange<'_, M>]
    ) -> Result<(), OutOfMemory>;
pub unsafe fn flush_memory_ranges(
        &self,
        ranges: &[MappedMemoryRange<'_, M>]
    ) -> Result<(), OutOfMemory>; }

Abstract device that can be used to allocate memory objects.

Required methods

pub unsafe fn allocate_memory(
    &self,
    size: u64,
    memory_type: u32,
    flags: AllocationFlags
) -> Result<M, OutOfMemory>
[src]

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.

pub unsafe fn deallocate_memory(&self, memory: M)[src]

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.

pub unsafe fn map_memory(
    &self,
    memory: &mut M,
    offset: u64,
    size: u64
) -> Result<NonNull<u8>, DeviceMapError>
[src]

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_VISIBLE property.
  • offset + size must not overflow.
  • offset + size must not be larger than memory object size specified when memory object was allocated from this device.

pub unsafe fn unmap_memory(&self, memory: &mut M)[src]

Unmap previously mapped memory region.

Safety

  • Memory object must have been allocated from this device.
  • Memory object must be mapped

pub unsafe fn invalidate_memory_ranges(
    &self,
    ranges: &[MappedMemoryRange<'_, M>]
) -> Result<(), OutOfMemory>
[src]

Invalidates ranges of memory mapped regions.

Safety

  • Memory objects must have been allocated from this device.
  • offset and size in each element of ranges must specify subregion of currently mapped memory region
  • if memory in some element of ranges does not contain HOST_COHERENT property then offset and size of that element must be multiple of non_coherent_atom_size.

pub unsafe fn flush_memory_ranges(
    &self,
    ranges: &[MappedMemoryRange<'_, M>]
) -> Result<(), OutOfMemory>
[src]

Flushes ranges of memory mapped regions.

Safety

  • Memory objects must have been allocated from this device.
  • offset and size in each element of ranges must specify subregion of currently mapped memory region
  • if memory in some element of ranges does not contain HOST_COHERENT property then offset and size of that element must be multiple of non_coherent_atom_size.
Loading content...

Implementors

Loading content...