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

// Common Valid Usage
// Common to binding any memory to an image
  * [[VUID-{refpage}-image-01044]]
    pname:image must: not already be backed by a memory object
  * [[VUID-{refpage}-image-01045]]
    pname:image must: not have been created with any sparse memory binding
    flags
  * [[VUID-{refpage}-memoryOffset-01046]]
    pname:memoryOffset must: be less than the size of pname:memory
ifdef::VK_VERSION_1_1,VK_KHR_dedicated_allocation[]
  * [[VUID-{refpage}-image-01445]]
    If pname:image requires a dedicated allocation (as reported by
    flink:vkGetImageMemoryRequirements2 in
    slink:VkMemoryDedicatedRequirements::pname:requiresDedicatedAllocation
    for pname:image), pname:memory must: have been created with
    slink:VkMemoryDedicatedAllocateInfo::pname:image equal to pname:image
ifndef::VK_NV_dedicated_allocation_image_aliasing[]
  * [[VUID-{refpage}-memory-01509]]
    If the sname:VkMemoryAllocateInfo provided when pname:memory was
    allocated included a slink:VkMemoryDedicatedAllocateInfo structure in
    its pname:pNext chain, and
    slink:VkMemoryDedicatedAllocateInfo::pname:image was not
    dlink:VK_NULL_HANDLE, then pname:image must: equal
    slink:VkMemoryDedicatedAllocateInfo::pname:image and pname:memoryOffset
    must: be zero
endif::VK_NV_dedicated_allocation_image_aliasing[]
ifdef::VK_NV_dedicated_allocation_image_aliasing[]
  * [[VUID-{refpage}-memory-02628]]
    If the <<features-dedicatedAllocationImageAliasing,dedicated allocation
    image aliasing>> feature is not enabled, and the
    sname:VkMemoryAllocateInfo provided when pname:memory was allocated
    included a slink:VkMemoryDedicatedAllocateInfo structure in its
    pname:pNext chain, and slink:VkMemoryDedicatedAllocateInfo::pname:image
    was not dlink:VK_NULL_HANDLE, then pname:image must: equal
    slink:VkMemoryDedicatedAllocateInfo::pname:image and pname:memoryOffset
    must: be zero
  * [[VUID-{refpage}-memory-02629]]
    If the <<features-dedicatedAllocationImageAliasing,dedicated allocation
    image aliasing>> feature is enabled, and the sname:VkMemoryAllocateInfo
    provided when pname:memory was allocated included a
    slink:VkMemoryDedicatedAllocateInfo structure in its pname:pNext chain,
    and slink:VkMemoryDedicatedAllocateInfo::pname:image was not
    dlink:VK_NULL_HANDLE, then pname:memoryOffset must: be zero, and
    pname:image must: be either equal to
    slink:VkMemoryDedicatedAllocateInfo::pname:image or an image that was
    created using the same parameters in slink:VkImageCreateInfo, with the
    exception that pname:extent and pname:arrayLayers may: differ subject to
    the following restrictions: every dimension in the pname:extent
    parameter of the image being bound must: be equal to or smaller than the
    original image for which the allocation was created; and the
    pname:arrayLayers parameter of the image being bound must: be equal to
    or smaller than the original image for which the allocation was created
endif::VK_NV_dedicated_allocation_image_aliasing[]
endif::VK_VERSION_1_1,VK_KHR_dedicated_allocation[]
ifdef::VK_VERSION_1_1[]
  * [[VUID-{refpage}-None-01901]]
    If image was created with the ename:VK_IMAGE_CREATE_PROTECTED_BIT bit
    set, the image must: be bound to a memory object allocated with a memory
    type that reports ename:VK_MEMORY_PROPERTY_PROTECTED_BIT
  * [[VUID-{refpage}-None-01902]]
    If image was created with the ename:VK_IMAGE_CREATE_PROTECTED_BIT bit
    not set, the image must: not be bound to a memory object created with a
    memory type that reports ename:VK_MEMORY_PROPERTY_PROTECTED_BIT
endif::VK_VERSION_1_1[]
ifdef::VK_NV_dedicated_allocation[]
  * [[VUID-{refpage}-image-01050]]
    If pname:image was created with
    slink:VkDedicatedAllocationImageCreateInfoNV::pname:dedicatedAllocation
    equal to ename:VK_TRUE, pname:memory must: have been created with
    slink:VkDedicatedAllocationMemoryAllocateInfoNV::pname:image equal to an
    image handle created with identical creation parameters to pname:image
    and pname:memoryOffset must: be zero
ifndef::VK_VERSION_1_1,VK_KHR_dedicated_allocation[]
  * [[VUID-{refpage}-image-01051]]
    If pname:image was not created with
    slink:VkDedicatedAllocationImageCreateInfoNV::pname:dedicatedAllocation
    equal to ename:VK_TRUE, pname:memory must: not have been allocated
    dedicated for a specific buffer or image
endif::VK_VERSION_1_1,VK_KHR_dedicated_allocation[]
endif::VK_NV_dedicated_allocation[]
ifdef::VK_VERSION_1_1,VK_KHR_external_memory[]
  * [[VUID-{refpage}-memory-02728]]
    If the value of slink:VkExportMemoryAllocateInfo::pname:handleTypes used
    to allocate pname:memory is not `0`, it must: include at least one of
    the handles set in
    slink:VkExternalMemoryImageCreateInfo::pname:handleTypes when
    pname:image was created
ifndef::VK_ANDROID_external_memory_android_hardware_buffer[]
  * [[VUID-{refpage}-memory-02729]]
    If pname:memory was created by a memory import operation, the external
    handle type of the imported memory must: also have been set in
    slink:VkExternalMemoryImageCreateInfo::pname:handleTypes when
    pname:image was created
endif::VK_ANDROID_external_memory_android_hardware_buffer[]
ifdef::VK_ANDROID_external_memory_android_hardware_buffer[]
  * [[VUID-{refpage}-memory-02989]]
    If pname:memory was created by a memory import operation, that is not
    slink:VkImportAndroidHardwareBufferInfoANDROID with a non-`NULL`
    pname:buffer value, the external handle type of the imported memory
    must: also have been set in
    slink:VkExternalMemoryImageCreateInfo::pname:handleTypes when
    pname:image was created
  * [[VUID-{refpage}-memory-02990]]
    If pname:memory was created with the
    slink:VkImportAndroidHardwareBufferInfoANDROID memory import operation
    with a non-`NULL` pname:buffer value,
    ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID
    must: also have been set in
    slink:VkExternalMemoryImageCreateInfo::pname:handleTypes when
    pname:image was created
endif::VK_ANDROID_external_memory_android_hardware_buffer[]
endif::VK_VERSION_1_1,VK_KHR_external_memory[]
// Common Valid Usage
