Executing a secondary command buffer inside a primary command buffer
In Vulkan we can record two types of command buffers--primary and secondary. Primary command buffers can be submitted to queues directly. Secondary command buffers can be executed only from within primary command buffers.
How to do it...
- Take a command buffer's handle. Store it in a variable of type
VkCommandBuffer
namedcommand_buffer
. Make sure the command buffer is in the recording state. - Prepare a variable of type
std::vector<VkCommandBuffer>
namedsecondary_command_buffers
containing secondary command buffers that should be executed from within thecommand_buffer
.
- Record the following command:
vkCmdExecuteCommands( command_buffer, static_cast<uint32_t>(secondary_command_buffers.size()), secondary_command_buffers.data() )
. Provide the handle of the primary command buffer, the number of elements in thesecondary_command_buffers
vector, and a pointer to its first element.
How it works...
Secondary command buffers...