// Copyright 2020-2024 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

// Common Valid Usage
// Common to VkCmdCopyImage* commands
  * [[VUID-{refpage}-pRegions-00124]]
    The union of all source regions, and the union of all destination
    regions, specified by the elements of pname:pRegions, must: not overlap
    in memory
ifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
  * [[VUID-{refpage}-srcImage-01995]]
    The <<resources-image-format-features,format features>> of
    pname:srcImage must: contain ename:VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
endif::VK_VERSION_1_1,VK_KHR_maintenance1[]
  * [[VUID-{refpage}-srcImageLayout-00128]]
    pname:srcImageLayout must: specify the layout of the image subresources
    of pname:srcImage specified in pname:pRegions at the time this command
    is executed on a sname:VkDevice
  * [[VUID-{refpage}-srcImageLayout-01917]]
    pname:srcImageLayout must: be
ifdef::VK_KHR_shared_presentable_image[]
    ename:VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
endif::VK_KHR_shared_presentable_image[]
    ename:VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, or
    ename:VK_IMAGE_LAYOUT_GENERAL
  * [[VUID-{refpage}-srcImage-09460]]
    If pname:srcImage and pname:dstImage are the same, and any elements of
    pname:pRegions contains the pname:srcSubresource and
    pname:dstSubresource with matching pname:mipLevel and overlapping array
    layers, then the pname:srcImageLayout and pname:dstImageLayout must: be
    ename:VK_IMAGE_LAYOUT_GENERAL
ifdef::VK_KHR_shared_presentable_image[]
    or ename:VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR
endif::VK_KHR_shared_presentable_image[]
ifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
  * [[VUID-{refpage}-dstImage-01996]]
    The <<resources-image-format-features,format features>> of
    pname:dstImage must: contain ename:VK_FORMAT_FEATURE_TRANSFER_DST_BIT
endif::VK_VERSION_1_1,VK_KHR_maintenance1[]
  * [[VUID-{refpage}-dstImageLayout-00133]]
    pname:dstImageLayout must: specify the layout of the image subresources
    of pname:dstImage specified in pname:pRegions at the time this command
    is executed on a sname:VkDevice
  * [[VUID-{refpage}-dstImageLayout-01395]]
    pname:dstImageLayout must: be
ifdef::VK_KHR_shared_presentable_image[]
    ename:VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
endif::VK_KHR_shared_presentable_image[]
    ename:VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, or
    ename:VK_IMAGE_LAYOUT_GENERAL
  * [[VUID-{refpage}-srcImage-01548]]
ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
    If the elink:VkFormat of each of pname:srcImage and pname:dstImage is
    not a <<formats-requiring-sampler-ycbcr-conversion,_multi-planar
    format_>>, the
endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
ifndef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[The]
    elink:VkFormat of each of pname:srcImage and pname:dstImage must: be
    <<formats-size-compatibility,size-compatible>>
ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
  * [[VUID-{refpage}-None-01549]]
    In a copy to or from a plane of a
    <<formats-requiring-sampler-ycbcr-conversion,multi-planar image>>, the
    elink:VkFormat of the image and plane must: be compatible according to
    <<formats-compatible-planes,the description of compatible planes>> for
    the plane being copied
endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
  * [[VUID-{refpage}-srcImage-09247]]
    If the elink:VkFormat of each of pname:srcImage and pname:dstImage is a
    <<compressed_image_formats,compressed image format>>, the formats must:
    have the same texel block extent
  * [[VUID-{refpage}-srcImage-00136]]
    The sample count of pname:srcImage and pname:dstImage must: match
  * [[VUID-{refpage}-srcOffset-01783]]
    The pname:srcOffset and pname:extent members of each element of
    pname:pRegions must: respect the image transfer granularity requirements
    of pname:commandBuffer's command pool's queue family, as described in
    slink:VkQueueFamilyProperties
  * [[VUID-{refpage}-dstOffset-01784]]
    The pname:dstOffset and pname:extent members of each element of
    pname:pRegions must: respect the image transfer granularity requirements
    of pname:commandBuffer's command pool's queue family, as described in
    slink:VkQueueFamilyProperties
