# vkBuildAccelerationStructureKHR(3) Manual Page

## Name

vkBuildAccelerationStructureKHR - Build an acceleration structure on the host

## C Specification

To build acceleration structures on the host, call:

    VkResult vkBuildAccelerationStructureKHR(
        VkDevice                                    device,
        uint32_t                                    infoCount,
        const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
        const VkAccelerationStructureBuildOffsetInfoKHR* const* ppOffsetInfos);

## Parameters

This command fulfills the same task as vkCmdBuildAccelerationStructureKHR but executed by the host.

## Description

- `device` is the `VkDevice` for which the acceleration structures are being built.

- `infoCount` is the number of acceleration structures to build. It specifies the number of the `pInfos` structures and `ppOffsetInfos` pointers that must be provided.

- `pInfos` is a pointer to an array of `infoCount` VkAccelerationStructureBuildGeometryInfoKHR structures defining the geometry used to build each acceleration structure.

- `ppOffsetInfos` is an array of `infoCount` pointers to arrays of VkAccelerationStructureBuildOffsetInfoKHR structures. Each `ppOffsetInfos`[i] is an array of `pInfos`[i]→`geometryCount` VkAccelerationStructureBuildOffsetInfoKHR structures defining dynamic offsets to the addresses where geometry data is stored, as defined by `pInfos`[i].

The `vkBuildAccelerationStructureKHR` command provides the ability to initiate multiple acceleration structures builds, however there is no ordering or synchronization implied between any of the individual acceleration structure builds.

| Note This means that an application cannot build a top-level acceleration structure in the same vkBuildAccelerationStructureKHR call as the associated bottom-level or instance acceleration structures are being built. There also cannot be any memory aliasing between any acceleration structure memories or scratch memories being used by any of the builds.

If the VkDeferredOperationInfoKHR structure is included in the `pNext` chain of any VkAccelerationStructureBuildGeometryInfoKHR structure, the operation of this command is deferred, as defined in the Deferred Host Operations chapter.

Valid Usage

- [[VUID-{refpage}-pOffsetInfos-03402]] `pOffsetInfos`[i] must be a valid pointer to an array of `pInfos`[i]→`geometryCount` `VkAccelerationStructureBuildOffsetInfoKHR` structures

- [[VUID-{refpage}-pInfos-03403]] Each `pInfos`[i].`srcAccelerationStructure` must not refer to the same acceleration structure as any `pInfos`[i].`dstAccelerationStructure` that is provided to the same build command unless it is identical for an update

- [[VUID-{refpage}-pInfos-03404]] For each `pInfos`[i], `dstAccelerationStructure` must have been created with compatible VkAccelerationStructureCreateInfoKHR where VkAccelerationStructureCreateInfoKHR::`type` and VkAccelerationStructureCreateInfoKHR::`flags` are identical to VkAccelerationStructureBuildGeometryInfoKHR::`type` and VkAccelerationStructureBuildGeometryInfoKHR::`flags` respectively, VkAccelerationStructureBuildGeometryInfoKHR::`geometryCount` for `dstAccelerationStructure` are greater than or equal to the build size, and each geometry in VkAccelerationStructureBuildGeometryInfoKHR::`ppGeometries` for `dstAccelerationStructure` has greater than or equal to the number of vertices, indices, and AABBs, VkAccelerationStructureGeometryTrianglesDataKHR::`transformData` is both 0 or both non-zero, and all other parameters are the same.

- [[VUID-{refpage}-pInfos-03405]] For each `pInfos`[i], if `update` is `VK_TRUE`, then objects that were previously active for that acceleration structure must not be made inactive as per [acceleration-structure-inactive-prims]

- [[VUID-{refpage}-pInfos-03406]] For each `pInfos`[i], if `update` is `VK_TRUE`, then objects that were previously inactive for that acceleration structure must not be made active as per [acceleration-structure-inactive-prims]

- [[VUID-{refpage}-None-03407]] Any acceleration structure instance in any top level build in this command must not reference any bottom level acceleration structure built by this command

- [[VUID-{refpage}-pInfos-03408]] There must not be any memory aliasing between the scratch memories that are provided in all the `pInfos`[i].`scratchData` memories for the acceleration structure builds

- [[VUID-{refpage}-None-03409]] There must not be any memory aliasing between memory bound to any top level, bottom level, or instance acceleration structure accessed by this command

- All VkDeviceOrHostAddressKHR or VkDeviceOrHostAddressConstKHR referenced by this command must contain valid host addresses

- All `VkAccelerationStructureKHR` objects referenced by this command must be bound to host-visible memory

- The `VkPhysicalDeviceRayTracingFeaturesKHR`→`rayTracingHostAccelerationStructureCommands` feature must be enabled

Valid Usage (Implicit)

- `device` must be a valid VkDevice handle

- `pInfos` must be a valid pointer to an array of `infoCount` valid VkAccelerationStructureBuildGeometryInfoKHR structures

- `ppOffsetInfos` must be a valid pointer to an array of `infoCount` VkAccelerationStructureBuildOffsetInfoKHR structures

- `infoCount` must be greater than `0`

Return Codes

On success, this command returns

  - `VK_SUCCESS`

  - `VK_OPERATION_DEFERRED_KHR`

  - `VK_OPERATION_NOT_DEFERRED_KHR`

On failure, this command returns

  - `VK_ERROR_OUT_OF_HOST_MEMORY`

  - `VK_ERROR_OUT_OF_DEVICE_MEMORY`

## See Also

VkAccelerationStructureBuildGeometryInfoKHR, VkAccelerationStructureBuildOffsetInfoKHR, VkDevice

## 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

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.