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

// Common Valid Usage
// Common to binding any memory to a buffer
  * [[VUID-{refpage}-buffer-01029]]
    pname:buffer must: not already be backed by a memory object
  * [[VUID-{refpage}-buffer-01030]]
    pname:buffer must: not have been created with any sparse memory binding
    flags
  * [[VUID-{refpage}-memoryOffset-01031]]
    pname:memoryOffset must: be less than the size of pname:memory
  * [[VUID-{refpage}-memory-01035]]
    pname:memory must: have been allocated using one of the memory types
    allowed in the pname:memoryTypeBits member of the
    sname:VkMemoryRequirements structure returned from a call to
    fname:vkGetBufferMemoryRequirements with pname:buffer
  * [[VUID-{refpage}-memoryOffset-01036]]
    pname:memoryOffset must: be an integer multiple of the pname:alignment
    member of the sname:VkMemoryRequirements structure returned from a call
    to fname:vkGetBufferMemoryRequirements with pname:buffer
  * [[VUID-{refpage}-size-01037]]
    The pname:size member of the sname:VkMemoryRequirements structure
    returned from a call to fname:vkGetBufferMemoryRequirements with
    pname:buffer must: be less than or equal to the size of pname:memory
    minus pname:memoryOffset
ifdef::VK_VERSION_1_1,VK_KHR_dedicated_allocation[]
  * [[VUID-{refpage}-buffer-01444]]
    If pname:buffer requires a dedicated allocation (as reported by
    flink:vkGetBufferMemoryRequirements2 in
    slink:VkMemoryDedicatedRequirements::pname:requiresDedicatedAllocation
    for pname:buffer), pname:memory must: have been allocated with
    slink:VkMemoryDedicatedAllocateInfo::pname:buffer equal to pname:buffer
  * [[VUID-{refpage}-memory-01508]]
    If the sname:VkMemoryAllocateInfo provided when pname:memory was
    allocated included a slink:VkMemoryDedicatedAllocateInfo structure in
    its pname:pNext chain, and
    slink:VkMemoryDedicatedAllocateInfo::pname:buffer was not
    dlink:VK_NULL_HANDLE, then pname:buffer must: equal
    slink:VkMemoryDedicatedAllocateInfo::pname:buffer, and
    pname:memoryOffset must: be zero
endif::VK_VERSION_1_1,VK_KHR_dedicated_allocation[]
ifdef::VK_VERSION_1_1[]
  * [[VUID-{refpage}-None-01898]]
    If pname:buffer was created with the
    ename:VK_BUFFER_CREATE_PROTECTED_BIT bit set, the buffer must: be bound
    to a memory object allocated with a memory type that reports
    ename:VK_MEMORY_PROPERTY_PROTECTED_BIT
  * [[VUID-{refpage}-None-01899]]
    If pname:buffer was created with the
    ename:VK_BUFFER_CREATE_PROTECTED_BIT bit not set, the buffer must: not
    be bound to a memory object allocated with a memory type that reports
    ename:VK_MEMORY_PROPERTY_PROTECTED_BIT
endif::VK_VERSION_1_1[]
ifdef::VK_NV_dedicated_allocation[]
  * [[VUID-{refpage}-buffer-01038]]
    If pname:buffer was created with
    slink:VkDedicatedAllocationBufferCreateInfoNV::pname:dedicatedAllocation
    equal to ename:VK_TRUE, pname:memory must: have been allocated with
    slink:VkDedicatedAllocationMemoryAllocateInfoNV::pname:buffer equal to a
    buffer handle created with identical creation parameters to pname:buffer
    and pname:memoryOffset must: be zero
ifndef::VK_VERSION_1_1,VK_KHR_dedicated_allocation[]
  * [[VUID-{refpage}-buffer-01039]]
    If pname:buffer was not created with
    slink:VkDedicatedAllocationBufferCreateInfoNV::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-02726]]
    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:VkExternalMemoryBufferCreateInfo::pname:handleTypes when
    pname:buffer was created
ifndef::VK_ANDROID_external_memory_android_hardware_buffer[]
  * [[VUID-{refpage}-memory-02727]]
    If pname:memory was allocated by a memory import operation, the external
    handle type of the imported memory must: also have been set in
    slink:VkExternalMemoryBufferCreateInfo::pname:handleTypes when
    pname:buffer was created
endif::VK_ANDROID_external_memory_android_hardware_buffer[]
ifdef::VK_ANDROID_external_memory_android_hardware_buffer[]
  * [[VUID-{refpage}-memory-02985]]
    If pname:memory was allocated 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:VkExternalMemoryBufferCreateInfo::pname:handleTypes when
    pname:buffer was created
  * [[VUID-{refpage}-memory-02986]]
    If pname:memory was allocated 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:VkExternalMemoryBufferCreateInfo::pname:handleTypes when
    pname:buffer was created
endif::VK_ANDROID_external_memory_android_hardware_buffer[]
endif::VK_VERSION_1_1,VK_KHR_external_memory[]
ifdef::VK_VERSION_1_2,VK_KHR_buffer_device_address[]
  * [[VUID-{refpage}-bufferDeviceAddress-03339]]
    If the
    slink:VkPhysicalDeviceBufferDeviceAddressFeatures::pname:bufferDeviceAddress
    feature is enabled and pname:buffer was created with the
    ename:VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT bit set, pname:memory
    must: have been allocated with the
    ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT bit set
endif::VK_VERSION_1_2,VK_KHR_buffer_device_address[]
// Common Valid Usage
