C Specification

To dispatch ray tracing, with some parameters sourced on the device, use:

// Provided by VK_KHR_ray_tracing_maintenance1 with VK_KHR_ray_tracing_pipeline
void vkCmdTraceRaysIndirect2KHR(
    VkCommandBuffer                             commandBuffer,
    VkDeviceAddress                             indirectDeviceAddress);

Parameters

  • commandBuffer is the command buffer into which the command will be recorded.

  • indirectDeviceAddress is a buffer device address which is a pointer to a VkTraceRaysIndirectCommand2KHR structure containing the trace ray parameters.

Description

vkCmdTraceRaysIndirect2KHR behaves similarly to vkCmdTraceRaysIndirectKHR except that shader binding table parameters as well as dispatch dimensions are read by the device from indirectDeviceAddress during execution.

Valid Usage
  • VUID-vkCmdTraceRaysIndirect2KHR-maxPipelineRayRecursionDepth-03679
    This command must not cause a shader call instruction to be executed from a shader invocation with a recursion depth greater than the value of maxPipelineRayRecursionDepth used to create the bound ray tracing pipeline

  • VUID-vkCmdTraceRaysIndirect2KHR-commandBuffer-03635
    commandBuffer must not be a protected command buffer

  • VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03633
    indirectDeviceAddress must be a device address allocated to the application from a buffer created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT usage flag set

  • VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634
    indirectDeviceAddress must be a multiple of 4

  • VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03636
    All device addresses between indirectDeviceAddress and indirectDeviceAddress + sizeof(VkTraceRaysIndirectCommand2KHR) - 1 must be in the buffer device address range of the same buffer

  • VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637
    The rayTracingPipelineTraceRaysIndirect2 feature must be enabled

  • VUID-vkCmdTraceRaysIndirect2KHR-rayTracingMotionBlurPipelineTraceRaysIndirect-04951
    If the bound ray tracing pipeline was created with VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV VkPhysicalDeviceRayTracingMotionBlurFeaturesNV::rayTracingMotionBlurPipelineTraceRaysIndirect feature must be enabled

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

  • VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-parameter
    indirectDeviceAddress must be a valid VkDeviceAddress value

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

  • VUID-vkCmdTraceRaysIndirect2KHR-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support VK_QUEUE_COMPUTE_BIT operations

  • VUID-vkCmdTraceRaysIndirect2KHR-renderpass
    This command must only be called outside of a render pass instance

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

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

Outside

Outside

VK_QUEUE_COMPUTE_BIT

Action

Conditional Rendering

vkCmdTraceRaysIndirect2KHR is not 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