Vulkan Logo

24. Drawing Commands

Drawing commands (commands with Draw in the name) provoke work in a graphics pipeline. Drawing commands are recorded into a command buffer and when executed by a queue, will produce work which executes according to the bound graphics pipeline, or if the shaderObject feature is enabled, any shader objects bound to graphics stages. A graphics pipeline or a combination of one or more graphics shader objects must be bound to a command buffer before any drawing commands are recorded in that command buffer.

Drawing can be achieved in two modes:

Each draw is made up of zero or more vertices and zero or more instances, which are processed by the device and result in the assembly of primitives. Primitives are assembled according to the pInputAssemblyState member of the VkGraphicsPipelineCreateInfo structure, which is of type VkPipelineInputAssemblyStateCreateInfo:

// Provided by VK_VERSION_1_0
typedef struct VkPipelineInputAssemblyStateCreateInfo {
    VkStructureType                            sType;
    const void*                                pNext;
    VkPipelineInputAssemblyStateCreateFlags    flags;
    VkPrimitiveTopology                        topology;
    VkBool32                                   primitiveRestartEnable;
} VkPipelineInputAssemblyStateCreateInfo;

Restarting the assembly of primitives discards the most recent index values if those elements formed an incomplete primitive, and restarts the primitive assembly using the subsequent indices, but only assembling the immediately following element through the end of the originally specified elements. The primitive restart index value comparison is performed before adding the vertexOffset value to the index value.

Valid Usage
Valid Usage (Implicit)
  • VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType
    sType must be VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO

  • VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext
    pNext must be NULL

  • VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask
    flags must be 0

  • VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter
    topology must be a valid VkPrimitiveTopology value

// Provided by VK_VERSION_1_0
typedef VkFlags VkPipelineInputAssemblyStateCreateFlags;

VkPipelineInputAssemblyStateCreateFlags is a bitmask type for setting a mask, but is currently reserved for future use.

To dynamically control whether a special vertex index value is treated as restarting the assembly of primitives, call:

// Provided by VK_VERSION_1_3
void vkCmdSetPrimitiveRestartEnable(
    VkCommandBuffer                             commandBuffer,
    VkBool32                                    primitiveRestartEnable);
// Provided by VK_EXT_extended_dynamic_state2, VK_EXT_shader_object
// Equivalent to vkCmdSetPrimitiveRestartEnable
void vkCmdSetPrimitiveRestartEnableEXT(
    VkCommandBuffer                             commandBuffer,
    VkBool32                                    primitiveRestartEnable);
  • commandBuffer is the command buffer into which the command will be recorded.

  • primitiveRestartEnable controls whether a special vertex index value is treated as restarting the assembly of primitives. It behaves in the same way as VkPipelineInputAssemblyStateCreateInfo::primitiveRestartEnable

This command sets the primitive restart enable for subsequent drawing commands when drawing using shader objects, or when the graphics pipeline is created with VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE set in VkPipelineDynamicStateCreateInfo::pDynamicStates. Otherwise, this state is specified by the VkPipelineInputAssemblyStateCreateInfo::primitiveRestartEnable value used to create the currently active pipeline.

Valid Usage
  • VUID-vkCmdSetPrimitiveRestartEnable-None-08970
    At least one of the following must be true:

Valid Usage (Implicit)
  • VUID-vkCmdSetPrimitiveRestartEnable-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdSetPrimitiveRestartEnable-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdSetPrimitiveRestartEnable-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdSetPrimitiveRestartEnable-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Both

Outside

VK_QUEUE_GRAPHICS_BIT

State

Conditional Rendering

vkCmdSetPrimitiveRestartEnable is not affected by conditional rendering

24.1. Primitive Topologies

Primitive topology determines how consecutive vertices are organized into primitives, and determines the type of primitive that is used at the beginning of the graphics pipeline. The effective topology for later stages of the pipeline is altered by tessellation or geometry shading (if either is in use) and depends on the execution modes of those shaders. In the case of mesh shading the only effective topology is defined by the execution mode of the mesh shader.

The primitive topologies defined by VkPrimitiveTopology are:

// Provided by VK_VERSION_1_0
typedef enum VkPrimitiveTopology {
    VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0,
    VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1,
    VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2,
    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3,
    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP = 4,
    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN = 5,
    VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY = 6,
    VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY = 7,
    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY = 8,
    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9,
    VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10,
} VkPrimitiveTopology;

Each primitive topology, and its construction from a list of vertices, is described in detail below with a supporting diagram, according to the following key:

image/svg+xml

Vertex

A point in 3-dimensional space. Positions chosen within the diagrams are arbitrary and for illustration only.

image/svg+xml 5

Vertex Number

Sequence position of a vertex within the provided vertex data.

image/svg+xml

Provoking Vertex

Provoking vertex within the main primitive. The tail is angled towards the relevant primitive. Used in flat shading.

image/svg+xml

Primitive Edge

An edge connecting the points of a main primitive.

image/svg+xml

Adjacency Edge

Points connected by these lines do not contribute to a main primitive, and are only accessible in a geometry shader.

image/svg+xml

Winding Order

The relative order in which vertices are defined within a primitive, used in the facing determination. This ordering has no specific start or end point.

The diagrams are supported with mathematical definitions where the vertices (v) and primitives (p) are numbered starting from 0; v0 is the first vertex in the provided data and p0 is the first primitive in the set of primitives defined by the vertices and topology.

To dynamically set primitive topology, call:

// Provided by VK_VERSION_1_3
void vkCmdSetPrimitiveTopology(
    VkCommandBuffer                             commandBuffer,
    VkPrimitiveTopology                         primitiveTopology);
// Provided by VK_EXT_extended_dynamic_state, VK_EXT_shader_object
// Equivalent to vkCmdSetPrimitiveTopology
void vkCmdSetPrimitiveTopologyEXT(
    VkCommandBuffer                             commandBuffer,
    VkPrimitiveTopology                         primitiveTopology);
  • commandBuffer is the command buffer into which the command will be recorded.

  • primitiveTopology specifies the primitive topology to use for drawing.

This command sets the primitive topology for subsequent drawing commands when drawing using shader objects, or when the graphics pipeline is created with VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY set in VkPipelineDynamicStateCreateInfo::pDynamicStates. Otherwise, this state is specified by the VkPipelineInputAssemblyStateCreateInfo::topology value used to create the currently active pipeline.

Valid Usage
  • VUID-vkCmdSetPrimitiveTopology-None-08971
    At least one of the following must be true:

Valid Usage (Implicit)
  • VUID-vkCmdSetPrimitiveTopology-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdSetPrimitiveTopology-primitiveTopology-parameter
    primitiveTopology must be a valid VkPrimitiveTopology value

  • VUID-vkCmdSetPrimitiveTopology-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdSetPrimitiveTopology-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdSetPrimitiveTopology-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Both

Outside

VK_QUEUE_GRAPHICS_BIT

State

Conditional Rendering

vkCmdSetPrimitiveTopology is not affected by conditional rendering

24.1.2. Point Lists

When the topology is VK_PRIMITIVE_TOPOLOGY_POINT_LIST, each consecutive vertex defines a single point primitive, according to the equation:

pi = {vi}

As there is only one vertex, that vertex is the provoking vertex. The number of primitives generated is equal to vertexCount.

image/svg+xml 0 4 2 1 3

24.1.3. Line Lists

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_LINE_LIST, each consecutive pair of vertices defines a single line primitive, according to the equation:

pi = {v2i, v2i+1}

The number of primitives generated is equal to vertexCount/2⌋.

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is v2i.

image/svg+xml 0 2 1 3

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is v2i+1.

image/svg+xml 0 2 1 3

24.1.4. Line Strips

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, one line primitive is defined by each vertex and the following vertex, according to the equation:

pi = {vi, vi+1}

The number of primitives generated is equal to max(0,vertexCount-1).

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is vi.

image/svg+xml 0 2 1 3

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is vi+1.

image/svg+xml 0 2 1 3

24.1.5. Triangle Lists

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, each consecutive set of three vertices defines a single triangle primitive, according to the equation:

pi = {v3i, v3i+1, v3i+2}

The number of primitives generated is equal to vertexCount/3⌋.

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is v3i.

image/svg+xml 2 1 0 3 5 4

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is v3i+2.

image/svg+xml 2 1 0 3 5 4

24.1.6. Triangle Strips

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, one triangle primitive is defined by each vertex and the two vertices that follow it, according to the equation:

pi = {vi, vi+(1+i%2), vi+(2-i%2)}

The number of primitives generated is equal to max(0,vertexCount-2).

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is vi.

image/svg+xml 0 4 2 1 3

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is vi+2.

image/svg+xml 0 4 2 1 3
Note

The ordering of the vertices in each successive triangle is reversed, so that the winding order is consistent throughout the strip.

24.1.7. Triangle Fans

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN, triangle primitives are defined around a shared common vertex, according to the equation:

pi = {vi+1, vi+2, v0}

The number of primitives generated is equal to max(0,vertexCount-2).

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is vi+1.

image/svg+xml 0 4 2 1 3

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is vi+2.

image/svg+xml 0 4 2 1 3
Note

If the VK_KHR_portability_subset extension is enabled, and VkPhysicalDevicePortabilitySubsetFeaturesKHR::triangleFans is VK_FALSE, then triangle fans are not supported by the implementation, and VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN must not be used.

24.1.8. Line Lists With Adjacency

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, each consecutive set of four vertices defines a single line primitive with adjacency, according to the equation:

pi = {v4i, v4i+1, v4i+2,v4i+3}

A line primitive is described by the second and third vertices of the total primitive, with the remaining two vertices only accessible in a geometry shader.

The number of primitives generated is equal to vertexCount/4⌋.

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is v4i+1.

image/svg+xml 0 2 1 3 4 6 5 7

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is v4i+2.

image/svg+xml 0 2 1 3 4 6 5 7

24.1.9. Line Strips With Adjacency

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY, one line primitive with adjacency is defined by each vertex and the following vertex, according to the equation:

