[[device-generated-commands]]
= Device-Generated Commands

This chapter discusses the generation of command buffer content on the
device.
These principle steps are to be taken to generate commands on the device:

  * Make resource bindings accessible for the device via registering in an
    sname:VkObjectTableNVX.
  * Define via sname:VkIndirectCommandsLayoutNVX the sequence of commands
    which should be generated.
  * Fill one or more sname:VkBuffer with the appropriate content that gets
    interpreted by sname:VkIndirectCommandsLayoutNVX.
  * Reserve command space via flink:vkCmdReserveSpaceForCommandsNVX in a
    secondary sname:VkCommandBuffer where the generated commands should be
    recorded.
  * Generate the actual commands via flink:vkCmdProcessCommandsNVX passing
    all required data.

Execution of such generated commands can either be triggered directly with
the generation process, or by executing the secondary sname:VkCommandBuffer
that was chosen as optional target.
The latter allows re-using generated commands as well.
Similar to sname:VkDescriptorSet, special care should: be taken for the
lifetime of resources referenced in sname:VkObjectTableNVX, which may be
accessed at either generation or execution time.

flink:vkCmdProcessCommandsNVX executes in a separate logical pipeline from
either graphics or compute.
When generating commands into a secondary command buffer, the command
generation must: be explicitly synchronized against the secondary command
buffer's execution.
When not using a secondary command buffer, the command generation is
automatically synchronized against the command execution.

== Features and Limitations

// refBegin vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX Returns device-generated commands related properties of a physical device

To query the support of related features and limitations, call:

include::../../api/protos/vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX.txt[]

  * pname:physicalDevice is the handle to the physical device whose
    properties will be queried.
  * pname:pFeatures points to an instance of the
    slink:VkDeviceGeneratedCommandsFeaturesNVX structure, that will be
    filled with returned information.
  * pname:pLimits points to an instance of the
    slink:VkDeviceGeneratedCommandsLimitsNVX structure, that will be filled
    with returned information.

include::../../validity/protos/vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX.txt[]

// refBegin VkDeviceGeneratedCommandsFeaturesNVX Structure specifying physical device support

The sname:VkDeviceGeneratedCommandsFeaturesNVX structure is defined as:

include::../../api/structs/VkDeviceGeneratedCommandsFeaturesNVX.txt[]

  * pname:sType is the type of this structure.
  * pname:pNext is `NULL` or a pointer to an extension-specific structure.
  * pname:computeBindingPointSupport indicates whether the
    sname:VkObjectTableNVX supports entries with
    ename:VK_OBJECT_ENTRY_USAGE_GRAPHICS_BIT_NVX bit set and
    sname:VkIndirectCommandsLayoutNVX supports
    ename:VK_PIPELINE_BIND_POINT_COMPUTE.

include::../../validity/structs/VkDeviceGeneratedCommandsFeaturesNVX.txt[]

// refBegin VkDeviceGeneratedCommandsLimitsNVX Structure specifying physical device limits

The sname:VkDeviceGeneratedCommandsLimitsNVX structure is defined as:

include::../../api/structs/VkDeviceGeneratedCommandsLimitsNVX.txt[]

  * pname:sType is the type of this structure.
  * pname:pNext is `NULL` or a pointer to an extension-specific structure.
  * pname:maxIndirectCommandsLayoutTokenCount the maximum number of tokens
    in sname:VkIndirectCommandsLayoutNVX.
  * pname:maxObjectEntryCounts the maximum number of entries per resource
    type in sname:VkObjectTableNVX.
  * pname:minSequenceCountBufferOffsetAlignment the minimum alignment for
    memory addresses optionally used in fname:vkCmdProcessCommandsNVX.
  * pname:minSequenceIndexBufferOffsetAlignment the minimum alignment for
    memory addresses optionally used in fname:vkCmdProcessCommandsNVX.
  * pname:minCommandsTokenBufferOffsetAlignment the minimum alignment for
    memory addresses optionally used in fname:vkCmdProcessCommandsNVX.

include::../../validity/structs/VkDeviceGeneratedCommandsLimitsNVX.txt[]

include::objecttable.txt[]

include::indirectcommands.txt[]

include::generation.txt[]
