pub struct StandardDescriptorSetAllocator { /* private fields */ }
Expand description

Standard implementation of a descriptor set allocator.

The intended way to use this allocator is to have one that is used globally for the duration of the program, in order to avoid creating and destroying DescriptorPools, as that is expensive. Alternatively, you can have one locally on a thread for the duration of the thread.

Internally, this allocator uses one or more DescriptorPools per descriptor set layout per thread, using Thread-Local Storage. When a thread first allocates, an entry is reserved for the thread and descriptor set layout combination. After a thread exits and the allocator wasn’t dropped yet, its entries are freed, but the pools it used are not dropped. The next time a new thread allocates for the first time, the entries are reused along with the pools. If all threads drop their reference to the allocator, all entries along with the allocator are dropped, even if the threads didn’t exit yet, which is why you should keep the allocator alive for as long as you need to allocate so that the pools can keep being reused.

This allocator only needs to lock when a thread first allocates or when a thread that previously allocated exits. In all other cases, allocation is lock-free.

Implementations§

source§

impl StandardDescriptorSetAllocator

source

pub fn new( device: Arc<Device>, create_info: StandardDescriptorSetAllocatorCreateInfo ) -> StandardDescriptorSetAllocator

Creates a new StandardDescriptorSetAllocator.

source

pub fn clear(&self, layout: &Arc<DescriptorSetLayout>)

Clears the entry for the given descriptor set layout and the current thread. This does not mean that the pools are dropped immediately. A pool is kept alive for as long as descriptor sets allocated from it exist.

This has no effect if the entry was not initialized yet.

source

pub fn clear_all(&self)

Clears all entries for the current thread. This does not mean that the pools are dropped immediately. A pool is kept alive for as long as descriptor sets allocated from it exist.

This has no effect if no entries were initialized yet.

Trait Implementations§

source§

impl Debug for StandardDescriptorSetAllocator

source§

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

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

impl DescriptorSetAllocator for StandardDescriptorSetAllocator

source§

fn allocate( &self, layout: &Arc<DescriptorSetLayout>, variable_descriptor_count: u32 ) -> Result<StandardDescriptorSetAlloc, Validated<VulkanError>>

Allocates a descriptor set.

§

type Alloc = StandardDescriptorSetAlloc

Object that represented an allocated descriptor set. Read more
source§

impl DeviceOwned for StandardDescriptorSetAllocator

source§

fn device(&self) -> &Arc<Device>

Returns the device that owns self.

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, 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.