Allocating command buffers
Command buffers are used to store (record) commands that are later submitted to queues, where they are executed and processed by the hardware to give us results. When we have created a command pool, we can use it to allocate command buffers.
How to do it...
- Take the handle of a created logical device and store it in a variable of type
VkDevice
namedlogical_device
. - Take the handle of a command pool and use it to initialize a variable of type
VkCommandPool
namedcommand_pool
. - Create a variable of type
VkCommandBufferAllocateInfo
namedcommand_buffer_allocate_info
and use the following values for its members:VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
value forsType
nullptr
value forpNext
command_pool
variable forcommandPool
VK_COMMAND_BUFFER_LEVEL_PRIMARY
value or aVK_COMMAND_BUFFER_LEVEL_SECONDARY
value forlevel
- The number of command buffers we want to allocate for
commandBufferCount
- Create a vector of type
std::vector<VkCommandBuffer>
namedcommand_buffers...