// The remaining common VU used to be in image_copy_common.adoc and have been
// rewritten to apply to the calling command rather than the structure
// parameter(s) of that command.
ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
  * [[VUID-{refpage}-srcImage-01551]]
    If neither pname:srcImage nor pname:dstImage has a
    <<formats-requiring-sampler-ycbcr-conversion, multi-planar image
    format>> then for each element of pname:pRegions,
    pname:srcSubresource.aspectMask and pname:dstSubresource.aspectMask
    must: match
  * [[VUID-{refpage}-srcImage-08713]]
    If pname:srcImage has a <<formats-requiring-sampler-ycbcr-conversion,
    multi-planar image format>>, then for each element of pname:pRegions,
    pname:srcSubresource.aspectMask must: be a single valid
    <<formats-planes-image-aspect,multi-planar aspect mask>> bit
  * [[VUID-{refpage}-dstImage-08714]]
    If pname:dstImage has a <<formats-requiring-sampler-ycbcr-conversion,
    multi-planar image format>>, then for each element of pname:pRegions,
    pname:dstSubresource.aspectMask must: be a single valid
    <<formats-planes-image-aspect,multi-planar aspect mask>> bit
  * [[VUID-{refpage}-srcImage-01556]]
    If pname:srcImage has a
    <<formats-requiring-sampler-ycbcr-conversion,multi-planar image format>>
    and the pname:dstImage does not have a multi-planar image format, then
    for each element of pname:pRegions, pname:dstSubresource.aspectMask
    must: be ename:VK_IMAGE_ASPECT_COLOR_BIT
  * [[VUID-{refpage}-dstImage-01557]]
    If pname:dstImage has a
    <<formats-requiring-sampler-ycbcr-conversion,multi-planar image format>>
    and the pname:srcImage does not have a multi-planar image format, then
    for each element of pname:pRegions, pname:srcSubresource.aspectMask
    must: be ename:VK_IMAGE_ASPECT_COLOR_BIT
endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
ifndef::VKSC_VERSION_1_0[]
  * [[VUID-{refpage}-apiVersion-07932]]
    If
ifdef::VK_KHR_maintenance1[]
    the apiext:VK_KHR_maintenance1 extension is not enabled,
endif::VK_KHR_maintenance1[]
ifdef::VK_VERSION_1_1,VK_KHR_maintenance1[or]
ifdef::VK_VERSION_1_1[]
    slink:VkPhysicalDeviceProperties::pname:apiVersion is less than Vulkan
    1.1,
endif::VK_VERSION_1_1[]
ifdef::VK_VERSION_1_1,VK_KHR_maintenance1[and]
    either pname:srcImage or pname:dstImage is of type
    ename:VK_IMAGE_TYPE_3D, then for each element of pname:pRegions,
    pname:srcSubresource.baseArrayLayer and
    pname:dstSubresource.baseArrayLayer must: both be `0`, and
    pname:srcSubresource.layerCount and pname:dstSubresource.layerCount
    must: both be `1`
