VKCMDDRAWINDIRECT(3)

NAME
vkCmdDrawIndirect - Issue an indirect draw into a command buffer.

C SPECIFICATION

    void vkCmdDrawIndirect(
        VkCommandBuffer                             commandBuffer,
        VkBuffer                                    buffer,
        VkDeviceSize                                offset,
        uint32_t                                    drawCount,
        uint32_t                                    stride);

PARAMETERS

commandBuffer
    Specifies the command buffer into which to insert the draw command.

buffer
    Specifies a handle of a buffer object containing parameters forming individual draw commands.

offset
    Specifies offset, in bytes, within the buffer object represented by buffer at which the drawing command parameters begin.

drawCount
    Specifies the number of indirect draws to consume from the specified memory object.

stride
    Specifies the distance, in bytes, between the start of each indirect draw in the memory object. This parameter may be zero to indicate that the array of indirect draw commands is tightly packed.

DESCRIPTION

vkCmdDrawIndirect issues an indirect draw into a command bufer. Each indirect command consumes drawCount structures, stored at offset bytes into the buffer object whose handle is specified in buffer. The beginning of each structure is stride bytes from the previous. The data structures have the a layout in memory which may be represented by the VkDrawIndirectCommand structure, the definition of which is:

    typedef struct VkDrawIndirectCommand {
        uint32_t    vertexCount;
        uint32_t    instanceCount;
        uint32_t    firstVertex;
        uint32_t    firstInstance;
    } VkDrawIndirectCommand;

If stride is zero, the array of VkDrawIndirectCommand structures is assumed to be tightly packed.

VALID USAGE

    • commandBuffer must be a valid VkCommandBuffer handle

    • buffer must be a valid VkBuffer handle

    • commandBuffer must be in the recording state

    • The VkCommandPool that commandBuffer was allocated from must support graphics operations

    • This command must only be called inside of a render pass instance

    • Each of commandBuffer and buffer must have been created, allocated or retrieved from the same VkDevice

    • offset must be a multiple of 4

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

    • If the multi-draw indirect feature is not enabled, drawCount must be 0 or 1

    • If the drawIndirectFirstInstance feature is not enabled, all the firstInstance members of the VkDrawIndirectCommand structures accessed by this command must be 0

    • For each set n that is statically used by the VkPipeline currently bound to VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must have been bound to n at VK_PIPELINE_BIND_POINT_GRAPHICS, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in ???

    • For each push constant that is statically used by the VkPipeline currently bound to VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value must have been set for VK_PIPELINE_BIND_POINT_GRAPHICS, with a VkPipelineLayout that is compatible for push constants, with the VkPipelineLayout used to create the current VkPipeline, as described in ???

    • Descriptors in each bound descriptor set, specified via vkCmdBindDescriptorSets, must be valid if they are statically used by the currently bound VkPipeline object, specified via vkCmdBindPipeline

    • All vertex input bindings accessed via vertex input variables declared in the vertex shader entry point’s interface must have valid buffers bound

    • A valid graphics pipeline must be bound to the current command buffer with VK_PIPELINE_BIND_POINT_GRAPHICS

    • If the VkPipeline object currently bound to VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that state must have been set on the current command buffer

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

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

    • drawCount must be less than or equal to VkPhysicalDeviceLimits::maxDrawIndirectCount

    • Every input attachment used by the current subpass must be bound to the pipeline via a descriptor set

    • If any VkSampler object that is accessed from a shader by the VkPipeline currently bound to VK_PIPELINE_BIND_POINT_GRAPHICS uses unnormalized coordinates, it must not be used to sample from any VkImage with a VkImageView of the type VK_IMAGE_VIEW_TYPE_3D, VK_IMAGE_VIEW_TYPE_CUBE, VK_IMAGE_VIEW_TYPE_1D_ARRAY, VK_IMAGE_VIEW_TYPE_2D_ARRAY or VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage

    • If any VkSampler object that is accessed from a shader by the VkPipeline currently bound to VK_PIPELINE_BIND_POINT_GRAPHICS uses unnormalized coordinates, it must not be used with any of the SPIR-V OpImageSample* or OpImageSparseSample* instructions with ImplicitLod, Dref or Proj in their name, in any shader stage

    • If any VkSampler object that is accessed from a shader by the VkPipeline currently bound to VK_PIPELINE_BIND_POINT_GRAPHICS uses unnormalized coordinates, it must not be used with any of the SPIR-V OpImageSample* or OpImageSparseSample* instructions that includes a lod bias or any offset values, in any shader stage

    • If the robust buffer access feature is not enabled, and any shader stage in the VkPipeline object currently bound to VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform buffer, it must not access values outside of the range of that buffer specified in the currently bound descriptor set

    • If the robust buffer access feature is not enabled, and any shader stage in the VkPipeline object currently bound to VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage buffer, it must not access values outside of the range of that buffer specified in the currently bound descriptor set

    • Any VkImageView being sampled with VK_FILTER_LINEAR as a result of this command must be of a format which supports linear filtering, as specified by the VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT flag in VkFormatProperties::linearTilingFeatures (for a linear image) or VkFormatProperties::optimalTilingFeatures(for an optimally tiled image) returned by vkGetPhysicalDeviceFormatProperties

HOST SYNCHRONIZATION

    • Host access to commandBuffer must be externally synchronized

COMMAND PROPERTIES
Command Buffer Levels | Render Pass Scope | Supported Queue Types
Primary Secondary | Inside | GRAPHICS

NOTES

Although vkCmdDrawIndirect does not generate errors or return a value, enabled validation layers may detect possible error conditions or potentially undefined behavior and report this via some other means.

SEE ALSO

vkCmdDraw, vkCmdDrawIndexed, vkCmdDrawIndexedIndirect

COPYRIGHT

Copyright © 2014-2016 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.

AUTHOR

Khronos Group
    Author.