[−][src]Trait vulkano::memory::pool::MemoryPool
Pool of GPU-visible memory that can be allocated from.
Associated Types
type Alloc: MemoryPoolAlloc
Object that represents a single allocation. Its destructor should free the chunk.
Required methods
fn alloc_generic(
&self,
ty: MemoryType,
size: usize,
alignment: usize,
layout: AllocLayout,
map: MappingRequirement
) -> Result<Self::Alloc, DeviceMemoryAllocError>
&self,
ty: MemoryType,
size: usize,
alignment: usize,
layout: AllocLayout,
map: MappingRequirement
) -> Result<Self::Alloc, DeviceMemoryAllocError>
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
isMappingRequirement::Map
. - Panics if
size
is 0. - Panics if
alignment
is 0.
Provided methods
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,
&self,
requirements: &MemoryRequirements,
layout: AllocLayout,
map: MappingRequirement,
dedicated: DedicatedAlloc,
filter: F
) -> Result<PotentialDedicatedAllocation<Self::Alloc>, DeviceMemoryAllocError> where
F: FnMut(MemoryType) -> AllocFromRequirementsFilter,
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 notNone
, 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.
Implementations on Foreign Types
impl MemoryPool for Arc<StdMemoryPool>
[src]
type Alloc = StdMemoryPoolAlloc
fn alloc_generic(
&self,
memory_type: MemoryType,
size: usize,
alignment: usize,
layout: AllocLayout,
map: MappingRequirement
) -> Result<StdMemoryPoolAlloc, DeviceMemoryAllocError>
[src]
&self,
memory_type: MemoryType,
size: usize,
alignment: usize,
layout: AllocLayout,
map: MappingRequirement
) -> Result<StdMemoryPoolAlloc, DeviceMemoryAllocError>