endif::VKSC_VERSION_1_0[]
  * [[VUID-{refpage}-srcImage-04443]]
    If pname:srcImage is of type ename:VK_IMAGE_TYPE_3D, then for each
    element of pname:pRegions, pname:srcSubresource.baseArrayLayer must: be
    `0` and pname:srcSubresource.layerCount must: be `1`
  * [[VUID-{refpage}-dstImage-04444]]
    If pname:dstImage is of type ename:VK_IMAGE_TYPE_3D, then for each
    element of pname:pRegions, pname:dstSubresource.baseArrayLayer must: be
    `0` and pname:dstSubresource.layerCount must: be `1`
  * [[VUID-{refpage}-aspectMask-00142]]
    For each element of pname:pRegions, pname:srcSubresource.aspectMask
    must: specify aspects present in pname:srcImage
  * [[VUID-{refpage}-aspectMask-00143]]
    For each element of pname:pRegions, pname:dstSubresource.aspectMask
    must: specify aspects present in pname:dstImage
  * [[VUID-{refpage}-srcOffset-00144]]
    For each element of pname:pRegions, pname:srcOffset.x and
    [eq]#(pname:extent.width {plus} pname:srcOffset.x)# must: both be
    greater than or equal to `0` and less than or equal to the width of the
    specified pname:srcSubresource of pname:srcImage
  * [[VUID-{refpage}-srcOffset-00145]]
    For each element of pname:pRegions, pname:srcOffset.y and
    [eq]#(pname:extent.height {plus} pname:srcOffset.y)# must: both be
    greater than or equal to `0` and less than or equal to the height of the
    specified pname:srcSubresource of pname:srcImage
  * [[VUID-{refpage}-srcImage-00146]]
    If pname:srcImage is of type ename:VK_IMAGE_TYPE_1D, then for each
    element of pname:pRegions, pname:srcOffset.y must: be `0` and
    pname:extent.height must: be `1`
  * [[VUID-{refpage}-srcOffset-00147]]
    If pname:srcImage is of type ename:VK_IMAGE_TYPE_3D, then for each
    element of pname:pRegions, pname:srcOffset.z and
    [eq]#(pname:extent.depth {plus} pname:srcOffset.z)# must: both be
    greater than or equal to `0` and less than or equal to the depth of the
    specified pname:srcSubresource of pname:srcImage
  * [[VUID-{refpage}-srcImage-01785]]
    If pname:srcImage is of type ename:VK_IMAGE_TYPE_1D, then for each
    element of pname:pRegions, pname:srcOffset.z must: be `0` and
    pname:extent.depth must: be `1`
  * [[VUID-{refpage}-dstImage-01786]]
    If pname:dstImage is of type ename:VK_IMAGE_TYPE_1D, then for each
    element of pname:pRegions, pname:dstOffset.z must: be `0` and
    pname:extent.depth must: be `1`
  * [[VUID-{refpage}-srcImage-01787]]
    If pname:srcImage is of type ename:VK_IMAGE_TYPE_2D, then for each
    element of pname:pRegions, pname:srcOffset.z must: be `0`
  * [[VUID-{refpage}-dstImage-01788]]
    If pname:dstImage is of type ename:VK_IMAGE_TYPE_2D, then for each
    element of pname:pRegions, pname:dstOffset.z must: be `0`
ifndef::VKSC_VERSION_1_0[]
  * [[VUID-{refpage}-apiVersion-07933]]
    If
ifdef::VK_KHR_maintenance1[]
    the apiext:VK_KHR_maintenance1 extension is not enabled,
endif::VK_KHR_maintenance1[]
ifdef::VK_VERSION_1_1,VK_KHR_maintenance1[and]
ifdef::VK_VERSION_1_1[]
    slink:VkPhysicalDeviceProperties::pname:apiVersion is less than Vulkan
    1.1,
endif::VK_VERSION_1_1[]
    pname:srcImage and pname:dstImage must: have the same elink:VkImageType
  * [[VUID-{refpage}-apiVersion-08969]]
    If
ifdef::VK_KHR_maintenance1[]
    the apiext:VK_KHR_maintenance1 extension is not enabled,
endif::VK_KHR_maintenance1[]
ifdef::VK_VERSION_1_1,VK_KHR_maintenance1[and]
ifdef::VK_VERSION_1_1[]
    slink:VkPhysicalDeviceProperties::pname:apiVersion is less than Vulkan
    1.1,
endif::VK_VERSION_1_1[]
    pname:srcImage or pname:dstImage is of type ename:VK_IMAGE_TYPE_2D, then
    for each element of pname:pRegions, pname:extent.depth must: be `1`
endif::VKSC_VERSION_1_0[]
ifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
  * [[VUID-{refpage}-srcImage-07743]]
    If pname:srcImage and pname:dstImage have a different elink:VkImageType,
ifdef::VK_KHR_maintenance5[]
    and <<features-maintenance5, pname:maintenance5>> is not enabled,
endif::VK_KHR_maintenance5[]
    one must: be ename:VK_IMAGE_TYPE_3D and the other must: be
    ename:VK_IMAGE_TYPE_2D
  * [[VUID-{refpage}-srcImage-08793]]
    If pname:srcImage and pname:dstImage have the same elink:VkImageType,
    for each element of pname:pRegions,
ifdef::VK_KHR_maintenance5[]
    if neither of the pname:layerCount members of pname:srcSubresource or
    pname:dstSubresource are ename:VK_REMAINING_ARRAY_LAYERS,
endif::VK_KHR_maintenance5[]
    the pname:layerCount members of pname:srcSubresource or
    pname:dstSubresource must: match
