class
CommandPoolThe CommandPool class is the primary interface through which one will acquire VkCommandBuffer objects.
Contents
- Reference
The quantity of command buffers is not selected upon construction: only the command buffer level, primary or secondary. Before use, one must call AllocateCmdBuffers or risk exceptions. StartSingleCmdBuffer and EndSingleCmdBuffer can be used to retrieve (relatively wasteful, don't do it while rendering) single-shot command buffers for things like binding resources to sparse buffers, submitting transfers, or performing image layout transitions.'
Public functions
- void ResetCmdPool(const VkCommandPoolResetFlagBits& command_pool_reset_flag_bits = VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT)
- Resets the entire command pool via a call to VkResetCommandPool.
- void ResetCmdBuffer(const size_t& idx, const VkCommandBufferResetFlagBits& command_buffer_reset_flag_bits = VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT)
- Resets the single command buffer at the given index.
- void FreeCommandBuffers()
- Frees the memory used for all command buffers in this pool, which effectively "deletes" them, unlike resetting a single command buffer or even resetting the entire pool.
- auto GetCommandBuffers(const size_t& offset) const -> const VkCommandBuffer*
- Gets a range of command buffers, starting at the given offset.
Function documentation
void vpr:: CommandPool:: ResetCmdPool(const VkCommandPoolResetFlagBits& command_pool_reset_flag_bits = VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT)
Resets the entire command pool via a call to VkResetCommandPool.
Parameters | |
---|---|
command_pool_reset_flag_bits | - Only current options are VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT, the default, or no flags (thus, no resources released) |
Uses VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT by default, which releases all resources that the Vulkan implementation internally allocates. This may take time, and may require re-allocation upon reinitialization but also prevents memory fragmentation when using command pools for quite some time.
void vpr:: CommandPool:: ResetCmdBuffer(const size_t& idx,
const VkCommandBufferResetFlagBits& command_buffer_reset_flag_bits = VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT)
Resets the single command buffer at the given index.
Parameters | |
---|---|
idx | |
command_buffer_reset_flag_bits | - Only current options are VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT, the default, or no flags (thus, no resources released) |
Uses VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT by default, which returns the resources allocated by the Vulkan implementation for this particular command buffer back to the parent pool. Be careful using this in a pool that doesn't have other buffers reset: this can cause memory fragmentation in the command buffer memory resources, which will increase the time it takes for the Vulkan implementation to find a suitable memory location to use (or it will have to allocate more memory).
void vpr:: CommandPool:: FreeCommandBuffers()
Frees the memory used for all command buffers in this pool, which effectively "deletes" them, unlike resetting a single command buffer or even resetting the entire pool.
This will require calling AllocateCmdBuffers again, as it ultimately resets the object into its base state.