pub struct GenericMemoryAllocatorCreateInfo<'b, 'e> {
    pub block_sizes: &'b [(Threshold, BlockSize)],
    pub allocation_type: AllocationType,
    pub dedicated_allocation: bool,
    pub export_handle_types: &'e [ExternalMemoryHandleTypes],
    pub device_address: bool,
    pub _ne: NonExhaustive,
}
Expand description

Parameters to create a new GenericMemoryAllocator.

Fields§

§block_sizes: &'b [(Threshold, BlockSize)]

Lets you configure the block sizes for various heap size classes.

Each entry is a pair of the threshold for the heap size and the block size that should be used for that heap. Must be sorted by threshold and all thresholds must be unique. Must contain a baseline threshold of 0.

The allocator keeps a pool of DeviceMemory blocks for each memory type, so each memory type that resides in a heap whose size crosses one of the thresholds will use the corresponding block size. If multiple thresholds apply to a given heap, the block size corresponding to the largest threshold is chosen.

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.

§allocation_type: AllocationType

The allocation type that should be used for root allocations.

You only need to worry about this if you’re using PoolAllocator as the suballocator, as all suballocations that the pool allocator makes inherit their allocation type from the parent allocation. For the FreeListAllocator and the BuddyAllocator this must be AllocationType::Unknown otherwise you will get panics. It does not matter what this is when using the BumpAllocator.

The default value is AllocationType::Unknown.

§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 made free-standing (root) allocations, just not dedicated ones.

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: &'e [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<'b, 'e> Clone for GenericMemoryAllocatorCreateInfo<'b, 'e>

source§

fn clone(&self) -> GenericMemoryAllocatorCreateInfo<'b, 'e>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'b, 'e> Debug for GenericMemoryAllocatorCreateInfo<'b, 'e>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for GenericMemoryAllocatorCreateInfo<'_, '_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.