ifdef::VK_KHR_maintenance5[]
  * [[VUID-{refpage}-srcImage-08794]]
    If pname:srcImage and pname:dstImage have the same elink:VkImageType,
    and one of the pname:layerCount members of pname:srcSubresource or
    pname:dstSubresource is ename:VK_REMAINING_ARRAY_LAYERS, the other
    member must: be either ename:VK_REMAINING_ARRAY_LAYERS or equal to the
    pname:arrayLayers member of the slink:VkImageCreateInfo used to create
    the image minus pname:baseArrayLayer
endif::VK_KHR_maintenance5[]
  * [[VUID-{refpage}-srcImage-01790]]
    If pname:srcImage and pname:dstImage are both of type
    ename:VK_IMAGE_TYPE_2D, then for each element of pname:pRegions,
    pname:extent.depth must: be `1`
  * [[VUID-{refpage}-srcImage-01791]]
    If pname:srcImage is of type ename:VK_IMAGE_TYPE_2D, and pname:dstImage
    is of type ename:VK_IMAGE_TYPE_3D, then for each element of
    pname:pRegions, pname:extent.depth must: equal
    pname:srcSubresource.layerCount
  * [[VUID-{refpage}-dstImage-01792]]
    If pname:dstImage is of type ename:VK_IMAGE_TYPE_2D, and pname:srcImage
    is of type ename:VK_IMAGE_TYPE_3D, then for each element of
    pname:pRegions, pname:extent.depth must: equal
    pname:dstSubresource.layerCount
endif::VK_VERSION_1_1,VK_KHR_maintenance1[]
  * [[VUID-{refpage}-dstOffset-00150]]
    For each element of pname:pRegions, pname:dstOffset.x and
    [eq]#(pname:extent.width {plus} pname:dstOffset.x)# must: both be
    greater than or equal to `0` and less than or equal to the width of the
    specified pname:dstSubresource of pname:dstImage
  * [[VUID-{refpage}-dstOffset-00151]]
    For each element of pname:pRegions, pname:dstOffset.y and
    [eq]#(pname:extent.height {plus} pname:dstOffset.y)# must: both be
    greater than or equal to `0` and less than or equal to the height of the
    specified pname:dstSubresource of pname:dstImage
  * [[VUID-{refpage}-dstImage-00152]]
    If pname:dstImage is of type ename:VK_IMAGE_TYPE_1D, then for each
    element of pname:pRegions, pname:dstOffset.y must: be `0` and
    pname:extent.height must: be `1`
  * [[VUID-{refpage}-dstOffset-00153]]
    If pname:dstImage is of type ename:VK_IMAGE_TYPE_3D, then for each
    element of pname:pRegions, pname:dstOffset.z and
    [eq]#(pname:extent.depth {plus} pname:dstOffset.z)# must: both be
    greater than or equal to `0` and less than or equal to the depth of the
    specified pname:dstSubresource of pname:dstImage
  * [[VUID-{refpage}-pRegions-07278]]
    For each element of pname:pRegions, pname:srcOffset.x must: be a
    multiple of the <<formats-compatibility-classes,texel block extent
    width>> of the elink:VkFormat of pname:srcImage
  * [[VUID-{refpage}-pRegions-07279]]
    For each element of pname:pRegions, pname:srcOffset.y must: be a
    multiple of the <<formats-compatibility-classes,texel block extent
    height>> of the elink:VkFormat of pname:srcImage
  * [[VUID-{refpage}-pRegions-07280]]
    For each element of pname:pRegions, pname:srcOffset.z must: be a
    multiple of the <<formats-compatibility-classes,texel block extent
    depth>> of the elink:VkFormat of pname:srcImage
  * [[VUID-{refpage}-pRegions-07281]]
    For each element of pname:pRegions, pname:dstOffset.x must: be a
    multiple of the <<formats-compatibility-classes,texel block extent
    width>> of the elink:VkFormat of pname:dstImage
  * [[VUID-{refpage}-pRegions-07282]]
    For each element of pname:pRegions, pname:dstOffset.y must: be a
    multiple of the <<formats-compatibility-classes,texel block extent
    height>> of the elink:VkFormat of pname:dstImage
  * [[VUID-{refpage}-pRegions-07283]]
    For each element of pname:pRegions, pname:dstOffset.z must: be a
    multiple of the <<formats-compatibility-classes,texel block extent
    depth>> of the elink:VkFormat of pname:dstImage
  * [[VUID-{refpage}-srcImage-01728]]
    For each element of pname:pRegions, if the sum of pname:srcOffset.x and
    pname:extent.width does not equal the width of the subresource specified
    by pname:srcSubresource, pname:extent.width must: be a multiple of the
    <<formats-compatibility-classes,texel block extent width>> of the
    elink:VkFormat of pname:srcImage
  * [[VUID-{refpage}-srcImage-01729]]
    For each element of pname:pRegions, if the sum of pname:srcOffset.y and
    pname:extent.height does not equal the height of the subresource
    specified by pname:srcSubresource, pname:extent.height must: be a
    multiple of the <<formats-compatibility-classes,texel block extent
    height>> of the elink:VkFormat of pname:srcImage
  * [[VUID-{refpage}-srcImage-01730]]
    For each element of pname:pRegions, if the sum of pname:srcOffset.z and
    pname:extent.depth does not equal the depth of the subresource specified
    by pname:srcSubresource, pname:extent.depth must: be a multiple of the
    <<formats-compatibility-classes,texel block extent depth>> of the
    elink:VkFormat of pname:srcImage
  * [[VUID-{refpage}-dstImage-01732]]
    For each element of pname:pRegions, if the sum of pname:dstOffset.x and
    pname:extent.width does not equal the width of the subresource specified
    by pname:dstSubresource, pname:extent.width must: be a multiple of the
    <<formats-compatibility-classes,texel block extent width>> of the
    elink:VkFormat of pname:dstImage
  * [[VUID-{refpage}-dstImage-01733]]
    For each element of pname:pRegions, if the sum of pname:dstOffset.y and
    pname:extent.height does not equal the height of the subresource
    specified by pname:dstSubresource, pname:extent.height must: be a
    multiple of the <<formats-compatibility-classes,texel block extent
    height>> of the elink:VkFormat of pname:dstImage
  * [[VUID-{refpage}-dstImage-01734]]
    For each element of pname:pRegions, if the sum of pname:dstOffset.z and
    pname:extent.depth does not equal the depth of the subresource specified
    by pname:dstSubresource, pname:extent.depth must: be a multiple of the
    <<formats-compatibility-classes,texel block extent depth>> of the
    elink:VkFormat of pname:dstImage
  * [[VUID-{refpage}-aspect-06662]]
