vkGetAccelerationStructureBuildSizesKHR
To get the build sizes for an acceleration structure, call:
void vkGetAccelerationStructureBuildSizesKHR(
VkDevice device,
VkAccelerationStructureBuildTypeKHR buildType,
const VkAccelerationStructureBuildGeometryInfoKHR* pBuildInfo,
const uint32_t* pMaxPrimitiveCounts,
VkAccelerationStructureBuildSizesInfoKHR* pSizeInfo);
deviceis the logical device that will be used for creating the acceleration structure.buildTypedefines whether host or device operations (or both) are being queried for.pBuildInfois a pointer to a VkAccelerationStructureBuildGeometryInfoKHR structure describing parameters of a build operation.pMaxPrimitiveCountsis a pointer to an array ofpBuildInfo→geometryCountuint32_tvalues defining the number of primitives built into each geometry.pSizeInfois a pointer to a VkAccelerationStructureBuildSizesInfoKHR structure which returns the size required for an acceleration structure and the sizes required for the scratch buffers, given the build parameters.
The srcAccelerationStructure, dstAccelerationStructure, and
mode members of pBuildInfo are ignored.
Any VkDeviceOrHostAddressKHR or VkDeviceOrHostAddressConstKHR
members of pBuildInfo are ignored by this command, except that the
hostAddress member of
VkAccelerationStructureGeometryTrianglesDataKHR::transformData
will be examined to check if it is NULL.
An acceleration structure created with the accelerationStructureSize
returned by this command supports any build or update with a
VkAccelerationStructureBuildGeometryInfoKHR structure and array of
VkAccelerationStructureBuildRangeInfoKHR structures subject to the
following properties:
- The build command is a host build command, and
buildTypeisVK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_KHRorVK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR - The build command is a device build command, and
buildTypeisVK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHRorVK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR - For VkAccelerationStructureBuildGeometryInfoKHR:
- Its
type, andflagsmembers are equal topBuildInfo→typeandpBuildInfo→flags, respectively. geometryCountis less than or equal topBuildInfo→geometryCount.- For each element of either
pGeometriesorppGeometriesat a given index, itsgeometryTypemember is equal topBuildInfo→geometryType. - For each element of either
pGeometriesorppGeometriesat a given index, itsflagsmember is equal to the corresponding member of the same element inpBuildInfo. - For each element of either
pGeometriesorppGeometriesat a given index, with ageometryTypemember equal toVK_GEOMETRY_TYPE_TRIANGLES_KHR, thevertexFormatandindexTypemembers ofgeometry.trianglesare equal to the corresponding members of the same element inpBuildInfo. - For each element of either
pGeometriesorppGeometriesat a given index, with ageometryTypemember equal toVK_GEOMETRY_TYPE_TRIANGLES_KHR, themaxVertexmember ofgeometry.trianglesis less than or equal to the corresponding member of the same element inpBuildInfo. - For each element of either
pGeometriesorppGeometriesat a given index, with ageometryTypemember equal toVK_GEOMETRY_TYPE_TRIANGLES_KHR, if the applicable address in thetransformDatamember ofgeometry.trianglesis notNULL, the correspondingtransformData.hostAddressparameter inpBuildInfois notNULL.
- Its
- For each VkAccelerationStructureBuildRangeInfoKHR corresponding to
the VkAccelerationStructureBuildGeometryInfoKHR:
- Its
primitiveCountmember is less than or equal to the corresponding element ofpMaxPrimitiveCounts. - For each element of either
pGeometriesorppGeometriesat a given index, with ageometryTypemember equal toVK_GEOMETRY_TYPE_TRIANGLES_KHR, if thepNextchain contains VkAccelerationStructureTrianglesOpacityMicromapEXT the corresponding member ofpBuildInfoalso contains VkAccelerationStructureTrianglesOpacityMicromapEXT and with an equivalentmicromap. - For each element of either
pGeometriesorppGeometriesat a given index, with ageometryTypemember equal toVK_GEOMETRY_TYPE_TRIANGLES_KHR, if thepNextchain contains VkAccelerationStructureTrianglesDisplacementMicromapNV the corresponding member ofpBuildInfoalso contains VkAccelerationStructureTrianglesDisplacementMicromapNV and with an equivalentmicromap.
- Its
Similarly, the updateScratchSize value will support any build command
specifying the VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR
mode under the above conditions, and the buildScratchSize value
will support any build command specifying the
VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR mode under the
above conditions.
Valid Usage
VUID-vkGetAccelerationStructureBuildSizesKHR-accelerationStructure-08933
The VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructure
feature must be enabled
VUID-vkGetAccelerationStructureBuildSizesKHR-device-03618
If device was created with multiple physical devices, then the
bufferDeviceAddressMultiDevice feature must be enabled
VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619
If pBuildInfo→geometryCount is not 0, pMaxPrimitiveCountsmust be a valid pointer to an array of pBuildInfo→geometryCount
uint32_t values
VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03785
If pBuildInfo→pGeometries or pBuildInfo→ppGeometries has a
geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, each
pMaxPrimitiveCounts[i] must be less than or equal to
VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxInstanceCount
Valid Usage (Implicit)
VUID-vkGetAccelerationStructureBuildSizesKHR-device-parameter
device must be a valid VkDevice handle
VUID-vkGetAccelerationStructureBuildSizesKHR-buildType-parameter
buildType must be a valid VkAccelerationStructureBuildTypeKHR value
VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-parameter
pBuildInfo must be a valid pointer to a valid VkAccelerationStructureBuildGeometryInfoKHR structure
VUID-vkGetAccelerationStructureBuildSizesKHR-pMaxPrimitiveCounts-parameter
If pMaxPrimitiveCounts is not NULL, pMaxPrimitiveCounts must be a valid pointer to an array of pBuildInfo→geometryCount uint32_t values
VUID-vkGetAccelerationStructureBuildSizesKHR-pSizeInfo-parameter
pSizeInfo must be a valid pointer to a VkAccelerationStructureBuildSizesInfoKHR structure