Freeing command buffers
When command buffers are no longer necessary and when they are not pending for execution on a device, they can be freed.
How to do it...
- Take the handle of a logical device and use it to initialize a variable of type
VkDevice
namedlogical_device
. - Take the handle of a command pool created from the logical device. Store this handle in a variable of type
VkCommandPool
namedcommand_pool
. - Create a vector variable with elements of type
VkCommandBuffer
, name the variablecommand_buffers
. Resize the vector to be able to hold all command buffers that should be freed. Initialize the vector's elements with the handles of all the command buffers that should be freed. - Call
vkFreeCommandBuffers( logical_device, command_pool, static_cast<uint32_t>(command_buffers.size()), &command_buffers[0] )
. During the call, provide the handles of the logical device and the command pool, provide the number of elements in thecommand_buffers
vector (the number of command buffers to be freed...