Struct StandardCommandBufferAllocator

Source
pub struct StandardCommandBufferAllocator { /* private fields */ }
Expand description

Standard implementation of a command buffer 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 CommandPools, as that is expensive. Alternatively, you can have one locally on a thread for the duration of the thread.

Internally, this allocator keeps one or more CommandPools per queue family index per thread, using Thread-Local Storage. When a thread first allocates, an entry is reserved for the thread and queue family 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 StandardCommandBufferAllocator

Source

pub fn new( device: Arc<Device>, create_info: StandardCommandBufferAllocatorCreateInfo, ) -> Self

Creates a new StandardCommandBufferAllocator.

Source

pub fn try_reset_pool( &self, queue_family_index: u32, flags: CommandPoolResetFlags, ) -> Result<(), Validated<ResetCommandPoolError>>

Tries to reset the CommandPool that’s currently in use for the given queue family index on the current thread.

If successful, the memory of the pool can be reused again along with all command buffers allocated from it. This is only possible if all command buffers allocated from the pool have been dropped.

This has no effect if the entry wasn’t initialized yet or if the entry was cleared.

§Panics
  • Panics if queue_family_index is not less than the number of queue families.
Source

pub fn clear(&self, queue_family_index: u32)

Clears the entry for the given queue family index and the current thread. This does not mean that the pools are dropped immediately. A pool is kept alive for as long as command buffers allocated from it exist.

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

§Panics
  • Panics if queue_family_index is not less than the number of queue families.

Trait Implementations§

Source§

impl CommandBufferAllocator for StandardCommandBufferAllocator

Source§

fn allocate( &self, queue_family_index: u32, level: CommandBufferLevel, ) -> Result<CommandBufferAlloc, Validated<VulkanError>>

Allocates a command buffer.
Source§

unsafe fn deallocate(&self, allocation: CommandBufferAlloc)

Deallocates the given allocation. Read more
Source§

impl Debug for StandardCommandBufferAllocator

Source§

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

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

impl DeviceOwned for StandardCommandBufferAllocator

Source§

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

Returns the device that owns self.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.