pi = {vi, vi+1, vi+2, vi+3}

A line primitive is described by the second and third vertices of the total primitive, with the remaining two vertices only accessible in a geometry shader.

The number of primitives generated is equal to max(0,vertexCount-3).

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is vi+1.

image/svg+xml 0 2 1 3 4 5

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is vi+2.

image/svg+xml 0 2 1 3 4 5

24.1.10. Triangle Lists With Adjacency

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, each consecutive set of six vertices defines a single triangle primitive with adjacency, according to the equations:

pi = {v6i, v6i+1, v6i+2, v6i+3, v6i+4, v6i+5}

A triangle primitive is described by the first, third, and fifth vertices of the total primitive, with the remaining three vertices only accessible in a geometry shader.

The number of primitives generated is equal to vertexCount/6⌋.

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is v6i.

image/svg+xml 0 4 2 1 5 3 6 8 10 11 7 9

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is v6i+4.

image/svg+xml 0 4 2 1 5 3 6 8 10 11 7 9

24.1.11. Triangle Strips With Adjacency

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY, one triangle primitive with adjacency is defined by each vertex and the following 5 vertices.

The number of primitives generated, n, is equal to ⌊max(0, vertexCount - 4)/2⌋.

If n=1, the primitive is defined as:

p = {v0, v1, v2, v5, v4, v3}

If n>1, the total primitive consists of different vertices according to where it is in the strip:

pi = {v2i, v2i+1, v2i+2, v2i+6, v2i+4, v2i+3} when i=0

pi = {v2i, v2i+3, v2i+4, v2i+6, v2i+2, v2i-2} when i>0, i<n-1, and i%2=1

pi = {v2i, v2i-2, v2i+2, v2i+6, v2i+4, v2i+3} when i>0, i<n-1, and i%2=0

pi = {v2i, v2i+3, v2i+4, v2i+5, v2i+2, v2i-2} when i=n-1 and i%2=1

pi = {v2i, v2i-2, v2i+2, v2i+5, v2i+4, v2i+3} when i=n-1 and i%2=0

A triangle primitive is described by the first, third, and fifth vertices of the total primitive in all cases, with the remaining three vertices only accessible in a geometry shader.

Note

The ordering of the vertices in each successive triangle is altered so that the winding order is consistent throughout the strip.

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the provoking vertex for pi is always v2i.

image/svg+xml 0 4 2 1 5 3 2 6 5 7 7 8 9 7 8 10 9 11 0 4 1 3 2 6 5 0 4 1 3 2 6 5 0 4 1 3

When the provokingVertexMode is VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for pi is always v2i+4.

image/svg+xml 0 4 2 1 5 3 2 6 5 7 7 8 9 7 8 10 9 11 0 4 1 3 2 6 5 0 4 1 3 2 6 5 0 4 1 3

24.1.12. Patch Lists

When the primitive topology is VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, each consecutive set of m vertices defines a single patch primitive, according to the equation:

pi = {vmi, vmi+1, …​, vmi+(m-2), vmi+(m-1)}

where m is equal to VkPipelineTessellationStateCreateInfo::patchControlPoints.

Patch lists are never passed to vertex post-processing, and as such no provoking vertex is defined for patch primitives. The number of primitives generated is equal to vertexCount/m⌋.

The vertices comprising a patch have no implied geometry, and are used as inputs to tessellation shaders and the fixed-function tessellator to generate new point, line, or triangle primitives.

24.2. Effective Primitive Topology

The effective primitive topology is the primitive topology that is consumed or produced by a given stage of the graphics pipeline. The interpretation of this topology depends on the active shader stages and other state set in the graphics pipeline.

24.2.1. Vertex Input Assembler Topology

This is the topology set when the VK_SHADER_STAGE_VERTEX_BIT stage is used and Programmable Primitive Shading occurs. It can be set with VkPipelineInputAssemblyStateCreateInfo::topology or vkCmdSetPrimitiveTopology.

24.2.2. Clip Space Topology

This is the output of the last pre-rasterization shader stage involved.

24.2.3. Rasterization Input Topology

After clipping and viewport transformations, the Polygon Mode can set a topology as an input for rasterization. This can be different from what was used in Clip Space Topology.

If VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable or vkCmdSetRasterizerDiscardEnableEXT::rasterizerDiscardEnable is set to VK_FALSE, then this Rasterization Input Topology is not observed.

If the clip space topology is in triangle topology class then VK_POLYGON_MODE_LINE will turn it into line topology and VK_POLYGON_MODE_POINT will turn it into point topology.

If the clip space topology is in line topology class then VK_POLYGON_MODE_POINT will turn it into point topology.

24.3. Primitive Order

Primitives generated by drawing commands progress through the stages of the graphics pipeline in primitive order. Primitive order is initially determined in the following way:

  1. Submission order determines the initial ordering

  2. For indirect drawing commands, the order in which accessed instances of the VkDrawIndirectCommand are stored in buffer, from lower indirect buffer addresses to higher addresses.

  3. If a drawing command includes multiple instances, the order in which instances are executed, from lower numbered instances to higher.

  4. The order in which primitives are specified by a drawing command:

    • For non-indexed draws, from vertices with a lower numbered vertexIndex to a higher numbered vertexIndex.

    • For indexed draws, vertices sourced from a lower index buffer addresses to higher addresses.

    • For draws using mesh shaders, the order is provided by mesh shading.

    • For draws using cluster culling shaders, the order is provided by cluster culling shading.

Within this order implementations further sort primitives:

  1. If tessellation shading is active, by an implementation-dependent order of new primitives generated by tessellation.

  2. If geometry shading is active, by the order new primitives are generated by geometry shading.

  3. If the polygon mode is not VK_POLYGON_MODE_FILL, or VK_POLYGON_MODE_FILL_RECTANGLE_NV, by an implementation-dependent ordering of the new primitives generated within the original primitive.

Primitive order is later used to define rasterization order, which determines the order in which fragments output results to a framebuffer.

24.4. Programmable Primitive Shading

Once primitives are assembled, they proceed to the vertex shading stage of the pipeline. If the draw includes multiple instances, then the set of primitives is sent to the vertex shading stage multiple times, once for each instance.

It is implementation-dependent whether vertex shading occurs on vertices that are discarded as part of incomplete primitives, but if it does occur then it operates as if they were vertices in complete primitives and such invocations can have side effects.

Vertex shading receives two per-vertex inputs from the primitive assembly stage - the vertexIndex and the instanceIndex. How these values are generated is defined below, with each command.

Drawing commands fall roughly into two categories:

To bind an index buffer to a command buffer, call:

// Provided by VK_VERSION_1_0
void vkCmdBindIndexBuffer(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkIndexType                                 indexType);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer being bound.

  • offset is the starting offset in bytes within buffer used in index buffer address calculations.

  • indexType is a VkIndexType value specifying the size of the indices.

If the maintenance6 feature is enabled, buffer can be VK_NULL_HANDLE. If buffer is VK_NULL_HANDLE and the nullDescriptor feature is enabled, every index fetched results in a value of zero.

Valid Usage
  • VUID-vkCmdBindIndexBuffer-offset-08782
    offset must be less than the size of buffer

  • VUID-vkCmdBindIndexBuffer-offset-08783
    The sum of offset and the base address of the range of VkDeviceMemory object that is backing buffer, must be a multiple of the size of the type indicated by indexType

  • VUID-vkCmdBindIndexBuffer-buffer-08784
    buffer must have been created with the VK_BUFFER_USAGE_INDEX_BUFFER_BIT usage flag set

  • VUID-vkCmdBindIndexBuffer-buffer-08785
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdBindIndexBuffer-indexType-08786
    indexType must not be VK_INDEX_TYPE_NONE_KHR

  • VUID-vkCmdBindIndexBuffer-indexType-08787
    If indexType is VK_INDEX_TYPE_UINT8, the indexTypeUint8 feature must be enabled

  • VUID-vkCmdBindIndexBuffer-None-09493
    If the maintenance6 feature is not enabled, buffer must not be VK_NULL_HANDLE

  • VUID-vkCmdBindIndexBuffer-buffer-09494
    If buffer is VK_NULL_HANDLE, offset must be zero

Valid Usage (Implicit)
  • VUID-vkCmdBindIndexBuffer-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdBindIndexBuffer-buffer-parameter
    If buffer is not VK_NULL_HANDLE, buffer must be a valid VkBuffer handle

  • VUID-vkCmdBindIndexBuffer-indexType-parameter
    indexType must be a valid VkIndexType value

  • VUID-vkCmdBindIndexBuffer-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdBindIndexBuffer-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdBindIndexBuffer-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdBindIndexBuffer-commonparent
    Both of buffer, and commandBuffer that are valid handles of non-ignored parameters must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Both

Outside

VK_QUEUE_GRAPHICS_BIT

State

Conditional Rendering

vkCmdBindIndexBuffer is not affected by conditional rendering

To bind an index buffer, along with its size, to a command buffer, call:

// Provided by VK_VERSION_1_4
void vkCmdBindIndexBuffer2(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkDeviceSize                                size,
    VkIndexType                                 indexType);
// Provided by VK_KHR_maintenance5
// Equivalent to vkCmdBindIndexBuffer2
void vkCmdBindIndexBuffer2KHR(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkDeviceSize                                size,
    VkIndexType                                 indexType);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer being bound.

  • offset is the starting offset in bytes within buffer used in index buffer address calculations.

  • size is the size in bytes of index data bound from buffer.

  • indexType is a VkIndexType value specifying the size of the indices.

size specifies the bound size of the index buffer starting from offset. If size is VK_WHOLE_SIZE then the bound size is from offset to the end of the buffer.

If the maintenance6 feature is enabled, buffer can be VK_NULL_HANDLE. If buffer is VK_NULL_HANDLE and the nullDescriptor feature is enabled, every index fetched results in a value of zero.

