C Specification

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

// Provided by VK_KHR_device_address_commands with VK_EXT_transform_feedback
void vkCmdDrawIndirectByteCount2EXT(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    instanceCount,
    uint32_t                                    firstInstance,
    const VkBindTransformFeedbackBuffer2InfoEXT* pCounterInfo,
    uint32_t                                    counterOffset,
    uint32_t                                    vertexStride);

Parameters

  • 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.

  • pCounterInfo is a pointer to a VkBindTransformFeedbackBuffer2InfoEXT defining the range of memory that the byte count is read from.

  • counterOffset is subtracted from the byte count.

  • 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.

Description

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 *)counterRange.address;
vertexCount = floor(max(0, (*counterBufferPtr - counterOffset)) / vertexStride);

The effective firstVertex is zero.

Valid Usage
  • VUID-vkCmdDrawIndirectByteCount2EXT-counterOffset-09474
    counterOffset must be a multiple of 4

  • VUID-vkCmdDrawIndirectByteCount2EXT-transformFeedback-02287
    VkPhysicalDeviceTransformFeedbackFeaturesEXT::transformFeedback must be enabled

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

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

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

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

  • VUID-vkCmdDrawIndirectByteCount2EXT-pInfo-13061
    The VkBuffer that pInfo->counterRange was queried from must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set

  • VUID-vkCmdDrawIndirectByteCount2EXT-pInfo-13062
    pInfo->counterRange.address must be a multiple of 4

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

  • VUID-vkCmdDrawIndirectByteCount2EXT-pCounterInfo-parameter
    pCounterInfo must be a valid pointer to a valid VkBindTransformFeedbackBuffer2InfoEXT structure

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

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

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

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

  • VUID-vkCmdDrawIndirectByteCount2EXT-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

vkCmdDrawIndirectByteCount2EXT is affected by conditional rendering

See Also

Document Notes

For more information, see the Vulkan Specification.

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2026 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0