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>

source§

fn clone(&self) -> GenericMemoryAllocatorCreateInfo<'a>

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<'a> Debug for GenericMemoryAllocatorCreateInfo<'a>

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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.
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.
source§

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

Performs the conversion.