When rendering a large number of objects, the device can be leveraged to implement a number of critical functions, like updating matrices, or implementing occlusion culling, frustum culling, front to back sorting, etc. Implementing those on the device does not require any special extension, since an application is free to define its own data structures, and just process them using shaders.
However, if the application desires to quickly kick off the rendering of the final stream of objects, then unextended Vulkan forces the application to read back the processed stream and issue graphics command from the host. For very large scenes, the synchronization overhead and cost to generate the command buffer can become the bottleneck. This extension allows an application to generate a device side stream of state changes and commands, and convert it efficiently into a command buffer without having to read it back to the host.
Furthermore, it allows incremental changes to such command buffers by manipulating only partial sections of a command stream — for example pipeline bindings. Unextended Vulkan requires re-creation of entire command buffers in such a scenario, or updates synchronized on the host.
The intended usage for this extension is for the application to:
VkBuffer objects and retrieve physical addresses from them via GetBufferDeviceAddressEXTVkGraphicsPipelineShaderGroupsCreateInfoNV for the ability to change shaders on the device.VkIndirectCommandsLayoutNV, which lists the VkIndirectCommandsTokenTypeNV it wants to dynamically execute as an atomic command sequence. This step likely involves some internal device code compilation, since the intent is for the GPU to generate the command buffer in the pipeline.VkBuffer that uses memory according to the information retrieved via GetGeneratedCommandsMemoryRequirementsNV.CmdPreprocessGeneratedCommandsNV, for example on an asynchronous compute queue, or for the purpose of re-using the data in multiple executions.CmdExecuteGeneratedCommandsNV to create and execute the actual device commands for all sequences based on the inputs provided.For each draw in a sequence, the following can be specified:
While the GPU can be faster than a CPU to generate the commands, it will not happen asynchronously to the device, therefore the primary use case is generating “less” total work (occlusion culling, classification to use specialized shaders, etc.).
Open-Source samples illustrating the usage of the extension can be found at the following location (may not yet exist at time of writing):
https://github.com/nvpro-samples/vk_device_generated_cmds
VK_NV_device_generated_commandsVK_KHR_buffer_device_addressVK_EXT_buffer_device_address or VK_KHR_buffer_device_address or Vulkan 1.2 for the ability to bind vertex and index buffers on the device.VK_NV_mesh_shader. If the latter extension is not supported, remove the command token to initiate mesh tasks drawing in this extension.| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static void | nvkCmdExecuteGeneratedCommandsNV(VkCommandBuffer commandBuffer, int isPreprocessed, long pGeneratedCommandsInfo)
Unsafe version of: |
| public static void | nvkCmdPreprocessGeneratedCommandsNV(VkCommandBuffer commandBuffer, long pGeneratedCommandsInfo)
Unsafe version of: |
| public static int | nvkCreateIndirectCommandsLayoutNV(VkDevice device, long pCreateInfo, long pAllocator, long pIndirectCommandsLayout)
Unsafe version of: |
| public static void | nvkDestroyIndirectCommandsLayoutNV(VkDevice device, long indirectCommandsLayout, long pAllocator)
Unsafe version of: |
| public static void | nvkGetGeneratedCommandsMemoryRequirementsNV(VkDevice device, long pInfo, long pMemoryRequirements)
Unsafe version of: |
| public static void | vkCmdBindPipelineShaderGroupNV(VkCommandBuffer
the command buffer that the pipeline will be bound to. commandBuffer, int a pipelineBindPoint, long VkPipelineBindPoint value specifying the bind point to which the pipeline will be bound.the pipeline to be bound. pipeline, int the shader group to be bound. groupIndex)Bind a pipeline object. |
| public static void | vkCmdExecuteGeneratedCommandsNV(VkCommandBuffer
the command buffer into which the command is recorded. commandBuffer, boolean represents whether the input data has already been preprocessed on the device. If it is isPreprocessed, VkGeneratedCommandsInfoNV FALSE this command will implicitly trigger the preprocessing step, otherwise not.a pointer to a pGeneratedCommandsInfo)VkGeneratedCommandsInfoNV structure containing parameters affecting the generation of commands.Generate and execute commands on the device. |
| public static void | vkCmdPreprocessGeneratedCommandsNV(VkCommandBuffer
the command buffer which does the preprocessing. commandBuffer, VkGeneratedCommandsInfoNV a pointer to a pGeneratedCommandsInfo)VkGeneratedCommandsInfoNV structure containing parameters affecting the preprocessing step.Performs preprocessing for generated commands. |
| public static int | vkCreateIndirectCommandsLayoutNV(VkDevice
the logical device that creates the indirect command layout. device, VkIndirectCommandsLayoutCreateInfoNV a pointer to a pCreateInfo, VkAllocationCallbacks VkIndirectCommandsLayoutCreateInfoNV structure containing parameters affecting creation of the indirect command layout.controls host memory allocation as described in the Memory Allocation chapter. pAllocator, LongBuffer a pointer to a pIndirectCommandsLayout)VkIndirectCommandsLayoutNV handle in which the resulting indirect command layout is returned.Create an indirect command layout object. |
| public static int | vkCreateIndirectCommandsLayoutNV(VkDevice device, VkIndirectCommandsLayoutCreateInfoNV pCreateInfo, VkAllocationCallbacks pAllocator, long[] pIndirectCommandsLayout)
Array version of: |
| public static void | vkDestroyIndirectCommandsLayoutNV(VkDevice
the logical device that destroys the layout. device, long the layout to destroy. indirectCommandsLayout, VkAllocationCallbacks controls host memory allocation as described in the Memory Allocation chapter. pAllocator)Destroy an indirect commands layout. |
| public static void | vkGetGeneratedCommandsMemoryRequirementsNV(VkDevice
the logical device that owns the buffer. device, VkGeneratedCommandsMemoryRequirementsInfoNV a pointer to a pInfo, VkMemoryRequirements2 VkGeneratedCommandsMemoryRequirementsInfoNV structure containing parameters required for the memory requirements query.a pointer to a pMemoryRequirements)VkMemoryRequirements2 structure in which the memory requirements of the buffer object are returned.Retrieve the buffer allocation requirements for generated commands. |