Valid Usage
  • VUID-vkCmdBindIndexBuffer2-offset-08782
    offset must be less than the size of buffer

  • VUID-vkCmdBindIndexBuffer2-offset-08783
    The sum of offset and the base address of the range of VkDeviceMemory object that is backing buffer, must be a multiple of the size of the type indicated by indexType

  • VUID-vkCmdBindIndexBuffer2-buffer-08784
    buffer must have been created with the VK_BUFFER_USAGE_INDEX_BUFFER_BIT usage flag set

  • VUID-vkCmdBindIndexBuffer2-buffer-08785
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdBindIndexBuffer2-indexType-08786
    indexType must not be VK_INDEX_TYPE_NONE_KHR

  • VUID-vkCmdBindIndexBuffer2-indexType-08787
    If indexType is VK_INDEX_TYPE_UINT8, the indexTypeUint8 feature must be enabled

  • VUID-vkCmdBindIndexBuffer2-None-09493
    If the maintenance6 feature is not enabled, buffer must not be VK_NULL_HANDLE

  • VUID-vkCmdBindIndexBuffer2-buffer-09494
    If buffer is VK_NULL_HANDLE, offset must be zero

  • VUID-vkCmdBindIndexBuffer2-size-08767
    If size is not VK_WHOLE_SIZE, size must be a multiple of the size of the type indicated by indexType

  • VUID-vkCmdBindIndexBuffer2-size-08768
    If size is not VK_WHOLE_SIZE, the sum of offset and size must be less than or equal to the size of buffer

Valid Usage (Implicit)
  • VUID-vkCmdBindIndexBuffer2-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdBindIndexBuffer2-buffer-parameter
    If buffer is not VK_NULL_HANDLE, buffer must be a valid VkBuffer handle

  • VUID-vkCmdBindIndexBuffer2-indexType-parameter
    indexType must be a valid VkIndexType value

  • VUID-vkCmdBindIndexBuffer2-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdBindIndexBuffer2-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdBindIndexBuffer2-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdBindIndexBuffer2-commonparent
    Both of buffer, and commandBuffer that are valid handles of non-ignored parameters must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Both

Outside

VK_QUEUE_GRAPHICS_BIT

State

Conditional Rendering

vkCmdBindIndexBuffer2 is not affected by conditional rendering

Possible values of vkCmdBindIndexBuffer2::indexType and vkCmdBindIndexBuffer::indexType, specifying the size of indices, are:

// Provided by VK_VERSION_1_0
typedef enum VkIndexType {
    VK_INDEX_TYPE_UINT16 = 0,
    VK_INDEX_TYPE_UINT32 = 1,
  // Provided by VK_VERSION_1_4
    VK_INDEX_TYPE_UINT8 = 1000265000,
  // Provided by VK_KHR_acceleration_structure
    VK_INDEX_TYPE_NONE_KHR = 1000165000,
  // Provided by VK_NV_ray_tracing
    VK_INDEX_TYPE_NONE_NV = VK_INDEX_TYPE_NONE_KHR,
  // Provided by VK_EXT_index_type_uint8
    VK_INDEX_TYPE_UINT8_EXT = VK_INDEX_TYPE_UINT8,
  // Provided by VK_KHR_index_type_uint8
    VK_INDEX_TYPE_UINT8_KHR = VK_INDEX_TYPE_UINT8,
} VkIndexType;

The parameters for each drawing command are specified directly in the command or read from buffer memory, depending on the command. Drawing commands that source their parameters from buffer memory are known as indirect drawing commands.

All drawing commands interact with the robustBufferAccess feature.

To record a non-indexed draw, call:

// Provided by VK_VERSION_1_0
void vkCmdDraw(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    vertexCount,
    uint32_t                                    instanceCount,
    uint32_t                                    firstVertex,
    uint32_t                                    firstInstance);
  • commandBuffer is the command buffer into which the command is recorded.

  • vertexCount is the number of vertices to draw.

  • instanceCount is the number of instances to draw.

  • firstVertex is the index of the first vertex to draw.

  • firstInstance is the instance ID of the first instance to draw.

When the command is executed, primitives are assembled using the current primitive topology and vertexCount consecutive vertex indices with the first vertexIndex value equal to firstVertex. The primitives are drawn instanceCount times with instanceIndex starting with firstInstance and increasing sequentially for each instance. The assembled primitives execute the bound graphics pipeline.

Valid Usage
  • VUID-vkCmdDraw-commandBuffer-02712
    If commandBuffer is a protected command buffer and protectedNoFault is not supported, any resource written to by the VkPipeline object bound to the pipeline bind point used by this command must not be an unprotected resource

  • VUID-vkCmdDraw-commandBuffer-02713
    If commandBuffer is a protected command buffer and protectedNoFault is not supported, pipeline stages other than the framebuffer-space and compute stages in the VkPipeline object bound to the pipeline bind point used by this command must not write to any resource

  • VUID-vkCmdDraw-commandBuffer-04617
    If any of the shader stages of the VkPipeline bound to the pipeline bind point used by this command uses the RayQueryKHR capability, then commandBuffer must not be a protected command buffer

Valid Usage (Implicit)
  • VUID-vkCmdDraw-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDraw-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDraw-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDraw-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDraw-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDraw-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDraw is affected by conditional rendering

To record an indexed draw, call:

// Provided by VK_VERSION_1_0
void vkCmdDrawIndexed(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    indexCount,
    uint32_t                                    instanceCount,
    uint32_t                                    firstIndex,
    int32_t                                     vertexOffset,
    uint32_t                                    firstInstance);
  • commandBuffer is the command buffer into which the command is recorded.

  • indexCount is the number of vertices to draw.

  • instanceCount is the number of instances to draw.

  • firstIndex is the base index within the index buffer.

  • vertexOffset is the value added to the vertex index before indexing into the vertex buffer.

  • firstInstance is the instance ID of the first instance to draw.

When the command is executed, primitives are assembled using the current primitive topology and indexCount vertices whose indices are retrieved from the index buffer. The index buffer is treated as an array of tightly packed unsigned integers of size defined by the vkCmdBindIndexBuffer2::indexType or the vkCmdBindIndexBuffer::indexType parameter with which the buffer was bound.

The first vertex index is at an offset of firstIndex × indexSize + offset within the bound index buffer, where offset is the offset specified by vkCmdBindIndexBuffer or vkCmdBindIndexBuffer2, and indexSize is the byte size of the type specified by indexType. Subsequent index values are retrieved from consecutive locations in the index buffer. Indices are first compared to the primitive restart value, then zero extended to 32 bits (if the indexType is VK_INDEX_TYPE_UINT8 or VK_INDEX_TYPE_UINT16) and have vertexOffset added to them, before being supplied as the vertexIndex value.

The primitives are drawn instanceCount times with instanceIndex starting with firstInstance and increasing sequentially for each instance. The assembled primitives execute the bound graphics pipeline.

Valid Usage
  • VUID-vkCmdDrawIndexed-commandBuffer-02712
    If commandBuffer is a protected command buffer and protectedNoFault is not supported, any resource written to by the VkPipeline object bound to the pipeline bind point used by this command must not be an unprotected resource

  • VUID-vkCmdDrawIndexed-commandBuffer-02713
    If commandBuffer is a protected command buffer and protectedNoFault is not supported, pipeline stages other than the framebuffer-space and compute stages in the VkPipeline object bound to the pipeline bind point used by this command must not write to any resource

  • VUID-vkCmdDrawIndexed-commandBuffer-04617
    If any of the shader stages of the VkPipeline bound to the pipeline bind point used by this command uses the RayQueryKHR capability, then commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawIndexed-None-07312
    If the maintenance6 feature is not enabled, a valid index buffer must be bound

  • VUID-vkCmdDrawIndexed-robustBufferAccess2-08798
    If the robustBufferAccess2 feature is not enabled, (indexSize × (firstIndex + indexCount) + offset) must be less than or equal to the size of the bound index buffer, with indexSize being based on the type specified by indexType, where the index buffer, indexType, and offset are specified via vkCmdBindIndexBuffer or vkCmdBindIndexBuffer2. If vkCmdBindIndexBuffer2 is used to bind the index buffer, the size of the bound index buffer is vkCmdBindIndexBuffer2::size

Valid Usage (Implicit)
  • VUID-vkCmdDrawIndexed-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawIndexed-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawIndexed-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawIndexed-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawIndexed-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawIndexed-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawIndexed is affected by conditional rendering

To record an ordered sequence of draws which have no state changes between them, call:

