Graphics‎ > ‎Graphic API‎ > ‎Vulkan‎ > ‎

Drawing

Here are the commands one can use on while recording a command buffer. The buffer need to begin with vkBeginCommandBuffer() first and after all commands are recorded one needs to close it with vkEndCommandBuffer. To submit the command buffer use vkQueueSubmit.

Each command has a small string by it that is my own way of coding the command properties. It tell what command buffer the command can be used on, its relationship to render passes and queue types it can be used at. The format is Command Buffer Levels-Render Pass Scope-Supported Queue types. A command that allows all has the string PS-IO-GCT. Things that are not allowed has an x. Ex Px-Ix-Gxx.

 Command Buffer Levels Render Pass Scope Support Queue types
P : Allowed on primary buffers
S : Allowed on secondary buffers
 I : Allowed inside.
O : Allowed outside.
G : Graphics
C : Compute
T : Transfer

Pseudocode of minimalistic command buffer.

vkBeginCommandBuffer(...);
vkCmdBeginRenderPass(...);
vkCmdBindPipeline(...);
vkCmdBindDescriptorSets(...)
vkCmdDraw(...);
vkCmdEndRenderPass(...);
vkEndCommandBuffer(...);

Secondary command buffers
How to run a secondare command buffer - vkCmdExecuteCommands - Px-IO-GCT
Secondary command buffers can only be run fromn a primary command buffer.


Renderpass
vkCmdBeginRenderPass - Px-xO-Gxx
Render passes can only be started and ended in primary command buffers. It must end in the same buffer that started it.

vkCmdNextSubpass - Px-xI-Gxx
Finalizes the previous subpass and moves on to the next. Can only be called in the primary command buffer.

vkCmdEndRenderPass - Px-xO-Gxx
A render pass must begin and end in the same command buffer. When this is called the store op for all all attachments in the render pass is performed, and the attachment images are transitioned to their final layout.


Clear
Clear a color image outside a render pass - vkCmdClearColorImage -  PS-xO-GCx

Clear depth and stencil outside a render pass - vkCmdClearDepthStencilImage - PS-xO-Gxx

Clear inside a render pass
- vkCmdClearAttachments - PS-Ix-Gxx

Bind
Bind the pipeline - vkCmdBindPipeline - PS-IO-GCx

Bind index buffer - vkCmdBindIndexBuffer - PS-IO-Gxx

Bind vertex buffer - vkCmdBindVertexBuffers - PS-IO-Gxx


Draw
The following commands draw things. For all these commands a graphics pipeline must be bound to the command buffer. What is drawn depends on the pInputAssemblyState settings of the pipeline.

Draw primitives
- vkCmdDraw - PS-Ix-Gxx

Draw indexed primitives - vkCmdDrawIndexed - PS-Ix-Gxx

Indirect draw primitives
- vkCmdDrawIndirect - PS-Ix-Gxx

Indirect draw indexed primitives 
- vkCmdDrawIndexedIndirect - PS-Ix-Gxx

Syncronize
Syncronize has it's own page.


Descriptors
vkCmdBindDescriptorSets - PS-IO-GCT

vkCmdPushConstants -

Set
All these set commands makes it possible to change a part of the state if the pipeline bound allows it. For the function to be used the pipeline should have the state VK_DYNAMIC_STATE_* enabled. If it is enabled the state will be undefined when the pipeline is bound until the values are set with the function. If the state is disabled it will be set when the pipeline is bound and the function should not be called at all.

Sets the dynamic viewport state - vkCmdSetViewport - PS-IO-Gxx
VK_DYNAMIC_STATE_VIEWPORT

Sets the dynamic scissor state - vkCmdSetScissor - PS-IO-Gxx
VK_DYNAMIC_STATE_SCISSOR

Sets the blend constants - vkCmdSetBlendConstants - PS-IO-Gxx
VK_DYNAMIC_STATE_BLEND_CONSTANTS

Sets the depth bias parameters - vkCmdSetDepthBias - PS-IO-Gxx
VK_DYNAMIC_STATE_DEPTH_BIAS

Set the depth bounds - vkCmdSetDepthBounds - PS-IO-Gxx
VK_DYNAMIC_STATE_DEPTH_BOUNDS

Sets the dymamic line width - vkCmdSetLineWidth - PS-IO-Gxx
VK_DYNAMIC_STATE_LINE_WIDTH

Sets the mask value for stencil comparison
- vkCmdSetStencilCompareMask - PS-IO-Gxx
VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK

Sets the reference value for stencil comparisons - vkCmdSetStencilReference - PS-IO-Gxx
VK_DYNAMIC_STATE_STENCIL_REFERENCE

Sets the mask value used for stencil writes - vkCmdSetStencilWriteMask - PS-IO-Gxx
VK_DYNAMIC_STATE_STENCIL_WRITE_MASK

Copy
Copy from one buffer to another - vkCmdCopyBuffer - PS-xO-GCT

Copy from one image to another - vkCmdCopyImage - PS-xO-GCT

Copy from a buffer to a image - vkCmdCopyBufferToImage - PS-xO-GCT

Copy from a image to a buffer - vkCmdCopyImageToBuffer - PS-xO-GCT

Copy a image with scale and filtering - vkCmdBlitImage - PS-xO-Gxx

Turn a multisample image into a non-multisample image
- vkCmdResolveImage - PS-xO-Gxx

Query
vkCmdBeginQuery

vkCmdEndQuery

vkCmdResetQueryPool

vkCmdWriteTimestamp

vkCmdCopyQueryPoolResults


Compute
Dispatch compute work items - vkCmdDispatch - PS-xO-xCx

Dispatch compute work items using indirect parameters - vkCmdDispatchIndirect - PS-xO-xCx

Buffer

Fill a buffer with a fixed value
- vkCmdFillBuffer - PS-xO-GCx

Update a buffer with data from host memory - vkCmdUpdateBuffer - PS-xO-GCT





Comments