Trait vulkano::memory::pool::MemoryPool [] [src]

pub unsafe trait MemoryPool: DeviceOwned {
    type Alloc: MemoryPoolAlloc;
    fn alloc_generic(
        &self,
        ty: MemoryType,
        size: usize,
        alignment: usize,
        layout: AllocLayout,
        map: MappingRequirement
    ) -> Result<Self::Alloc, DeviceMemoryAllocError>; fn alloc_from_requirements<F>(
        &self,
        requirements: &MemoryRequirements,
        layout: AllocLayout,
        map: MappingRequirement,
        dedicated: DedicatedAlloc,
        filter: F
    ) -> Result<PotentialDedicatedAllocation<Self::Alloc>, DeviceMemoryAllocError>
    where
        F: FnMut(MemoryType) -> AllocFromRequirementsFilter
, { ... } }

Pool of GPU-visible memory that can be allocated from.

Associated Types

Object that represents a single allocation. Its destructor should free the chunk.

Required Methods

Allocates memory from the pool.

Safety

Implementation safety:

  • The returned object must match the requirements.
  • When a linear object is allocated next to an optimal object, it is mandatory that the boundary is aligned to the value of the buffer_image_granularity limit.

Note that it is not unsafe to call this function, but it is unsafe to bind the memory returned by this function to a resource.

Panic

  • Panics if memory_type doesn't belong to the same physical device as the device which was used to create this pool.
  • Panics if the memory type is not host-visible and map is MappingRequirement::Map.
  • Panics if size is 0.
  • Panics if alignment is 0.

Provided Methods

Chooses a memory type and allocates memory from it.

Contrary to alloc_generic, this function may allocate a whole new block of memory dedicated to a resource based on requirements.prefer_dedicated.

filter can be used to restrict the memory types and to indicate which are preferred. If map is MappingRequirement::Map, then non-host-visible memory types will automatically be filtered out.

Safety

Implementation safety:

  • The returned object must match the requirements.
  • When a linear object is allocated next to an optimal object, it is mandatory that the boundary is aligned to the value of the buffer_image_granularity limit.
  • If dedicated is not None, the returned memory must either not be dedicated or be dedicated to the resource that was passed.

Note that it is not unsafe to call this function, but it is unsafe to bind the memory returned by this function to a resource.

Panic

  • Panics if no memory type could be found, which can happen if filter is too restrictive.
  • Panics if size is 0.
  • Panics if alignment is 0.

Implementors