// Copyright 2020-2024 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-07459]]
    pname:buffer must: not have been bound to 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::VKSC_VERSION_1_0[]
  * [[VUID-{refpage}-apiVersion-07920]]
    If
ifdef::VK_KHR_dedicated_allocation[]
    the apiext:VK_KHR_dedicated_allocation extension is not enabled,
endif::VK_KHR_dedicated_allocation[]
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_dedicated_allocation[and]
    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::VKSC_VERSION_1_0[]
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
  * [[VUID-{refpage}-memory-02985]]
    If pname:memory was allocated by a memory import operation,
ifdef::VK_ANDROID_external_memory_android_hardware_buffer[]
    that is not slink:VkImportAndroidHardwareBufferInfoANDROID with a
    non-`NULL` pname:buffer value,
endif::VK_ANDROID_external_memory_android_hardware_buffer[]
    the external handle type of the imported memory must: also have been set
    in slink:VkExternalMemoryBufferCreateInfo::pname:handleTypes when
    pname:buffer was created
ifdef::VK_ANDROID_external_memory_android_hardware_buffer[]
  * [[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
  * [[VUID-{refpage}-bufferDeviceAddressCaptureReplay-09200]]
    If the
    slink:VkPhysicalDeviceBufferDeviceAddressFeatures::pname:bufferDeviceAddressCaptureReplay
    feature is enabled and pname:buffer was created with the
    ename:VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT bit set,
    pname:memory must: have been allocated with the
    ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT bit set
endif::VK_VERSION_1_2,VK_KHR_buffer_device_address[]
ifdef::VK_FUCHSIA_buffer_collection[]
  * [[VUID-{refpage}-buffer-06408]]
    If pname:buffer was created with
    slink:VkBufferCollectionBufferCreateInfoFUCHSIA chained to
    slink:VkBufferCreateInfo::pname:pNext, pname:memory must: be allocated
    with a slink:VkImportMemoryBufferCollectionFUCHSIA chained to
    slink:VkMemoryAllocateInfo::pname:pNext
endif::VK_FUCHSIA_buffer_collection[]
ifdef::VK_EXT_descriptor_buffer[]
  * [[VUID-{refpage}-descriptorBufferCaptureReplay-08112]]
    If the pname:buffer was created with the
    ename:VK_BUFFER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT bit set,
    pname:memory must: have been allocated with the
    ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT bit set
  * [[VUID-{refpage}-buffer-09201]]
    If the pname:buffer was created with the
    ename:VK_BUFFER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT bit set,
    pname:memory must: have been allocated with the
    ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT bit set
endif::VK_EXT_descriptor_buffer[]
// Common Valid Usage
