C Specification

To copy an acceleration structure to device memory call:

// Provided by VK_KHR_ray_tracing
void vkCmdCopyAccelerationStructureToMemoryKHR(
    VkCommandBuffer                             commandBuffer,
    const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo);

Parameters

This command produces the same results as vkCopyAccelerationStructureToMemoryKHR, but writes its result to a device address, and is executed on the device rather than the host. The output may not necessarily be bit-for-bit identical, but it can be equally used by either vkCmdCopyMemoryToAccelerationStructureKHR or vkCopyMemoryToAccelerationStructureKHR.

Description

The defined header structure for the serialized data consists of:

  • VK_UUID_SIZE bytes of data matching VkPhysicalDeviceIDProperties::driverUUID

  • VK_UUID_SIZE bytes of data identifying the compatibility for comparison using vkGetDeviceAccelerationStructureCompatibilityKHR

  • A 64-bit integer of the total size matching the value queried using VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR

  • A 64-bit integer of the deserialized size to be passed in to VkAccelerationStructureCreateInfoKHR::compactedSize

  • A 64-bit integer of the count of the number of acceleration structure handles following. This will be zero for a bottom-level acceleration structure.

The corresponding handles matching the values returned by vkGetAccelerationStructureDeviceAddressKHR or vkGetAccelerationStructureHandleNV are tightly packed in the buffer following the count. The application is expected to store a mapping between those handles and the original application-generated bottom-level acceleration structures to provide when deserializing.

Valid Usage
  • VUID-vkCmdCopyAccelerationStructureToMemoryKHR-None-04048
    All VkDeviceOrHostAddressConstKHR referenced by this command must contain valid device addresses for a buffer bound to device memory. If the buffer is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object

  • VUID-vkCmdCopyAccelerationStructureToMemoryKHR-None-03559
    All VkAccelerationStructureKHR objects referenced by this command must be bound to device memory

  • VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560
    The VkDeferredOperationInfoKHR structure must not be included in the pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure

  • VUID-vkCmdCopyAccelerationStructureToMemoryKHR-mode-03412
    mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR

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

  • VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-parameter
    pInfo must be a valid pointer to a valid VkCopyAccelerationStructureToMemoryInfoKHR structure

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

  • VUID-vkCmdCopyAccelerationStructureToMemoryKHR-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support compute operations

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

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 Supported Queue Types Pipeline Type

Primary
Secondary

Outside

Compute

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 (c) 2014-2020 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0