// Provided by VK_EXT_multi_draw
void vkCmdDrawMultiEXT(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    drawCount,
    const VkMultiDrawInfoEXT*                   pVertexInfo,
    uint32_t                                    instanceCount,
    uint32_t                                    firstInstance,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • drawCount is the number of draws to execute, and can be zero.

  • pVertexInfo is a pointer to an array of VkMultiDrawInfoEXT with vertex information to be drawn.

  • instanceCount is the number of instances per draw.

  • firstInstance is the instance ID of the first instance in each draw.

  • stride is the byte stride between consecutive elements of pVertexInfo.

The number of draws recorded is drawCount, with each draw reading, sequentially, a firstVertex and a vertexCount from pVertexInfo. For each recorded draw, primitives are assembled as for vkCmdDraw, and drawn instanceCount times with instanceIndex starting with firstInstance and sequentially for each instance.

Valid Usage
  • VUID-vkCmdDrawMultiEXT-commandBuffer-02712
    If commandBuffer is a protected command buffer and protectedNoFault is not supported, any resource written to by the VkPipeline object bound to the pipeline bind point used by this command must not be an unprotected resource

  • VUID-vkCmdDrawMultiEXT-commandBuffer-02713
    If commandBuffer is a protected command buffer and protectedNoFault is not supported, pipeline stages other than the framebuffer-space and compute stages in the VkPipeline object bound to the pipeline bind point used by this command must not write to any resource

  • VUID-vkCmdDrawMultiEXT-commandBuffer-04617
    If any of the shader stages of the VkPipeline bound to the pipeline bind point used by this command uses the RayQueryKHR capability, then commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawMultiEXT-None-04933
    The multiDraw feature must be enabled

  • VUID-vkCmdDrawMultiEXT-drawCount-04934
    drawCount must be less than VkPhysicalDeviceMultiDrawPropertiesEXT::maxMultiDrawCount

  • VUID-vkCmdDrawMultiEXT-drawCount-04935
    If drawCount is greater than zero, pVertexInfo must be a valid pointer to memory containing one or more valid instances of VkMultiDrawInfoEXT structures

  • VUID-vkCmdDrawMultiEXT-drawCount-09628
    If drawCount is greater than 1, stride must be a multiple of 4 and must be greater than or equal to sizeof(VkMultiDrawInfoEXT)

Valid Usage (Implicit)
  • VUID-vkCmdDrawMultiEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawMultiEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawMultiEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawMultiEXT-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawMultiEXT-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawMultiEXT-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawMultiEXT is affected by conditional rendering

To record an ordered sequence of indexed draws which have no state changes between them, call:

// Provided by VK_EXT_multi_draw
void vkCmdDrawMultiIndexedEXT(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    drawCount,
    const VkMultiDrawIndexedInfoEXT*            pIndexInfo,
    uint32_t                                    instanceCount,
    uint32_t                                    firstInstance,
    uint32_t                                    stride,
    const int32_t*                              pVertexOffset);
  • commandBuffer is the command buffer into which the command is recorded.

  • drawCount is the number of draws to execute, and can be zero.

  • pIndexInfo is a pointer to an array of VkMultiDrawIndexedInfoEXT with index information to be drawn.

  • instanceCount is the number of instances per draw.

  • firstInstance is the instance ID of the first instance in each draw.

  • stride is the byte stride between consecutive elements of pIndexInfo.

  • pVertexOffset is NULL or a pointer to the value added to the vertex index before indexing into the vertex buffer. When specified, VkMultiDrawIndexedInfoEXT::offset is ignored.

The number of draws recorded is drawCount, with each draw reading, sequentially, a firstIndex and an indexCount from pIndexInfo. For each recorded draw, primitives are assembled as for vkCmdDrawIndexed, and drawn instanceCount times with instanceIndex starting with firstInstance and sequentially for each instance. If pVertexOffset is NULL, a vertexOffset is also read from pIndexInfo, otherwise the value from dereferencing pVertexOffset is used.

Valid Usage
  • VUID-vkCmdDrawMultiIndexedEXT-commandBuffer-02712
    If commandBuffer is a protected command buffer and protectedNoFault is not supported, any resource written to by the VkPipeline object bound to the pipeline bind point used by this command must not be an unprotected resource

  • VUID-vkCmdDrawMultiIndexedEXT-commandBuffer-02713
    If commandBuffer is a protected command buffer and protectedNoFault is not supported, pipeline stages other than the framebuffer-space and compute stages in the VkPipeline object bound to the pipeline bind point used by this command must not write to any resource

  • VUID-vkCmdDrawMultiIndexedEXT-commandBuffer-04617
    If any of the shader stages of the VkPipeline bound to the pipeline bind point used by this command uses the RayQueryKHR capability, then commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawMultiIndexedEXT-None-07312
    If the maintenance6 feature is not enabled, a valid index buffer must be bound

  • VUID-vkCmdDrawMultiIndexedEXT-robustBufferAccess2-08798
    If the robustBufferAccess2 feature is not enabled, (indexSize × (firstIndex + indexCount) + offset) must be less than or equal to the size of the bound index buffer, with indexSize being based on the type specified by indexType, where the index buffer, indexType, and offset are specified via vkCmdBindIndexBuffer or vkCmdBindIndexBuffer2. If vkCmdBindIndexBuffer2 is used to bind the index buffer, the size of the bound index buffer is vkCmdBindIndexBuffer2::size

  • VUID-vkCmdDrawMultiIndexedEXT-None-04937
    The multiDraw feature must be enabled

  • VUID-vkCmdDrawMultiIndexedEXT-drawCount-04939
    drawCount must be less than VkPhysicalDeviceMultiDrawPropertiesEXT::maxMultiDrawCount

  • VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940
    If drawCount is greater than zero, pIndexInfo must be a valid pointer to memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures

  • VUID-vkCmdDrawMultiIndexedEXT-drawCount-09629
    If drawCount is greater than 1, stride must be a multiple of 4 and must be greater than or equal to sizeof(VkMultiDrawIndexedInfoEXT)

Valid Usage (Implicit)
  • VUID-vkCmdDrawMultiIndexedEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawMultiIndexedEXT-pVertexOffset-parameter
    If pVertexOffset is not NULL, pVertexOffset must be a valid pointer to a valid int32_t value

  • VUID-vkCmdDrawMultiIndexedEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawMultiIndexedEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawMultiIndexedEXT-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawMultiIndexedEXT-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawMultiIndexedEXT-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawMultiIndexedEXT is affected by conditional rendering

The VkMultiDrawInfoEXT structure is defined as:

// Provided by VK_EXT_multi_draw
typedef struct VkMultiDrawInfoEXT {
    uint32_t    firstVertex;
    uint32_t    vertexCount;
} VkMultiDrawInfoEXT;
  • firstVertex is the first vertex to draw.

  • vertexCount is the number of vertices to draw.

The members of VkMultiDrawInfoEXT have the same meaning as the firstVertex and vertexCount parameters in vkCmdDraw.

The VkMultiDrawIndexedInfoEXT structure is defined as:

// Provided by VK_EXT_multi_draw
typedef struct VkMultiDrawIndexedInfoEXT {
    uint32_t    firstIndex;
    uint32_t    indexCount;
    int32_t     vertexOffset;
} VkMultiDrawIndexedInfoEXT;
  • firstIndex is the first index to draw.

  • indexCount is the number of vertices to draw.

  • vertexOffset is the value added to the vertex index before indexing into the vertex buffer for indexed multidraws.

The firstIndex, indexCount, and vertexOffset members of VkMultiDrawIndexedInfoEXT have the same meaning as the firstIndex, indexCount, and vertexOffset parameters, respectively, of vkCmdDrawIndexed.

To record a non-indexed indirect drawing command, call:

// Provided by VK_VERSION_1_0
void vkCmdDrawIndirect(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    uint32_t                                    drawCount,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

  • drawCount is the number of draws to execute, and can be zero.

  • stride is the byte stride between successive sets of draw parameters.

vkCmdDrawIndirect behaves similarly to vkCmdDraw except that the parameters are read by the device from a buffer during execution. drawCount draws are executed by the command, with parameters taken from buffer starting at offset and increasing by stride bytes for each successive draw. The parameters of each draw are encoded in an array of VkDrawIndirectCommand structures. If drawCount is less than or equal to one, stride is ignored.

Valid Usage
  • VUID-vkCmdDrawIndirect-buffer-02708
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawIndirect-buffer-02709
    buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawIndirect-offset-02710
    offset must be a multiple of 4

  • VUID-vkCmdDrawIndirect-commandBuffer-02711
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawIndirect-drawCount-02718
    If the multiDrawIndirect feature is not enabled, drawCount must be 0 or 1

  • VUID-vkCmdDrawIndirect-drawCount-02719
    drawCount must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawIndirect-drawCount-00476
    If drawCount is greater than 1, stride must be a multiple of 4 and must be greater than or equal to sizeof(VkDrawIndirectCommand)

  • VUID-vkCmdDrawIndirect-drawCount-00487
    If drawCount is equal to 1, (offset + sizeof(VkDrawIndirectCommand)) must be less than or equal to the size of buffer

  • VUID-vkCmdDrawIndirect-drawCount-00488
    If drawCount is greater than 1, (stride × (drawCount - 1) + offset + sizeof(VkDrawIndirectCommand)) must be less than or equal to the size of buffer

Valid Usage (Implicit)
  • VUID-vkCmdDrawIndirect-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawIndirect-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawIndirect-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawIndirect-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawIndirect-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawIndirect-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawIndirect-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawIndirect-commonparent
    Both of buffer, and commandBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawIndirect is affected by conditional rendering

The VkDrawIndirectCommand structure is defined as:

// Provided by VK_VERSION_1_0
typedef struct VkDrawIndirectCommand {
    uint32_t    vertexCount;
    uint32_t    instanceCount;
    uint32_t    firstVertex;
    uint32_t    firstInstance;
} VkDrawIndirectCommand;
  • vertexCount is the number of vertices to draw.

  • instanceCount is the number of instances to draw.

  • firstVertex is the index of the first vertex to draw.

  • firstInstance is the instance ID of the first instance to draw.

The members of VkDrawIndirectCommand have the same meaning as the similarly named parameters of vkCmdDraw.

Valid Usage
  • VUID-VkDrawIndirectCommand-firstInstance-00501
    If the drawIndirectFirstInstance feature is not enabled, firstInstance must be 0

To record a non-indexed draw call with a draw call count sourced from a buffer, call:

// Provided by VK_VERSION_1_2
void vkCmdDrawIndirectCount(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkBuffer                                    countBuffer,
    VkDeviceSize                                countBufferOffset,
    uint32_t                                    maxDrawCount,
    uint32_t                                    stride);
// Provided by VK_KHR_draw_indirect_count
// Equivalent to vkCmdDrawIndirectCount
void vkCmdDrawIndirectCountKHR(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkBuffer                                    countBuffer,
    VkDeviceSize                                countBufferOffset,
    uint32_t                                    maxDrawCount,
    uint32_t                                    stride);
// Provided by VK_AMD_draw_indirect_count
// Equivalent to vkCmdDrawIndirectCount
void vkCmdDrawIndirectCountAMD(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkBuffer                                    countBuffer,
    VkDeviceSize                                countBufferOffset,
    uint32_t                                    maxDrawCount,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

  • countBuffer is the buffer containing the draw count.

  • countBufferOffset is the byte offset into countBuffer where the draw count begins.

  • maxDrawCount specifies the maximum number of draws that will be executed. The actual number of executed draw calls is the minimum of the count specified in countBuffer and maxDrawCount.

  • stride is the byte stride between successive sets of draw parameters.

vkCmdDrawIndirectCount behaves similarly to vkCmdDrawIndirect except that the draw count is read by the device from a buffer during execution. The command will read an unsigned 32-bit integer from countBuffer located at countBufferOffset and use this as the draw count.

Valid Usage
  • VUID-vkCmdDrawIndirectCount-buffer-02708
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawIndirectCount-buffer-02709
    buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawIndirectCount-offset-02710
    offset must be a multiple of 4

  • VUID-vkCmdDrawIndirectCount-commandBuffer-02711
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawIndirectCount-countBuffer-02714
    If countBuffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawIndirectCount-countBuffer-02715
    countBuffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawIndirectCount-countBufferOffset-02716
    countBufferOffset must be a multiple of 4

  • VUID-vkCmdDrawIndirectCount-countBuffer-02717
    The count stored in countBuffer must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawIndirectCount-countBufferOffset-04129
    (countBufferOffset + sizeof(uint32_t)) must be less than or equal to the size of countBuffer

  • VUID-vkCmdDrawIndirectCount-None-04445
    If the drawIndirectCount feature is not enabled this function must not be used

  • VUID-vkCmdDrawIndirectCount-stride-03110
    stride must be a multiple of 4 and must be greater than or equal to sizeof(VkDrawIndirectCommand)

  • VUID-vkCmdDrawIndirectCount-maxDrawCount-03111
    If maxDrawCount is greater than or equal to 1, (stride × (maxDrawCount - 1) + offset + sizeof(VkDrawIndirectCommand)) must be less than or equal to the size of buffer

Valid Usage (Implicit)
  • VUID-vkCmdDrawIndirectCount-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawIndirectCount-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawIndirectCount-countBuffer-parameter
    countBuffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawIndirectCount-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawIndirectCount-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawIndirectCount-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawIndirectCount-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawIndirectCount-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawIndirectCount-commonparent
    Each of buffer, commandBuffer, and countBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawIndirectCount is affected by conditional rendering

To record an indexed indirect drawing command, call:

// Provided by VK_VERSION_1_0
void vkCmdDrawIndexedIndirect(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    uint32_t                                    drawCount,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

  • drawCount is the number of draws to execute, and can be zero.

  • stride is the byte stride between successive sets of draw parameters.

vkCmdDrawIndexedIndirect behaves similarly to vkCmdDrawIndexed except that the parameters are read by the device from a buffer during execution. drawCount draws are executed by the command, with parameters taken from buffer starting at offset and increasing by stride bytes for each successive draw. The parameters of each draw are encoded in an array of VkDrawIndexedIndirectCommand structures. If drawCount is less than or equal to one, stride is ignored.

Valid Usage
  • VUID-vkCmdDrawIndexedIndirect-buffer-02708
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawIndexedIndirect-buffer-02709
    buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawIndexedIndirect-offset-02710
    offset must be a multiple of 4

  • VUID-vkCmdDrawIndexedIndirect-commandBuffer-02711
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawIndexedIndirect-drawCount-02718
    If the multiDrawIndirect feature is not enabled, drawCount must be 0 or 1

  • VUID-vkCmdDrawIndexedIndirect-drawCount-02719
    drawCount must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawIndexedIndirect-None-07312
    If the maintenance6 feature is not enabled, a valid index buffer must be bound

  • VUID-vkCmdDrawIndexedIndirect-drawCount-00528
    If drawCount is greater than 1, stride must be a multiple of 4 and must be greater than or equal to sizeof(VkDrawIndexedIndirectCommand)

  • VUID-vkCmdDrawIndexedIndirect-drawCount-00539
    If drawCount is equal to 1, (offset + sizeof(VkDrawIndexedIndirectCommand)) must be less than or equal to the size of buffer

  • VUID-vkCmdDrawIndexedIndirect-drawCount-00540
    If drawCount is greater than 1, (stride × (drawCount - 1) + offset + sizeof(VkDrawIndexedIndirectCommand)) must be less than or equal to the size of buffer

Valid Usage (Implicit)
  • VUID-vkCmdDrawIndexedIndirect-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawIndexedIndirect-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawIndexedIndirect-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawIndexedIndirect-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawIndexedIndirect-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawIndexedIndirect-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawIndexedIndirect-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawIndexedIndirect-commonparent
    Both of buffer, and commandBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawIndexedIndirect is affected by conditional rendering

The VkDrawIndexedIndirectCommand structure is defined as:

// Provided by VK_VERSION_1_0
typedef struct VkDrawIndexedIndirectCommand {
    uint32_t    indexCount;
    uint32_t    instanceCount;
    uint32_t    firstIndex;
    int32_t     vertexOffset;
    uint32_t    firstInstance;
} VkDrawIndexedIndirectCommand;
  • indexCount is the number of vertices to draw.

  • instanceCount is the number of instances to draw.

  • firstIndex is the base index within the index buffer.

  • vertexOffset is the value added to the vertex index before indexing into the vertex buffer.

  • firstInstance is the instance ID of the first instance to draw.

The members of VkDrawIndexedIndirectCommand have the same meaning as the similarly named parameters of vkCmdDrawIndexed.

Valid Usage
  • VUID-VkDrawIndexedIndirectCommand-robustBufferAccess2-08798
    If the robustBufferAccess2 feature is not enabled, (indexSize × (firstIndex + indexCount) + offset) must be less than or equal to the size of the bound index buffer, with indexSize being based on the type specified by indexType, where the index buffer, indexType, and offset are specified via vkCmdBindIndexBuffer or vkCmdBindIndexBuffer2. If vkCmdBindIndexBuffer2 is used to bind the index buffer, the size of the bound index buffer is vkCmdBindIndexBuffer2::size

  • VUID-VkDrawIndexedIndirectCommand-firstInstance-00554
    If the drawIndirectFirstInstance feature is not enabled, firstInstance must be 0

To record an indexed draw call with a draw call count sourced from a buffer, call:

// Provided by VK_VERSION_1_2
void vkCmdDrawIndexedIndirectCount(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkBuffer                                    countBuffer,
    VkDeviceSize                                countBufferOffset,
    uint32_t                                    maxDrawCount,
    uint32_t                                    stride);
// Provided by VK_KHR_draw_indirect_count
// Equivalent to vkCmdDrawIndexedIndirectCount
void vkCmdDrawIndexedIndirectCountKHR(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkBuffer                                    countBuffer,
    VkDeviceSize                                countBufferOffset,
    uint32_t                                    maxDrawCount,
    uint32_t                                    stride);
// Provided by VK_AMD_draw_indirect_count
// Equivalent to vkCmdDrawIndexedIndirectCount
void vkCmdDrawIndexedIndirectCountAMD(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkBuffer                                    countBuffer,
    VkDeviceSize                                countBufferOffset,
    uint32_t                                    maxDrawCount,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

  • countBuffer is the buffer containing the draw count.

  • countBufferOffset is the byte offset into countBuffer where the draw count begins.

  • maxDrawCount specifies the maximum number of draws that will be executed. The actual number of executed draw calls is the minimum of the count specified in countBuffer and maxDrawCount.

  • stride is the byte stride between successive sets of draw parameters.

vkCmdDrawIndexedIndirectCount behaves similarly to vkCmdDrawIndexedIndirect except that the draw count is read by the device from a buffer during execution. The command will read an unsigned 32-bit integer from countBuffer located at countBufferOffset and use this as the draw count.

Valid Usage
  • VUID-vkCmdDrawIndexedIndirectCount-buffer-02708
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawIndexedIndirectCount-buffer-02709
    buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawIndexedIndirectCount-offset-02710
    offset must be a multiple of 4

  • VUID-vkCmdDrawIndexedIndirectCount-commandBuffer-02711
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawIndexedIndirectCount-countBuffer-02714
    If countBuffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawIndexedIndirectCount-countBuffer-02715
    countBuffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716
    countBufferOffset must be a multiple of 4

  • VUID-vkCmdDrawIndexedIndirectCount-countBuffer-02717
    The count stored in countBuffer must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-04129
    (countBufferOffset + sizeof(uint32_t)) must be less than or equal to the size of countBuffer

  • VUID-vkCmdDrawIndexedIndirectCount-None-04445
    If the drawIndirectCount feature is not enabled this function must not be used

  • VUID-vkCmdDrawIndexedIndirectCount-None-07312
    If the maintenance6 feature is not enabled, a valid index buffer must be bound

  • VUID-vkCmdDrawIndexedIndirectCount-stride-03142
    stride must be a multiple of 4 and must be greater than or equal to sizeof(VkDrawIndexedIndirectCommand)

  • VUID-vkCmdDrawIndexedIndirectCount-maxDrawCount-03143
    If maxDrawCount is greater than or equal to 1, (stride × (maxDrawCount - 1) + offset + sizeof(VkDrawIndexedIndirectCommand)) must be less than or equal to the size of buffer

Valid Usage (Implicit)
  • VUID-vkCmdDrawIndexedIndirectCount-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawIndexedIndirectCount-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawIndexedIndirectCount-countBuffer-parameter
    countBuffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawIndexedIndirectCount-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawIndexedIndirectCount-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawIndexedIndirectCount-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawIndexedIndirectCount-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawIndexedIndirectCount-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawIndexedIndirectCount-commonparent
    Each of buffer, commandBuffer, and countBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawIndexedIndirectCount is affected by conditional rendering

24.4.1. Drawing Transform Feedback

It is possible to draw vertex data that was previously captured during active transform feedback by binding one or more of the transform feedback buffers as vertex buffers. A pipeline barrier is required between using the buffers as transform feedback buffers and vertex buffers to ensure all writes to the transform feedback buffers are visible when the data is read as vertex attributes. The source access is VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT and the destination access is VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT for the pipeline stages VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT and VK_PIPELINE_STAGE_VERTEX_INPUT_BIT respectively. The value written to the counter buffer by vkCmdEndTransformFeedbackEXT can be used to determine the vertex count for the draw. A pipeline barrier is required between using the counter buffer for vkCmdEndTransformFeedbackEXT and vkCmdDrawIndirectByteCountEXT where the source access is VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT and the destination access is VK_ACCESS_INDIRECT_COMMAND_READ_BIT for the pipeline stages VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT and VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT respectively.

To record a non-indexed draw call, where the vertex count is based on a byte count read from a buffer and the passed in vertex stride parameter, call:

// Provided by VK_EXT_transform_feedback
void vkCmdDrawIndirectByteCountEXT(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    instanceCount,
    uint32_t                                    firstInstance,
    VkBuffer                                    counterBuffer,
    VkDeviceSize                                counterBufferOffset,
    uint32_t                                    counterOffset,
    uint32_t                                    vertexStride);
  • commandBuffer is the command buffer into which the command is recorded.

  • instanceCount is the number of instances to draw.

  • firstInstance is the instance ID of the first instance to draw.

  • counterBuffer is the buffer handle from where the byte count is read.

  • counterBufferOffset is the offset into the buffer used to read the byte count, which is used to calculate the vertex count for this draw call.

  • counterOffset is subtracted from the byte count read from the counterBuffer at the counterBufferOffset

  • vertexStride is the stride in bytes between each element of the vertex data that is used to calculate the vertex count from the counter value. This value is typically the same value that was used in the graphics pipeline state when the transform feedback was captured as the XfbStride.

When the command is executed, primitives are assembled in the same way as done with vkCmdDraw except the vertexCount is calculated based on the byte count read from counterBuffer at offset counterBufferOffset. The assembled primitives execute the bound graphics pipeline.

The effective vertexCount is calculated as follows:

const uint32_t * counterBufferPtr = (const uint8_t *)counterBuffer.address + counterBufferOffset;
vertexCount = floor(max(0, (*counterBufferPtr - counterOffset)) / vertexStride);

The effective firstVertex is zero.

Valid Usage
  • VUID-vkCmdDrawIndirectByteCountEXT-transformFeedback-02287
    VkPhysicalDeviceTransformFeedbackFeaturesEXT::transformFeedback must be enabled

  • VUID-vkCmdDrawIndirectByteCountEXT-transformFeedbackDraw-02288
    The implementation must support VkPhysicalDeviceTransformFeedbackPropertiesEXT::transformFeedbackDraw

  • VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289
    vertexStride must be greater than 0 and less than or equal to VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferDataStride

  • VUID-vkCmdDrawIndirectByteCountEXT-counterBuffer-04567
    If counterBuffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawIndirectByteCountEXT-counterBuffer-02290
    counterBuffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568
    counterBufferOffset must be a multiple of 4

  • VUID-vkCmdDrawIndirectByteCountEXT-counterOffset-09474
    counterOffset must be a multiple of 4

  • VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-09475
    vertexStride must be a multiple of 4

  • VUID-vkCmdDrawIndirectByteCountEXT-commandBuffer-02646
    commandBuffer must not be a protected command buffer

Valid Usage (Implicit)
  • VUID-vkCmdDrawIndirectByteCountEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawIndirectByteCountEXT-counterBuffer-parameter
    counterBuffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawIndirectByteCountEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawIndirectByteCountEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawIndirectByteCountEXT-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawIndirectByteCountEXT-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawIndirectByteCountEXT-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawIndirectByteCountEXT-commonparent
    Both of commandBuffer, and counterBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawIndirectByteCountEXT is affected by conditional rendering

24.5. Conditional Rendering

Certain rendering commands can be executed conditionally based on a value in buffer memory. These rendering commands are limited to drawing commands, dispatching commands, and clearing attachments with vkCmdClearAttachments within a conditional rendering block which is defined by commands vkCmdBeginConditionalRenderingEXT and vkCmdEndConditionalRenderingEXT. Other rendering commands remain unaffected by conditional rendering.

The complete list of commands affected by conditional rendering is:

After beginning conditional rendering, it is considered active within the command buffer it was called until it is ended with vkCmdEndConditionalRenderingEXT.

Conditional rendering must begin and end in the same command buffer. When conditional rendering is active, a primary command buffer can execute secondary command buffers if the inheritedConditionalRendering feature is enabled. For a secondary command buffer to be executed while conditional rendering is active in the primary command buffer, it must set the conditionalRenderingEnable flag of VkCommandBufferInheritanceConditionalRenderingInfoEXT, as described in the Command Buffer Recording section.

Conditional rendering must also either begin and end inside the same subpass of a render pass instance, or must both begin and end outside of a render pass instance (i.e. contain entire render pass instances).

To begin conditional rendering, call:

// Provided by VK_EXT_conditional_rendering
void vkCmdBeginConditionalRenderingEXT(
    VkCommandBuffer                             commandBuffer,
    const VkConditionalRenderingBeginInfoEXT*   pConditionalRenderingBegin);
  • commandBuffer is the command buffer into which this command will be recorded.

  • pConditionalRenderingBegin is a pointer to a VkConditionalRenderingBeginInfoEXT structure specifying parameters of conditional rendering.

Valid Usage
  • VUID-vkCmdBeginConditionalRenderingEXT-None-01980
    Conditional rendering must not already be active

Valid Usage (Implicit)
  • VUID-vkCmdBeginConditionalRenderingEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdBeginConditionalRenderingEXT-pConditionalRenderingBegin-parameter
    pConditionalRenderingBegin must be a valid pointer to a valid VkConditionalRenderingBeginInfoEXT structure

  • VUID-vkCmdBeginConditionalRenderingEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdBeginConditionalRenderingEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_COMPUTE_BIT, or VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdBeginConditionalRenderingEXT-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdBeginConditionalRenderingEXT-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Both

Outside

VK_QUEUE_COMPUTE_BIT
VK_QUEUE_GRAPHICS_BIT

Action
State

Conditional Rendering

vkCmdBeginConditionalRenderingEXT is not affected by conditional rendering

The VkConditionalRenderingBeginInfoEXT structure is defined as:

// Provided by VK_EXT_conditional_rendering
typedef struct VkConditionalRenderingBeginInfoEXT {
    VkStructureType                   sType;
    const void*                       pNext;
    VkBuffer                          buffer;
    VkDeviceSize                      offset;
    VkConditionalRenderingFlagsEXT    flags;
} VkConditionalRenderingBeginInfoEXT;
  • sType is a VkStructureType value identifying this structure.

  • pNext is NULL or a pointer to a structure extending this structure.

  • buffer is a buffer containing the predicate for conditional rendering.

  • offset is the byte offset into buffer where the predicate is located.

  • flags is a bitmask of VkConditionalRenderingFlagsEXT specifying the behavior of conditional rendering.

If the 32-bit value at offset in buffer memory is zero, then the rendering commands are discarded, otherwise they are executed as normal. If the value of the predicate in buffer memory changes while conditional rendering is active, the rendering commands may be discarded in an implementation-dependent way. Some implementations may latch the value of the predicate upon beginning conditional rendering while others may read it before every rendering command.

Valid Usage
  • VUID-VkConditionalRenderingBeginInfoEXT-buffer-01981
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-VkConditionalRenderingBeginInfoEXT-buffer-01982
    buffer must have been created with the VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT usage flag set

  • VUID-VkConditionalRenderingBeginInfoEXT-offset-01983
    offset must be less than the size of buffer by at least 32 bits

  • VUID-VkConditionalRenderingBeginInfoEXT-offset-01984
    offset must be a multiple of 4

Valid Usage (Implicit)

Bits which can be set in vkCmdBeginConditionalRenderingEXT::flags, specifying the behavior of conditional rendering, are:

// Provided by VK_EXT_conditional_rendering
typedef enum VkConditionalRenderingFlagBitsEXT {
    VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT = 0x00000001,
} VkConditionalRenderingFlagBitsEXT;
  • VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT specifies the condition used to determine whether to discard rendering commands or not. That is, if the 32-bit predicate read from buffer memory at offset is zero, the rendering commands are not discarded, and if non zero, then they are discarded.

// Provided by VK_EXT_conditional_rendering
typedef VkFlags VkConditionalRenderingFlagsEXT;

VkConditionalRenderingFlagsEXT is a bitmask type for setting a mask of zero or more VkConditionalRenderingFlagBitsEXT.

To end conditional rendering, call:

// Provided by VK_EXT_conditional_rendering
void vkCmdEndConditionalRenderingEXT(
    VkCommandBuffer                             commandBuffer);
  • commandBuffer is the command buffer into which this command will be recorded.

Once ended, conditional rendering becomes inactive.

Valid Usage
  • VUID-vkCmdEndConditionalRenderingEXT-None-01985
    Conditional rendering must be active

  • VUID-vkCmdEndConditionalRenderingEXT-None-01986
    If conditional rendering was made active outside of a render pass instance, it must not be ended inside a render pass instance

  • VUID-vkCmdEndConditionalRenderingEXT-None-01987
    If conditional rendering was made active within a subpass it must be ended in the same subpass

Valid Usage (Implicit)
  • VUID-vkCmdEndConditionalRenderingEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdEndConditionalRenderingEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdEndConditionalRenderingEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_COMPUTE_BIT, or VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdEndConditionalRenderingEXT-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdEndConditionalRenderingEXT-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Both

Outside

VK_QUEUE_COMPUTE_BIT
VK_QUEUE_GRAPHICS_BIT

Action
State

Conditional Rendering

vkCmdEndConditionalRenderingEXT is not affected by conditional rendering

24.6. Programmable Mesh Shading

In this drawing approach, primitives are assembled by the mesh shader stage. Mesh shading operates similarly to dispatching compute as the shaders make use of workgroups.

To record a mesh tasks drawing command, call:

// Provided by VK_NV_mesh_shader
void vkCmdDrawMeshTasksNV(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    taskCount,
    uint32_t                                    firstTask);
  • commandBuffer is the command buffer into which the command will be recorded.

  • taskCount is the number of local workgroups to dispatch in the X dimension. Y and Z dimension are implicitly set to one.

  • firstTask is the X component of the first workgroup ID.

When the command is executed, a global workgroup consisting of taskCount local workgroups is assembled.

Valid Usage
Valid Usage (Implicit)
  • VUID-vkCmdDrawMeshTasksNV-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawMeshTasksNV-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawMeshTasksNV-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawMeshTasksNV-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawMeshTasksNV-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawMeshTasksNV-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawMeshTasksNV is affected by conditional rendering

To record an indirect mesh tasks drawing command, call:

// Provided by VK_NV_mesh_shader
void vkCmdDrawMeshTasksIndirectNV(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    uint32_t                                    drawCount,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

  • drawCount is the number of draws to execute, and can be zero.

  • stride is the byte stride between successive sets of draw parameters.

vkCmdDrawMeshTasksIndirectNV behaves similarly to vkCmdDrawMeshTasksNV except that the parameters are read by the device from a buffer during execution. drawCount draws are executed by the command, with parameters taken from buffer starting at offset and increasing by stride bytes for each successive draw. The parameters of each draw are encoded in an array of VkDrawMeshTasksIndirectCommandNV structures. If drawCount is less than or equal to one, stride is ignored.

Valid Usage
  • VUID-vkCmdDrawMeshTasksIndirectNV-buffer-02708
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawMeshTasksIndirectNV-buffer-02709
    buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710
    offset must be a multiple of 4

  • VUID-vkCmdDrawMeshTasksIndirectNV-commandBuffer-02711
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718
    If the multiDrawIndirect feature is not enabled, drawCount must be 0 or 1

  • VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719
    drawCount must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146
    If drawCount is greater than 1, stride must be a multiple of 4 and must be greater than or equal to sizeof(VkDrawMeshTasksIndirectCommandNV)

  • VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02156
    If drawCount is equal to 1, (offset + sizeof(VkDrawMeshTasksIndirectCommandNV)) must be less than or equal to the size of buffer

  • VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02157
    If drawCount is greater than 1, (stride × (drawCount - 1) + offset + sizeof(VkDrawMeshTasksIndirectCommandNV)) must be less than or equal to the size of buffer

  • VUID-vkCmdDrawMeshTasksIndirectNV-MeshNV-07081
    The current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS must contain a shader stage using the MeshNV Execution Model

Valid Usage (Implicit)
  • VUID-vkCmdDrawMeshTasksIndirectNV-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectNV-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectNV-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawMeshTasksIndirectNV-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawMeshTasksIndirectNV-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawMeshTasksIndirectNV-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawMeshTasksIndirectNV-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawMeshTasksIndirectNV-commonparent
    Both of buffer, and commandBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawMeshTasksIndirectNV is affected by conditional rendering

The VkDrawMeshTasksIndirectCommandNV structure is defined as:

// Provided by VK_NV_mesh_shader
typedef struct VkDrawMeshTasksIndirectCommandNV {
    uint32_t    taskCount;
    uint32_t    firstTask;
} VkDrawMeshTasksIndirectCommandNV;
  • taskCount is the number of local workgroups to dispatch in the X dimension. Y and Z dimension are implicitly set to one.

  • firstTask is the X component of the first workgroup ID.

The members of VkDrawMeshTasksIndirectCommandNV have the same meaning as the similarly named parameters of vkCmdDrawMeshTasksNV.

Valid Usage
  • VUID-VkDrawMeshTasksIndirectCommandNV-taskCount-02175
    taskCount must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount

To record an indirect mesh tasks drawing command with the draw count sourced from a buffer, call:

// Provided by VK_NV_mesh_shader with (VK_VERSION_1_2 or VK_KHR_draw_indirect_count) or VK_AMD_draw_indirect_count
void vkCmdDrawMeshTasksIndirectCountNV(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkBuffer                                    countBuffer,
    VkDeviceSize                                countBufferOffset,
    uint32_t                                    maxDrawCount,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

  • countBuffer is the buffer containing the draw count.

  • countBufferOffset is the byte offset into countBuffer where the draw count begins.

  • maxDrawCount specifies the maximum number of draws that will be executed. The actual number of executed draw calls is the minimum of the count specified in countBuffer and maxDrawCount.

  • stride is the byte stride between successive sets of draw parameters.

vkCmdDrawMeshTasksIndirectCountNV behaves similarly to vkCmdDrawMeshTasksIndirectNV except that the draw count is read by the device from a buffer during execution. The command will read an unsigned 32-bit integer from countBuffer located at countBufferOffset and use this as the draw count.

Valid Usage
  • VUID-vkCmdDrawMeshTasksIndirectCountNV-buffer-02708
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-buffer-02709
    buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710
    offset must be a multiple of 4

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-commandBuffer-02711
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-countBuffer-02714
    If countBuffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-countBuffer-02715
    countBuffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716
    countBufferOffset must be a multiple of 4

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-countBuffer-02717
    The count stored in countBuffer must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-04129
    (countBufferOffset + sizeof(uint32_t)) must be less than or equal to the size of countBuffer

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-None-04445
    If the drawIndirectCount feature is not enabled this function must not be used

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-stride-02182
    stride must be a multiple of 4 and must be greater than or equal to sizeof(VkDrawMeshTasksIndirectCommandNV)

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-maxDrawCount-02183
    If maxDrawCount is greater than or equal to 1, (stride × (maxDrawCount - 1) + offset + sizeof(VkDrawMeshTasksIndirectCommandNV)) must be less than or equal to the size of buffer

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-MeshNV-07082
    The current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS must contain a shader stage using the MeshNV Execution Model

Valid Usage (Implicit)
  • VUID-vkCmdDrawMeshTasksIndirectCountNV-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-countBuffer-parameter
    countBuffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawMeshTasksIndirectCountNV-commonparent
    Each of buffer, commandBuffer, and countBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawMeshTasksIndirectCountNV is affected by conditional rendering

To record a mesh tasks drawing command, call:

// Provided by VK_EXT_mesh_shader
void vkCmdDrawMeshTasksEXT(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    groupCountX,
    uint32_t                                    groupCountY,
    uint32_t                                    groupCountZ);
  • commandBuffer is the command buffer into which the command will be recorded.

  • groupCountX is the number of local workgroups to dispatch in the X dimension.

  • groupCountY is the number of local workgroups to dispatch in the Y dimension.

  • groupCountZ is the number of local workgroups to dispatch in the Z dimension.

When the command is executed, a global workgroup consisting of groupCountX × groupCountY × groupCountZ local workgroups is assembled.

Valid Usage
  • VUID-vkCmdDrawMeshTasksEXT-TaskEXT-07322
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS contains a shader using the TaskEXT Execution Model, groupCountX must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxTaskWorkGroupCount[0]

  • VUID-vkCmdDrawMeshTasksEXT-TaskEXT-07323
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS contains a shader using the TaskEXT Execution Model, groupCountY must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxTaskWorkGroupCount[1]

  • VUID-vkCmdDrawMeshTasksEXT-TaskEXT-07324
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS contains a shader using the TaskEXT Execution Model, groupCountZ must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxTaskWorkGroupCount[2]

  • VUID-vkCmdDrawMeshTasksEXT-TaskEXT-07325
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS contains a shader using the TaskEXT Execution Model, The product of groupCountX, groupCountY and groupCountZ must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxTaskWorkGroupTotalCount

  • VUID-vkCmdDrawMeshTasksEXT-TaskEXT-07326
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS does not contain a shader using the TaskEXT Execution Model, groupCountX must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshWorkGroupCount[0]

  • VUID-vkCmdDrawMeshTasksEXT-TaskEXT-07327
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS does not contain a shader using the TaskEXT Execution Model, groupCountY must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshWorkGroupCount[1]

  • VUID-vkCmdDrawMeshTasksEXT-TaskEXT-07328
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS does not contain a shader using the TaskEXT Execution Model, groupCountZ must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshWorkGroupCount[2]

  • VUID-vkCmdDrawMeshTasksEXT-TaskEXT-07329
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS does not contain a shader using the TaskEXT Execution Model, The product of groupCountX, groupCountY and groupCountZ must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshWorkGroupTotalCount

  • VUID-vkCmdDrawMeshTasksEXT-MeshEXT-07087
    The current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS must contain a shader stage using the MeshEXT Execution Model

Valid Usage (Implicit)
  • VUID-vkCmdDrawMeshTasksEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawMeshTasksEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawMeshTasksEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawMeshTasksEXT-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawMeshTasksEXT-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawMeshTasksEXT-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawMeshTasksEXT is affected by conditional rendering

To record an indirect mesh tasks drawing command, call:

// Provided by VK_EXT_mesh_shader
void vkCmdDrawMeshTasksIndirectEXT(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    uint32_t                                    drawCount,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

  • drawCount is the number of draws to execute, and can be zero.

  • stride is the byte stride between successive sets of draw parameters.

vkCmdDrawMeshTasksIndirectEXT behaves similarly to vkCmdDrawMeshTasksEXT except that the parameters are read by the device from a buffer during execution. drawCount draws are executed by the command, with parameters taken from buffer starting at offset and increasing by stride bytes for each successive draw. The parameters of each draw are encoded in an array of VkDrawMeshTasksIndirectCommandEXT structures. If drawCount is less than or equal to one, stride is ignored.

Valid Usage
  • VUID-vkCmdDrawMeshTasksIndirectEXT-buffer-02708
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawMeshTasksIndirectEXT-buffer-02709
    buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawMeshTasksIndirectEXT-offset-02710
    offset must be a multiple of 4

  • VUID-vkCmdDrawMeshTasksIndirectEXT-commandBuffer-02711
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawMeshTasksIndirectEXT-drawCount-02718
    If the multiDrawIndirect feature is not enabled, drawCount must be 0 or 1

  • VUID-vkCmdDrawMeshTasksIndirectEXT-drawCount-02719
    drawCount must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawMeshTasksIndirectEXT-drawCount-07088
    If drawCount is greater than 1, stride must be a multiple of 4 and must be greater than or equal to sizeof(VkDrawMeshTasksIndirectCommandEXT)

  • VUID-vkCmdDrawMeshTasksIndirectEXT-drawCount-07089
    If drawCount is equal to 1, (offset + sizeof(VkDrawMeshTasksIndirectCommandEXT)) must be less than or equal to the size of buffer

  • VUID-vkCmdDrawMeshTasksIndirectEXT-drawCount-07090
    If drawCount is greater than 1, (stride × (drawCount - 1) + offset + sizeof(VkDrawMeshTasksIndirectCommandEXT)) must be less than or equal to the size of buffer

  • VUID-vkCmdDrawMeshTasksIndirectEXT-MeshEXT-07091
    The current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS must contain a shader stage using the MeshEXT Execution Model

Valid Usage (Implicit)
  • VUID-vkCmdDrawMeshTasksIndirectEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectEXT-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawMeshTasksIndirectEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawMeshTasksIndirectEXT-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawMeshTasksIndirectEXT-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawMeshTasksIndirectEXT-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawMeshTasksIndirectEXT-commonparent
    Both of buffer, and commandBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawMeshTasksIndirectEXT is affected by conditional rendering

The VkDrawMeshTasksIndirectCommandEXT structure is defined as:

// Provided by VK_EXT_mesh_shader
typedef struct VkDrawMeshTasksIndirectCommandEXT {
    uint32_t    groupCountX;
    uint32_t    groupCountY;
    uint32_t    groupCountZ;
} VkDrawMeshTasksIndirectCommandEXT;
  • groupCountX is the number of local workgroups to dispatch in the X dimension.

  • groupCountY is the number of local workgroups to dispatch in the Y dimension.

  • groupCountZ is the number of local workgroups to dispatch in the Z dimension.

The members of VkDrawMeshTasksIndirectCommandEXT have the same meaning as the similarly named parameters of vkCmdDrawMeshTasksEXT.

Valid Usage
  • VUID-VkDrawMeshTasksIndirectCommandEXT-TaskEXT-07322
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS contains a shader using the TaskEXT Execution Model, groupCountX must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxTaskWorkGroupCount[0]

  • VUID-VkDrawMeshTasksIndirectCommandEXT-TaskEXT-07323
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS contains a shader using the TaskEXT Execution Model, groupCountY must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxTaskWorkGroupCount[1]

  • VUID-VkDrawMeshTasksIndirectCommandEXT-TaskEXT-07324
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS contains a shader using the TaskEXT Execution Model, groupCountZ must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxTaskWorkGroupCount[2]

  • VUID-VkDrawMeshTasksIndirectCommandEXT-TaskEXT-07325
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS contains a shader using the TaskEXT Execution Model, The product of groupCountX, groupCountY and groupCountZ must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxTaskWorkGroupTotalCount

  • VUID-VkDrawMeshTasksIndirectCommandEXT-TaskEXT-07326
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS does not contain a shader using the TaskEXT Execution Model, groupCountX must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshWorkGroupCount[0]

  • VUID-VkDrawMeshTasksIndirectCommandEXT-TaskEXT-07327
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS does not contain a shader using the TaskEXT Execution Model, groupCountY must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshWorkGroupCount[1]

  • VUID-VkDrawMeshTasksIndirectCommandEXT-TaskEXT-07328
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS does not contain a shader using the TaskEXT Execution Model, groupCountZ must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshWorkGroupCount[2]

  • VUID-VkDrawMeshTasksIndirectCommandEXT-TaskEXT-07329
    If the current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS does not contain a shader using the TaskEXT Execution Model, The product of groupCountX, groupCountY and groupCountZ must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshWorkGroupTotalCount

To record an indirect mesh tasks drawing command with the draw count sourced from a buffer, call:

// Provided by VK_EXT_mesh_shader with (VK_VERSION_1_2 or VK_KHR_draw_indirect_count) or VK_AMD_draw_indirect_count
void vkCmdDrawMeshTasksIndirectCountEXT(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset,
    VkBuffer                                    countBuffer,
    VkDeviceSize                                countBufferOffset,
    uint32_t                                    maxDrawCount,
    uint32_t                                    stride);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

  • countBuffer is the buffer containing the draw count.

  • countBufferOffset is the byte offset into countBuffer where the draw count begins.

  • maxDrawCount specifies the maximum number of draws that will be executed. The actual number of executed draw calls is the minimum of the count specified in countBuffer and maxDrawCount.

  • stride is the byte stride between successive sets of draw parameters.

vkCmdDrawMeshTasksIndirectCountEXT behaves similarly to vkCmdDrawMeshTasksIndirectEXT except that the draw count is read by the device from a buffer during execution. The command will read an unsigned 32-bit integer from countBuffer located at countBufferOffset and use this as the draw count.

Valid Usage
  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-buffer-02708
    If buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-buffer-02709
    buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-offset-02710
    offset must be a multiple of 4

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-commandBuffer-02711
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBuffer-02714
    If countBuffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBuffer-02715
    countBuffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBufferOffset-02716
    countBufferOffset must be a multiple of 4

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBuffer-02717
    The count stored in countBuffer must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBufferOffset-04129
    (countBufferOffset + sizeof(uint32_t)) must be less than or equal to the size of countBuffer

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-None-04445
    If the drawIndirectCount feature is not enabled this function must not be used

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-stride-07096
    stride must be a multiple of 4 and must be greater than or equal to sizeof(VkDrawMeshTasksIndirectCommandEXT)

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-maxDrawCount-07097
    If maxDrawCount is greater than or equal to 1, (stride × (maxDrawCount - 1) + offset + sizeof(VkDrawMeshTasksIndirectCommandEXT)) must be less than or equal to the size of buffer

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-MeshEXT-07100
    The current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS must contain a shader stage using the MeshEXT Execution Model

Valid Usage (Implicit)
  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBuffer-parameter
    countBuffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawMeshTasksIndirectCountEXT-commonparent
    Each of buffer, commandBuffer, and countBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawMeshTasksIndirectCountEXT is affected by conditional rendering

24.7. Programmable Cluster Culling Shading

In this drawing approach, cluster are generated by the cluster culling shader stage. It operates similarly to dispatching compute as the shaders make use of workgroups.

To record a cluster culling shader drawing command, call:

// Provided by VK_HUAWEI_cluster_culling_shader
void vkCmdDrawClusterHUAWEI(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    groupCountX,
    uint32_t                                    groupCountY,
    uint32_t                                    groupCountZ);
  • commandBuffer is the command buffer into which the command will be recorded.

  • groupCountX is the number of local workgroups to dispatch in the X dimension.

  • groupCountY is the number of local workgroups to dispatch in the Y dimension.

  • groupCountZ is the number of local workgroups to dispatch in the Z dimension.

When the command is executed,a global workgroup consisting of groupCountX*groupCountY*groupCountZ local workgroup is assembled. Note that the cluster culling shader pipeline only accepts vkCmdDrawClusterHUAWEI and vkCmdDrawClusterIndirectHUAWEI as drawing commands.

Valid Usage
Valid Usage (Implicit)
  • VUID-vkCmdDrawClusterHUAWEI-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawClusterHUAWEI-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawClusterHUAWEI-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawClusterHUAWEI-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawClusterHUAWEI-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawClusterHUAWEI-videocoding
    This command must only be called outside of a video coding scope

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawClusterHUAWEI is affected by conditional rendering

To record an indirect cluster culling drawing command, call:

// Provided by VK_HUAWEI_cluster_culling_shader
void vkCmdDrawClusterIndirectHUAWEI(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    buffer,
    VkDeviceSize                                offset);
  • commandBuffer is the command buffer into which the command is recorded.

  • buffer is the buffer containing draw parameters.

  • offset is the byte offset into buffer where parameters begin.

vkCmdDrawClusterIndirectHUAWEI behaves similarly to vkCmdDrawClusterHUAWEI except that the parameters are read by the device from a buffer during execution. The parameters of the dispatch are encoded in a VkDispatchIndirectCommand structure taken from buffer starting at offset. Note the cluster culling shader pipeline only accepts vkCmdDrawClusterHUAWEI and vkCmdDrawClusterIndirectHUAWEI as drawing commands.

Valid Usage
  • VUID-vkCmdDrawClusterIndirectHUAWEI-drawCount-02718
    If the multiDrawIndirect feature is not enabled, drawCount must be 0 or 1

  • VUID-vkCmdDrawClusterIndirectHUAWEI-drawCount-02719
    drawCount must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

  • VUID-vkCmdDrawClusterIndirectHUAWEI-ClusterCullingHUAWEI-07824
    The current pipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS must contain a shader stage using the ClusterCullingHUAWEI Execution Model

  • VUID-vkCmdDrawClusterIndirectHUAWEI-offset-07918
    offset must be a multiple of VkPhysicalDeviceClusterCullingShaderPropertiesHUAWEI::indirectBufferOffsetAlignment

Valid Usage (Implicit)
  • VUID-vkCmdDrawClusterIndirectHUAWEI-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdDrawClusterIndirectHUAWEI-buffer-parameter
    buffer must be a valid VkBuffer handle

  • VUID-vkCmdDrawClusterIndirectHUAWEI-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdDrawClusterIndirectHUAWEI-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_GRAPHICS_BIT operations

  • VUID-vkCmdDrawClusterIndirectHUAWEI-renderpass
    This command must only be called inside of a render pass instance

  • VUID-vkCmdDrawClusterIndirectHUAWEI-suspended
    This command must not be called between suspended render pass instances

  • VUID-vkCmdDrawClusterIndirectHUAWEI-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdDrawClusterIndirectHUAWEI-commonparent
    Both of buffer, and commandBuffer must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Inside

Outside

VK_QUEUE_GRAPHICS_BIT

Action

Conditional Rendering

vkCmdDrawClusterIndirectHUAWEI is affected by conditional rendering