// Copyright 2019-2021 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

// Common Valid Usage
// Common to acceleration structure build commands
  * [[VUID-{refpage}-mode-04628]]
    The pname:mode member of each element of pname:pInfos must: be a valid
    elink:VkBuildAccelerationStructureModeKHR value
  * [[VUID-{refpage}-srcAccelerationStructure-04629]]
    If the pname:srcAccelerationStructure member of any element of
    pname:pInfos is not dlink:VK_NULL_HANDLE, the
    pname:srcAccelerationStructure member must: be a valid
    slink:VkAccelerationStructureKHR handle
  * [[VUID-{refpage}-pInfos-04630]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its
    pname:srcAccelerationStructure member must: not be dlink:VK_NULL_HANDLE
  * [[VUID-{refpage}-pInfos-03403]]
    The pname:srcAccelerationStructure member of any element of pname:pInfos
    must: not be the same acceleration structure as the
    pname:dstAccelerationStructure member of any other element of
    pname:pInfos
  * [[VUID-{refpage}-dstAccelerationStructure-03698]]
    The pname:dstAccelerationStructure member of any element of pname:pInfos
    must: not be the same acceleration structure as the
    pname:dstAccelerationStructure member of any other element of
    pname:pInfos
  * [[VUID-{refpage}-dstAccelerationStructure-03800]]
    The pname:dstAccelerationStructure member of any element of pname:pInfos
    must: be a valid slink:VkAccelerationStructureKHR handle
  * [[VUID-{refpage}-pInfos-03699]]
    For each element of pname:pInfos, if its pname:type member is
    ename:VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, its
    pname:dstAccelerationStructure member must: have been created with a
    value of slink:VkAccelerationStructureCreateInfoKHR::pname:type equal to
    either ename:VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR or
    ename:VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR
  * [[VUID-{refpage}-pInfos-03700]]
    For each element of pname:pInfos, if its pname:type member is
    ename:VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR, its
    pname:dstAccelerationStructure member must: have been created with a
    value of slink:VkAccelerationStructureCreateInfoKHR::pname:type equal to
    either ename:VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR or
    ename:VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR
  * [[VUID-{refpage}-pInfos-03663]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR,
    <<acceleration-structure-inactive-prims,inactive primitives>> in its
    pname:srcAccelerationStructure member must: not be made active
  * [[VUID-{refpage}-pInfos-03664]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, active primitives
    in its pname:srcAccelerationStructure member must: not be made
    <<acceleration-structure-inactive-prims,inactive>>
  * [[VUID-{refpage}-None-03407]]
    The pname:dstAccelerationStructure member of any element of pname:pInfos
    must: not be referenced by the pname:geometry.instances.data member of
    any element of pname:pGeometries or pname:ppGeometries with a
    pname:geometryType of ename:VK_GEOMETRY_TYPE_INSTANCES_KHR in any other
    element of pname:pInfos
  * [[VUID-{refpage}-dstAccelerationStructure-03701]]
    The range of memory backing the pname:dstAccelerationStructure member of
    any element of pname:pInfos that is accessed by this command must: not
    overlap the memory backing the pname:srcAccelerationStructure member of
    any other element of pname:pInfos with a pname:mode equal to
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, which is accessed
    by this command
  * [[VUID-{refpage}-dstAccelerationStructure-03702]]
    The range of memory backing the pname:dstAccelerationStructure member of
    any element of pname:pInfos that is accessed by this command must: not
    overlap the memory backing the pname:dstAccelerationStructure member of
    any other element of pname:pInfos, which is accessed by this command
  * [[VUID-{refpage}-dstAccelerationStructure-03703]]
    The range of memory backing the pname:dstAccelerationStructure member of
    any element of pname:pInfos that is accessed by this command must: not
    overlap the memory backing the pname:scratchData member of any element
    of pname:pInfos (including the same element), which is accessed by this
    command
  * [[VUID-{refpage}-scratchData-03704]]
    The range of memory backing the pname:scratchData member of any element
    of pname:pInfos that is accessed by this command must: not overlap the
    memory backing the pname:scratchData member of any other element of
    pname:pInfos, which is accessed by this command
  * [[VUID-{refpage}-scratchData-03705]]
    The range of memory backing the pname:scratchData member of any element
    of pname:pInfos that is accessed by this command must: not overlap the
    memory backing the pname:srcAccelerationStructure member of any element
    of pname:pInfos with a pname:mode equal to
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR (including the
    same element), which is accessed by this command
  * [[VUID-{refpage}-dstAccelerationStructure-03706]]
    The range of memory backing the pname:dstAccelerationStructure member of
    any element of pname:pInfos that is accessed by this command must: not
    overlap the memory backing any acceleration structure referenced by the
    pname:geometry.instances.data member of any element of pname:pGeometries
    or pname:ppGeometries with a pname:geometryType of
    ename:VK_GEOMETRY_TYPE_INSTANCES_KHR in any other element of
    pname:pInfos, which is accessed by this command
  * [[VUID-{refpage}-pInfos-03667]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its
    pname:srcAccelerationStructure member must: have been built before with
    ename:VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR set in
    slink:VkAccelerationStructureBuildGeometryInfoKHR::pname:flags
  * [[VUID-{refpage}-pInfos-03668]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its
    pname:srcAccelerationStructure and pname:dstAccelerationStructure
    members must: either be the same slink:VkAccelerationStructureKHR, or
    not have any <<resources-memory-aliasing, memory aliasing>>
  * [[VUID-{refpage}-pInfos-03758]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its
    pname:geometryCount member must: have the same value which was specified
    when pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03759]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its pname:flags
    member must: have the same value which was specified when
    pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03760]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its pname:type
    member must: have the same value which was specified when
    pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03761]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each
    sname:VkAccelerationStructureGeometryKHR structure referred to by its
    pname:pGeometries or pname:ppGeometries members, its pname:geometryType
    member must: have the same value which was specified when
    pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03762]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each
    sname:VkAccelerationStructureGeometryKHR structure referred to by its
    pname:pGeometries or pname:ppGeometries members, its pname:flags member
    must: have the same value which was specified when
    pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03763]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each
    sname:VkAccelerationStructureGeometryKHR structure referred to by its
    pname:pGeometries or pname:ppGeometries members, if pname:geometryType
    is ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, its
    pname:geometry.triangles.vertexFormat member must: have the same value
    which was specified when pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03764]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each
    sname:VkAccelerationStructureGeometryKHR structure referred to by its
    pname:pGeometries or pname:ppGeometries members, if pname:geometryType
    is ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, its
    pname:geometry.triangles.maxVertex member must: have the same value
    which was specified when pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03765]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each
    sname:VkAccelerationStructureGeometryKHR structure referred to by its
    pname:pGeometries or pname:ppGeometries members, if pname:geometryType
    is ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, its
    pname:geometry.triangles.indexType member must: have the same value
    which was specified when pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03766]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each
    sname:VkAccelerationStructureGeometryKHR structure referred to by its
    pname:pGeometries or pname:ppGeometries members, if pname:geometryType
    is ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, if its
    pname:geometry.triangles.transformData address was `NULL` when
    pname:srcAccelerationStructure was last built, then it must: be `NULL`
  * [[VUID-{refpage}-pInfos-03767]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each
    sname:VkAccelerationStructureGeometryKHR structure referred to by its
    pname:pGeometries or pname:ppGeometries members, if pname:geometryType
    is ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, if its
    pname:geometry.triangles.transformData address was not `NULL` when
    pname:srcAccelerationStructure was last built, then it must: not be
    `NULL`
  * [[VUID-{refpage}-pInfos-03768]]
    For each element of pname:pInfos, if its pname:mode member is
    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each
    sname:VkAccelerationStructureGeometryKHR structure referred to by its
    pname:pGeometries or pname:ppGeometries members, if pname:geometryType
    is ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, and
    pname:geometry.triangles.indexType is not ename:VK_INDEX_TYPE_NONE_KHR,
    then the value of each index referenced must: be the same as the
    corresponding index value when pname:srcAccelerationStructure was last
    built
  * [[VUID-{refpage}-primitiveCount-03769]]
    For each sname:VkAccelerationStructureBuildRangeInfoKHR referenced by
    this command, its pname:primitiveCount member must: have the same value
    which was specified when pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-firstVertex-03770]]
    For each sname:VkAccelerationStructureBuildRangeInfoKHR referenced by
    this command, if the corresponding geometry uses indices, its
    pname:firstVertex member must: have the same value which was specified
    when pname:srcAccelerationStructure was last built
  * [[VUID-{refpage}-pInfos-03801]]
    For each element of pname:pInfos[i].pname:pGeometries or
    pname:pInfos[i].pname:ppGeometries with a pname:geometryType of
    ename:VK_GEOMETRY_TYPE_INSTANCES_KHR, the corresponding
    {maxinstancecheck} must: be less than or equal to
    slink:VkPhysicalDeviceAccelerationStructurePropertiesKHR::pname:maxInstanceCount
// Common Valid Usage
