I'm creating my first Vulkan project and I'm at the point where I need to send commands to the GPU. Now I need help understanding how and when commands are being executed and what sort of commands can be sent. I have a working example of where I clear the screen using the following.

Creating the Buffer

VkCommandBufferAllocateInfo commandBufferAllocateInfo{};
commandBufferAllocateInfo.commandPool = engine.pipeline.command_pool;
commandBufferAllocateInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
commandBufferAllocateInfo.commandBufferCount = 1;

VkCommandBuffer commandBuffer = VK_NULL_HANDLE;


Clearing the screen

VkCommandBufferBeginInfo commandBufferBeginInfo{};


VkRect2D renderArea{};
renderArea.offset.x = 0;
renderArea.offset.y = 0;
renderArea.extent = window->GetVulkanSurfaceSize();

std::array<VkClearValue, 2> clearValues{};
// Depth stencil
clearValues[0].depthStencil.depth = 0.0f;
clearValues[0].depthStencil.stencil = 0;
// Color
clearValues[1].color.float32[0] = 0.0f;
clearValues[1].color.float32[1] = 0.0f;
clearValues[1].color.float32[2] = 1.0f;
clearValues[1].color.float32[3] = 0.0f;

VkRenderPassBeginInfo renderPassBeingInfo{};
renderPassBeingInfo.renderPass = engine.window.renderPass;
renderPassBeingInfo.framebuffer = engine.window.framebuffers[engine.window.activeSwapchainImageId]; // Get current frame buffer
renderPassBeingInfo.renderArea = renderArea;
renderPassBeingInfo.clearValueCount = clearValues.size();
renderPassBeingInfo.pClearValues = clearValues.data();


I'm finding it difficult to understand. I see that when you define a CommandBuffer you point to the pool that it will be submitted to, then when you execute the command it gets added to the queue to be processed asynchronously with the logic that is happening CPU side? I'm not sure if that is right.

Also, can the command buffer be used for other commands? and if so, what commands and how would I find example usage of them.

And what is a command pool in the scheme of things that is happening?


2 Answers 2


CommandPool are objects used to manage the allocation of CommandBuffers, and CommandBuffer is used to store the commands.

You almost got the mechanic of a CommandBuffer right.

A command buffer doesn't point to the pool; in fact, a CommandPool allocates the memory for CommandBuffers. The pool isn't the place where a command will be submitted; the place we actually want to submit them is the Queue. We must provide the Queue pointers of all CommandBuffer objects, to be submitted in the struct VkSubmitInfo, and submit them using VkSubmitQueue. After that, the commands in the queue will be taken, and executed.

If you have time, check out some tutorials on Vulkan-Tutorial. It explains everything you need, including the type of commands CommandBuffer stores.

  • 1
    \$\begingroup\$ Thank you for the suggestion of "Vulkan-Tutorial", I have the command buffers set up and have just finished creating the pipeline. They explain everything in an easy to understand, step by step format. Thanks! \$\endgroup\$
    – 0xen
    Jul 13, 2017 at 1:36

The command buffer only starts executing after you submit the buffer to a queue.

All vkCmd* functions will add a command to a command buffer. Every such command is annotated in the spec with where they are allowed to be used (primary command buffer, inside or outside a renderpass) and which queues capabilities it needs.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .