Struct vulkano::command_buffer::pool::CommandPool
source · pub struct CommandPool { /* private fields */ }
Expand description
Represents a Vulkan command pool.
A command pool is always tied to a specific queue family. Command buffers allocated from a pool can only be executed on the corresponding queue family.
This struct doesn’t implement the Sync
trait because Vulkan command pools are not thread
safe. In other words, you can only use a pool from one thread at a time.
Implementations
sourceimpl CommandPool
impl CommandPool
sourcepub fn new(
device: Arc<Device>,
create_info: CommandPoolCreateInfo
) -> Result<CommandPool, CommandPoolCreationError>
pub fn new(
device: Arc<Device>,
create_info: CommandPoolCreateInfo
) -> Result<CommandPool, CommandPoolCreationError>
Creates a new CommandPool
.
sourcepub unsafe fn from_handle(
device: Arc<Device>,
handle: CommandPool,
create_info: CommandPoolCreateInfo
) -> CommandPool
pub unsafe fn from_handle(
device: Arc<Device>,
handle: CommandPool,
create_info: CommandPoolCreateInfo
) -> CommandPool
Creates a new UnsafeCommandPool
from a raw object handle.
Safety
handle
must be a valid Vulkan object handle created fromdevice
.create_info
must match the info used to create the object.
sourcepub unsafe fn reset(&self, release_resources: bool) -> Result<(), OomError>
pub unsafe fn reset(&self, release_resources: bool) -> Result<(), OomError>
Resets the pool, which resets all the command buffers that were allocated from it.
If release_resources
is true, it is a hint to the implementation that it should free all
the memory internally allocated for this pool.
Safety
- The command buffers allocated from this pool jump to the initial state.
sourcepub fn allocate_command_buffers(
&self,
allocate_info: CommandBufferAllocateInfo
) -> Result<impl ExactSizeIterator<Item = CommandPoolAlloc>, OomError>
pub fn allocate_command_buffers(
&self,
allocate_info: CommandBufferAllocateInfo
) -> Result<impl ExactSizeIterator<Item = CommandPoolAlloc>, OomError>
Allocates command buffers.
sourcepub unsafe fn free_command_buffers(
&self,
command_buffers: impl IntoIterator<Item = CommandPoolAlloc>
)
pub unsafe fn free_command_buffers(
&self,
command_buffers: impl IntoIterator<Item = CommandPoolAlloc>
)
Frees individual command buffers.
Safety
- The
command_buffers
must have been allocated from this pool. - The
command_buffers
must not be in the pending state.
sourcepub fn trim(&self) -> Result<(), CommandPoolTrimError>
pub fn trim(&self) -> Result<(), CommandPoolTrimError>
Trims a command pool, which recycles unused internal memory from the command pool back to the system.
Command buffers allocated from the pool are not affected by trimming.
This function is supported only if the
khr_maintenance1
extension is
enabled on the device. Otherwise an error is returned.
Since this operation is purely an optimization it is legitimate to call this function and
simply ignore any possible error.
sourcepub fn queue_family_index(&self) -> u32
pub fn queue_family_index(&self) -> u32
Returns the queue family on which command buffers of this pool can be executed.