C Specification
To build acceleration structures on the host, call:
// Provided by VK_KHR_acceleration_structure
VkResult vkBuildAccelerationStructuresKHR(
VkDevice device,
VkDeferredOperationKHR deferredOperation,
uint32_t infoCount,
const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos);
Parameters
-
device
is theVkDevice
for which the acceleration structures are being built. -
deferredOperation
is an optional VkDeferredOperationKHR to request deferral for this command. -
infoCount
is the number of acceleration structures to build. It specifies the number of thepInfos
structures andppBuildRangeInfos
pointers that must be provided. -
pInfos
is a pointer to an array ofinfoCount
VkAccelerationStructureBuildGeometryInfoKHR structures defining the geometry used to build each acceleration structure. -
ppBuildRangeInfos
is a pointer to an array ofinfoCount
pointers to arrays of VkAccelerationStructureBuildRangeInfoKHR structures. EachppBuildRangeInfos
[i] is a pointer to an array ofpInfos
[i].geometryCount
VkAccelerationStructureBuildRangeInfoKHR structures defining dynamic offsets to the addresses where geometry data is stored, as defined bypInfos
[i].
Description
This command fulfills the same task as vkCmdBuildAccelerationStructuresKHR but is executed by the host.
The vkBuildAccelerationStructuresKHR
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 vkBuildAccelerationStructuresKHR 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. |
-
VUID-vkBuildAccelerationStructuresKHR-mode-04628
Themode
member of each element ofpInfos
must be a valid VkBuildAccelerationStructureModeKHR value -
VUID-vkBuildAccelerationStructuresKHR-srcAccelerationStructure-04629
If thesrcAccelerationStructure
member of any element ofpInfos
is not VK_NULL_HANDLE, thesrcAccelerationStructure
member must be a valid VkAccelerationStructureKHR handle -
VUID-vkBuildAccelerationStructuresKHR-pInfos-04630
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, itssrcAccelerationStructure
member must not be VK_NULL_HANDLE -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03403
ThesrcAccelerationStructure
member of any element ofpInfos
must not be the same acceleration structure as thedstAccelerationStructure
member of any other element ofpInfos
-
VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698
ThedstAccelerationStructure
member of any element ofpInfos
must not be the same acceleration structure as thedstAccelerationStructure
member of any other element ofpInfos
-
VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03800
ThedstAccelerationStructure
member of any element ofpInfos
must be a valid VkAccelerationStructureKHR handle -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03699
For each element ofpInfos
, if itstype
member isVK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR
, itsdstAccelerationStructure
member must have been created with a value of VkAccelerationStructureCreateInfoKHR::type
equal to eitherVK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR
orVK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR
-
VUID-vkBuildAccelerationStructuresKHR-pInfos-03700
For each element ofpInfos
, if itstype
member isVK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR
, itsdstAccelerationStructure
member must have been created with a value of VkAccelerationStructureCreateInfoKHR::type
equal to eitherVK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR
orVK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR
-
VUID-vkBuildAccelerationStructuresKHR-pInfos-03663
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, inactive primitives in itssrcAccelerationStructure
member must not be made active -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03664
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, active primitives in itssrcAccelerationStructure
member must not be made inactive -
VUID-vkBuildAccelerationStructuresKHR-None-03407
ThedstAccelerationStructure
member of any element ofpInfos
must not be referenced by thegeometry.instances.data
member of any element ofpGeometries
orppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_INSTANCES_KHR
in any other element ofpInfos
-
VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03701
The range of memory backing thedstAccelerationStructure
member of any element ofpInfos
that is accessed by this command must not overlap the memory backing thesrcAccelerationStructure
member of any other element ofpInfos
with amode
equal toVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, which is accessed by this command -
VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03702
The range of memory backing thedstAccelerationStructure
member of any element ofpInfos
that is accessed by this command must not overlap the memory backing thedstAccelerationStructure
member of any other element ofpInfos
, which is accessed by this command -
VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03703
The range of memory backing thedstAccelerationStructure
member of any element ofpInfos
that is accessed by this command must not overlap the memory backing thescratchData
member of any element ofpInfos
(including the same element), which is accessed by this command -
VUID-vkBuildAccelerationStructuresKHR-scratchData-03704
The range of memory backing thescratchData
member of any element ofpInfos
that is accessed by this command must not overlap the memory backing thescratchData
member of any other element ofpInfos
, which is accessed by this command -
VUID-vkBuildAccelerationStructuresKHR-scratchData-03705
The range of memory backing thescratchData
member of any element ofpInfos
that is accessed by this command must not overlap the memory backing thesrcAccelerationStructure
member of any element ofpInfos
with amode
equal toVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
(including the same element), which is accessed by this command -
VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03706
The range of memory backing thedstAccelerationStructure
member of any element ofpInfos
that is accessed by this command must not overlap the memory backing any acceleration structure referenced by thegeometry.instances.data
member of any element ofpGeometries
orppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_INSTANCES_KHR
in any other element ofpInfos
, which is accessed by this command -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03667
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, itssrcAccelerationStructure
member must have previously been constructed withVK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR
set in VkAccelerationStructureBuildGeometryInfoKHR::flags
in the build -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03668
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, itssrcAccelerationStructure
anddstAccelerationStructure
members must either be the same VkAccelerationStructureKHR, or not have any memory aliasing -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03758
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, itsgeometryCount
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03759
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, itsflags
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03760
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, itstype
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03761
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, then for eachVkAccelerationStructureGeometryKHR
structure referred to by itspGeometries
orppGeometries
members, itsgeometryType
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03762
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, then for eachVkAccelerationStructureGeometryKHR
structure referred to by itspGeometries
orppGeometries
members, itsflags
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03763
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, then for eachVkAccelerationStructureGeometryKHR
structure referred to by itspGeometries
orppGeometries
members, ifgeometryType
isVK_GEOMETRY_TYPE_TRIANGLES_KHR
, itsgeometry.triangles.vertexFormat
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03764
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, then for eachVkAccelerationStructureGeometryKHR
structure referred to by itspGeometries
orppGeometries
members, ifgeometryType
isVK_GEOMETRY_TYPE_TRIANGLES_KHR
, itsgeometry.triangles.maxVertex
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03765
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, then for eachVkAccelerationStructureGeometryKHR
structure referred to by itspGeometries
orppGeometries
members, ifgeometryType
isVK_GEOMETRY_TYPE_TRIANGLES_KHR
, itsgeometry.triangles.indexType
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03766
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, then for eachVkAccelerationStructureGeometryKHR
structure referred to by itspGeometries
orppGeometries
members, ifgeometryType
isVK_GEOMETRY_TYPE_TRIANGLES_KHR
, if itsgeometry.triangles.transformData
address wasNULL
whensrcAccelerationStructure
was last built, then it must beNULL
-
VUID-vkBuildAccelerationStructuresKHR-pInfos-03767
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, then for eachVkAccelerationStructureGeometryKHR
structure referred to by itspGeometries
orppGeometries
members, ifgeometryType
isVK_GEOMETRY_TYPE_TRIANGLES_KHR
, if itsgeometry.triangles.transformData
address was notNULL
whensrcAccelerationStructure
was last built, then it must not beNULL
-
VUID-vkBuildAccelerationStructuresKHR-pInfos-03768
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, then for eachVkAccelerationStructureGeometryKHR
structure referred to by itspGeometries
orppGeometries
members, ifgeometryType
isVK_GEOMETRY_TYPE_TRIANGLES_KHR
, andgeometry.triangles.indexType
is notVK_INDEX_TYPE_NONE_KHR
, then the value of each index referenced must be the same as the corresponding index value whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-primitiveCount-03769
For eachVkAccelerationStructureBuildRangeInfoKHR
referenced by this command, itsprimitiveCount
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-firstVertex-03770
For eachVkAccelerationStructureBuildRangeInfoKHR
referenced by this command, if the corresponding geometry uses indices, itsfirstVertex
member must have the same value which was specified whensrcAccelerationStructure
was last built -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03801
For each element ofpInfos
[i].pGeometries
orpInfos
[i].ppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_INSTANCES_KHR
, the correspondingppBuildRangeInfos
[i][j].primitiveCount
must be less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxInstanceCount
-
VUID-vkBuildAccelerationStructuresKHR-pInfos-03675
For eachpInfos
[i],dstAccelerationStructure
must have been created with a value of VkAccelerationStructureCreateInfoKHR::size
greater than or equal to the memory size required by the build operation, as returned by vkGetAccelerationStructureBuildSizesKHR withpBuildInfo
=pInfos
[i] and with each element of thepMaxPrimitiveCounts
array greater than or equal to the equivalentppBuildRangeInfos
[i][j].primitiveCount
values forj
in [0,pInfos
[i].geometryCount
) -
VUID-vkBuildAccelerationStructuresKHR-ppBuildRangeInfos-03676
Each element ofppBuildRangeInfos
[i] must be a valid pointer to an array ofpInfos
[i].geometryCount
VkAccelerationStructureBuildRangeInfoKHR
structures
-
VUID-vkBuildAccelerationStructuresKHR-deferredOperation-03677
IfdeferredOperation
is not VK_NULL_HANDLE, it must be a valid VkDeferredOperationKHR object -
VUID-vkBuildAccelerationStructuresKHR-deferredOperation-03678
Any previous deferred operation that was associated withdeferredOperation
must be complete -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03722
For each element ofpInfos
, thebuffer
used to create itsdstAccelerationStructure
member must be bound to host-visible device memory -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03723
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
thebuffer
used to create itssrcAccelerationStructure
member must be bound to host-visible device memory -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03724
For each element ofpInfos
, thebuffer
used to create each acceleration structure referenced by thegeometry.instances.data
member of any element ofpGeometries
orppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_INSTANCES_KHR
must be bound to host-visible device memory -
VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581
TheVkPhysicalDeviceAccelerationStructureFeaturesKHR
::accelerationStructureHostCommands
feature must be enabled -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03725
IfpInfos
[i].mode
isVK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR
, all addresses betweenpInfos
[i].scratchData.hostAddress
andpInfos
[i].scratchData.hostAddress
+ N - 1 must be valid host memory, where N is given by thebuildScratchSize
member of the VkAccelerationStructureBuildSizesInfoKHR structure returned from a call to vkGetAccelerationStructureBuildSizesKHR with an identical VkAccelerationStructureBuildGeometryInfoKHR structure and primitive count -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03726
IfpInfos
[i].mode
isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
, all addresses betweenpInfos
[i].scratchData.hostAddress
andpInfos
[i].scratchData.hostAddress
+ N - 1 must be valid host memory, where N is given by theupdateScratchSize
member of the VkAccelerationStructureBuildSizesInfoKHR structure returned from a call to vkGetAccelerationStructureBuildSizesKHR with an identical VkAccelerationStructureBuildGeometryInfoKHR structure and primitive count -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03771
For any element ofpInfos
[i].pGeometries
orpInfos
[i].ppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_TRIANGLES_KHR
,geometry.triangles.vertexData.hostAddress
must be a valid host address -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03772
For any element ofpInfos
[i].pGeometries
orpInfos
[i].ppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_TRIANGLES_KHR
, ifgeometry.triangles.indexType
is notVK_INDEX_TYPE_NONE_KHR
,geometry.triangles.indexData.hostAddress
must be a valid host address -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03773
For any element ofpInfos
[i].pGeometries
orpInfos
[i].ppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_TRIANGLES_KHR
, ifgeometry.triangles.transformData.hostAddress
is not0
, it must be a valid host address -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03774
For any element ofpInfos
[i].pGeometries
orpInfos
[i].ppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_AABBS_KHR
,geometry.aabbs.data.hostAddress
must be a valid host address -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03775
For each element ofpInfos
, thebuffer
used to create itsdstAccelerationStructure
member must be bound to memory that was not allocated with multiple instances -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03776
For each element ofpInfos
, if itsmode
member isVK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
thebuffer
used to create itssrcAccelerationStructure
member must be bound to memory that was not allocated with multiple instances -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03777
For each element ofpInfos
, thebuffer
used to create each acceleration structure referenced by thegeometry.instances.data
member of any element ofpGeometries
orppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_INSTANCES_KHR
must be bound to memory that was not allocated with multiple instances -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03778
For any element ofpInfos
[i].pGeometries
orpInfos
[i].ppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_INSTANCES_KHR
,geometry.instances.data.hostAddress
must be a valid host address -
VUID-vkBuildAccelerationStructuresKHR-pInfos-03779
For any element ofpInfos
[i].pGeometries
orpInfos
[i].ppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_INSTANCES_KHR
, each VkAccelerationStructureInstanceKHR::accelerationStructureReference
value ingeometry.instances.data.hostAddress
must be a valid VkAccelerationStructureKHR object -
VUID-vkBuildAccelerationStructuresKHR-pInfos-04930
For any element ofpInfos
[i].pGeometries
orpInfos
[i].ppGeometries
with ageometryType
ofVK_GEOMETRY_TYPE_INSTANCES_KHR
withVK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV
set, eachaccelerationStructureReference
in any structure in VkAccelerationStructureMotionInstanceNV value ingeometry.instances.data.hostAddress
must be a valid VkAccelerationStructureKHR object
-
VUID-vkBuildAccelerationStructuresKHR-device-parameter
device
must be a valid VkDevice handle -
VUID-vkBuildAccelerationStructuresKHR-deferredOperation-parameter
IfdeferredOperation
is not VK_NULL_HANDLE,deferredOperation
must be a valid VkDeferredOperationKHR handle -
VUID-vkBuildAccelerationStructuresKHR-pInfos-parameter
pInfos
must be a valid pointer to an array ofinfoCount
valid VkAccelerationStructureBuildGeometryInfoKHR structures -
VUID-vkBuildAccelerationStructuresKHR-ppBuildRangeInfos-parameter
ppBuildRangeInfos
must be a valid pointer to an array ofinfoCount
VkAccelerationStructureBuildRangeInfoKHR structures -
VUID-vkBuildAccelerationStructuresKHR-infoCount-arraylength
infoCount
must be greater than0
-
VUID-vkBuildAccelerationStructuresKHR-deferredOperation-parent
IfdeferredOperation
is a valid handle, it must have been created, allocated, or retrieved fromdevice
- 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
-
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.