ifdef::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
    If the pname:aspect member of any element of pname:pRegions includes any
    flag other than ename:VK_IMAGE_ASPECT_STENCIL_BIT or pname:srcImage was
    not created with <<VkImageStencilUsageCreateInfo,separate stencil
    usage>>,
endif::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
    ename:VK_IMAGE_USAGE_TRANSFER_SRC_BIT must: have been included in the
    slink:VkImageCreateInfo::pname:usage used to create pname:srcImage
  * [[VUID-{refpage}-aspect-06663]]
ifdef::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
    If the pname:aspect member of any element of pname:pRegions includes any
    flag other than ename:VK_IMAGE_ASPECT_STENCIL_BIT or pname:dstImage was
    not created with <<VkImageStencilUsageCreateInfo,separate stencil
    usage>>,
endif::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
    ename:VK_IMAGE_USAGE_TRANSFER_DST_BIT must: have been included in the
    slink:VkImageCreateInfo::pname:usage used to create pname:dstImage
ifdef::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
  * [[VUID-{refpage}-aspect-06664]]
    If the pname:aspect member of any element of pname:pRegions includes
    ename:VK_IMAGE_ASPECT_STENCIL_BIT, and pname:srcImage was created with
    <<VkImageStencilUsageCreateInfo,separate stencil usage>>,
    ename:VK_IMAGE_USAGE_TRANSFER_SRC_BIT must: have been included in the
    slink:VkImageStencilUsageCreateInfo::pname:stencilUsage used to create
    pname:srcImage
  * [[VUID-{refpage}-aspect-06665]]
    If the pname:aspect member of any element of pname:pRegions includes
    ename:VK_IMAGE_ASPECT_STENCIL_BIT, and pname:dstImage was created with
    <<VkImageStencilUsageCreateInfo,separate stencil usage>>,
    ename:VK_IMAGE_USAGE_TRANSFER_DST_BIT must: have been included in the
    slink:VkImageStencilUsageCreateInfo::pname:stencilUsage used to create
    pname:dstImage
endif::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
// Common Valid Usage
