Struct vulkano::memory::allocator::GenericMemoryAllocatorCreateInfo
source · pub struct GenericMemoryAllocatorCreateInfo<'a> {
pub block_sizes: &'a [DeviceSize],
pub memory_type_bits: u32,
pub dedicated_allocation: bool,
pub export_handle_types: &'a [ExternalMemoryHandleTypes],
pub device_address: bool,
pub _ne: NonExhaustive,
}
Expand description
Parameters to create a new GenericMemoryAllocator
.
Fields§
§block_sizes: &'a [DeviceSize]
Lets you configure the block sizes for each memory type.
Must contain one entry for each memory type. The allocator keeps a pool of DeviceMemory
blocks for each memory type, and every time a new block is allocated, the block size
corresponding to the memory type index is looked up here and used for the allocation.
The block size is going to be the maximum size of a DeviceMemory
block that is tried. If
allocating a block with the size fails, the allocator tries 1/2, 1/4 and 1/8 of the block
size in that order until one succeeds, else a dedicated allocation is attempted for the
allocation. If an allocation is created with a size greater than half the block size it is
always made a dedicated allocation. All of this doesn’t apply when using
MemoryAllocatePreference::NeverAllocate
however.
The default value is &[]
, which must be overridden.
memory_type_bits: u32
Lets you configure the allocator’s global mask of memory type indices. Only the memory type
indices that have a corresponding bit at the same index set will be allocated from when
calling allocate
, otherwise MemoryAllocatorError::FindMemoryType
is returned.
You may use this to disallow problematic memory types, for instance ones with the
PROTECTED
flag, or any other flags you don’t want.
The default value is u32::MAX
.
dedicated_allocation: bool
Whether the allocator should use the dedicated allocation APIs.
This means that when the allocator decides that an allocation should not be suballocated,
but rather have its own block of DeviceMemory
, that that allocation will be made a
dedicated allocation. Otherwise they are still given their own block of device memory, just
that that block won’t be dedicated to a particular resource.
Dedicated allocations are an optimization which may result in better performance, so there really is no reason to disable this option, unless the restrictions that they bring with them are a problem. Namely, a dedicated allocation must only be used for the resource it was created for. Meaning that reusing the memory for something else is not possible, suballocating it is not possible, and aliasing it is also not possible.
This option is silently ignored (treated as false
) if the device API version is below 1.1
and the khr_dedicated_allocation
extension is not enabled on the device.
The default value is true
.
export_handle_types: &'a [ExternalMemoryHandleTypes]
Lets you configure the external memory handle types that the DeviceMemory
blocks will
be allocated with.
Must be either empty or contain one element for each memory type. When DeviceMemory
is
allocated, the external handle types corresponding to the memory type index are looked up
here and used for the allocation.
The default value is &[]
.
device_address: bool
Whether the allocator should allocate the DeviceMemory
blocks with the
DEVICE_ADDRESS
flag set.
This is required if you want to allocate memory for buffers that have the
SHADER_DEVICE_ADDRESS
usage set. For this option too, there is no reason to disable it.
This option is silently ignored (treated as false
) if the buffer_device_address
feature is not enabled on the device or if the ext_buffer_device_address
extension is
enabled on the device. It is also ignored if the device API version is below 1.1 and the
khr_device_group
extension is not enabled on the device.
The default value is true
.
_ne: NonExhaustive
Trait Implementations§
source§impl<'a> Clone for GenericMemoryAllocatorCreateInfo<'a>
impl<'a> Clone for GenericMemoryAllocatorCreateInfo<'a>
source§fn clone(&self) -> GenericMemoryAllocatorCreateInfo<'a>
fn clone(&self) -> GenericMemoryAllocatorCreateInfo<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more