1// Copyright 2020-2021 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5// Common Valid Usage 6// Common to binding any memory to a buffer 7 * [[VUID-{refpage}-buffer-01029]] 8 pname:buffer must: not already be backed by a memory object 9 * [[VUID-{refpage}-buffer-01030]] 10 pname:buffer must: not have been created with any sparse memory binding 11 flags 12 * [[VUID-{refpage}-memoryOffset-01031]] 13 pname:memoryOffset must: be less than the size of pname:memory 14 * [[VUID-{refpage}-memory-01035]] 15 pname:memory must: have been allocated using one of the memory types 16 allowed in the pname:memoryTypeBits member of the 17 sname:VkMemoryRequirements structure returned from a call to 18 fname:vkGetBufferMemoryRequirements with pname:buffer 19 * [[VUID-{refpage}-memoryOffset-01036]] 20 pname:memoryOffset must: be an integer multiple of the pname:alignment 21 member of the sname:VkMemoryRequirements structure returned from a call 22 to fname:vkGetBufferMemoryRequirements with pname:buffer 23 * [[VUID-{refpage}-size-01037]] 24 The pname:size member of the sname:VkMemoryRequirements structure 25 returned from a call to fname:vkGetBufferMemoryRequirements with 26 pname:buffer must: be less than or equal to the size of pname:memory 27 minus pname:memoryOffset 28ifdef::VK_VERSION_1_1,VK_KHR_dedicated_allocation[] 29 * [[VUID-{refpage}-buffer-01444]] 30 If pname:buffer requires a dedicated allocation (as reported by 31 flink:vkGetBufferMemoryRequirements2 in 32 slink:VkMemoryDedicatedRequirements::pname:requiresDedicatedAllocation 33 for pname:buffer), pname:memory must: have been allocated with 34 slink:VkMemoryDedicatedAllocateInfo::pname:buffer equal to pname:buffer 35 * [[VUID-{refpage}-memory-01508]] 36 If the sname:VkMemoryAllocateInfo provided when pname:memory was 37 allocated included a slink:VkMemoryDedicatedAllocateInfo structure in 38 its pname:pNext chain, and 39 slink:VkMemoryDedicatedAllocateInfo::pname:buffer was not 40 dlink:VK_NULL_HANDLE, then pname:buffer must: equal 41 slink:VkMemoryDedicatedAllocateInfo::pname:buffer, and 42 pname:memoryOffset must: be zero 43endif::VK_VERSION_1_1,VK_KHR_dedicated_allocation[] 44ifdef::VK_VERSION_1_1[] 45 * [[VUID-{refpage}-None-01898]] 46 If pname:buffer was created with the 47 ename:VK_BUFFER_CREATE_PROTECTED_BIT bit set, the buffer must: be bound 48 to a memory object allocated with a memory type that reports 49 ename:VK_MEMORY_PROPERTY_PROTECTED_BIT 50 * [[VUID-{refpage}-None-01899]] 51 If pname:buffer was created with the 52 ename:VK_BUFFER_CREATE_PROTECTED_BIT bit not set, the buffer must: not 53 be bound to a memory object allocated with a memory type that reports 54 ename:VK_MEMORY_PROPERTY_PROTECTED_BIT 55endif::VK_VERSION_1_1[] 56ifdef::VK_NV_dedicated_allocation[] 57 * [[VUID-{refpage}-buffer-01038]] 58 If pname:buffer was created with 59 slink:VkDedicatedAllocationBufferCreateInfoNV::pname:dedicatedAllocation 60 equal to ename:VK_TRUE, pname:memory must: have been allocated with 61 slink:VkDedicatedAllocationMemoryAllocateInfoNV::pname:buffer equal to a 62 buffer handle created with identical creation parameters to pname:buffer 63 and pname:memoryOffset must: be zero 64ifndef::VK_VERSION_1_1,VK_KHR_dedicated_allocation[] 65 * [[VUID-{refpage}-buffer-01039]] 66 If pname:buffer was not created with 67 slink:VkDedicatedAllocationBufferCreateInfoNV::pname:dedicatedAllocation 68 equal to ename:VK_TRUE, pname:memory must: not have been allocated 69 dedicated for a specific buffer or image 70endif::VK_VERSION_1_1,VK_KHR_dedicated_allocation[] 71endif::VK_NV_dedicated_allocation[] 72ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 73 * [[VUID-{refpage}-memory-02726]] 74 If the value of slink:VkExportMemoryAllocateInfo::pname:handleTypes used 75 to allocate pname:memory is not `0`, it must: include at least one of 76 the handles set in 77 slink:VkExternalMemoryBufferCreateInfo::pname:handleTypes when 78 pname:buffer was created 79ifndef::VK_ANDROID_external_memory_android_hardware_buffer[] 80 * [[VUID-{refpage}-memory-02727]] 81 If pname:memory was allocated by a memory import operation, the external 82 handle type of the imported memory must: also have been set in 83 slink:VkExternalMemoryBufferCreateInfo::pname:handleTypes when 84 pname:buffer was created 85endif::VK_ANDROID_external_memory_android_hardware_buffer[] 86ifdef::VK_ANDROID_external_memory_android_hardware_buffer[] 87 * [[VUID-{refpage}-memory-02985]] 88 If pname:memory was allocated by a memory import operation, that is not 89 slink:VkImportAndroidHardwareBufferInfoANDROID with a non-`NULL` 90 pname:buffer value, the external handle type of the imported memory 91 must: also have been set in 92 slink:VkExternalMemoryBufferCreateInfo::pname:handleTypes when 93 pname:buffer was created 94 * [[VUID-{refpage}-memory-02986]] 95 If pname:memory was allocated with the 96 slink:VkImportAndroidHardwareBufferInfoANDROID memory import operation 97 with a non-`NULL` pname:buffer value, 98 ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID 99 must: also have been set in 100 slink:VkExternalMemoryBufferCreateInfo::pname:handleTypes when 101 pname:buffer was created 102endif::VK_ANDROID_external_memory_android_hardware_buffer[] 103endif::VK_VERSION_1_1,VK_KHR_external_memory[] 104ifdef::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 105 * [[VUID-{refpage}-bufferDeviceAddress-03339]] 106 If the 107 slink:VkPhysicalDeviceBufferDeviceAddressFeatures::pname:bufferDeviceAddress 108 feature is enabled and pname:buffer was created with the 109 ename:VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT bit set, pname:memory 110 must: have been allocated with the 111 ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT bit set 112endif::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 113ifdef::VK_FUCHSIA_buffer_collection[] 114 * [[VUID-{refpage}-buffer-06408]] 115 If pname:buffer was created with 116 slink:VkBufferCollectionBufferCreateInfoFUCHSIA chained to 117 slink:VkBufferCreateInfo::pname:pNext, pname:memory must: be allocated 118 with a slink:VkImportMemoryBufferCollectionFUCHSIA chained to 119 slink:VkMemoryAllocateInfo::pname:pNext 120endif::VK_FUCHSIA_buffer_collection[] 121// Common Valid Usage 122