vkGetBufferDeviceAddress
To query a 64-bit buffer device address value which can be used to identify a buffer to API commands or through which buffer memory can be accessed, call:
VkDeviceAddress vkGetBufferDeviceAddress(
VkDevice device,
const VkBufferDeviceAddressInfo* pInfo);
pub fn get_buffer_device_address(
device: vk::Device,
p_info: *const vk::BufferDeviceAddressInfo,
) -> vk::DeviceAddress;
VkDeviceAddress vkGetBufferDeviceAddressKHR(
VkDevice device,
const VkBufferDeviceAddressInfo* pInfo);
pub fn get_buffer_device_address_khr(
device: vk::Device,
p_info: *const vk::BufferDeviceAddressInfo,
) -> vk::DeviceAddress;
VkDeviceAddress vkGetBufferDeviceAddressEXT(
VkDevice device,
const VkBufferDeviceAddressInfo* pInfo);
pub fn get_buffer_device_address_ext(
device: vk::Device,
p_info: *const vk::BufferDeviceAddressInfo,
) -> vk::DeviceAddress;
deviceis the logical device that the buffer was created on.pInfois a pointer to a VkBufferDeviceAddressInfo structure specifying the buffer to retrieve an address for.
The 64-bit return value, bufferBaseAddress, is an address of the
start of pInfo→buffer.
Addresses in the range [bufferBaseAddress, bufferBaseAddress
+ VkBufferCreateInfo::size) can be used to access the
memory bound to this buffer on the device.
A value of zero is reserved as a null pointer and must not be returned
as a valid buffer device address.
If the buffer was created with a non-zero value of
VkBufferOpaqueCaptureAddressCreateInfo::opaqueCaptureAddress or
VkBufferDeviceAddressCreateInfoEXT::deviceAddress,
the return value will be the same address that was returned at capture time.
The returned address must satisfy alignment requirements if certain
conditions are met, outlined below.
The required alignment must be observed for either the returned address of
the buffer, or, if the buffer was created without
VK_BUFFER_CREATE_SPARSE_BINDING_BIT, the returned address of the
buffer minus VkBindBufferMemoryInfo::memoryOffset or equivalent
vkBindBufferMemory offset.
The required alignment is the maximum of the following values:
- The value of VkMemoryRequirements::
alignmentqueried via vkGetBufferMemoryRequirements forpInfo→buffer minStorageBufferOffsetAlignmentifpInfo→bufferwas created withVK_BUFFER_USAGE_2_STORAGE_BUFFER_BITminUniformBufferOffsetAlignmentifpInfo→bufferwas created withVK_BUFFER_USAGE_2_UNIFORM_BUFFER_BITminTexelBufferOffsetAlignmentifpInfo→bufferwas created withVK_BUFFER_USAGE_2_STORAGE_TEXEL_BUFFER_BITorVK_BUFFER_USAGE_2_UNIFORM_TEXEL_BUFFER_BITresourceHeapAlignmentifpInfo→bufferwas created withVK_BUFFER_USAGE_2_DESCRIPTOR_HEAP_BIT_EXTsamplerHeapAlignmentifpInfo→bufferwas created withVK_BUFFER_USAGE_2_DESCRIPTOR_HEAP_BIT_EXTdescriptorBufferOffsetAlignmentifpInfo→bufferwas created withVK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXTorVK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT- VkBufferDeviceAddressAlignmentAllocateInfoVALVE::
alignmentifpInfo→bufferwas created withoutVK_BUFFER_CREATE_SPARSE_BINDING_BITand the bound VkDeviceMemory was created with specified non-zero alignment of VkBufferDeviceAddressAlignmentAllocateInfoVALVE::alignment - VkBufferDeviceAddressAlignmentAllocateInfoVALVE::
alignmentifpInfo→bufferwas created withVK_BUFFER_CREATE_SPARSE_BINDING_BIT, and the buffer was created with non-zero VkBufferDeviceAddressAlignmentAllocateInfoVALVE::alignment - 256, if
pInfo→bufferwas created withVK_BUFFER_USAGE_2_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR, and VK_KHR_device_address_commands is supported
If multiple VkBuffer objects are bound to overlapping ranges of VkDeviceMemory, implementations may return address ranges which overlap. In this case, it is ambiguous which VkBuffer is associated with any given device address. For purposes of valid usage, if multiple VkBuffer objects can be attributed to a device address, a VkBuffer is selected such that valid usage passes, if it exists.
Valid Usage
VUID-vkGetBufferDeviceAddress-bufferDeviceAddress-03324
The bufferDeviceAddress feature
or the [VkPhysicalDeviceBufferDeviceAddressFeaturesEXT::bufferDeviceAddress](xref::features-bufferDeviceAddressEXT)
feature
must be enabled, and at least one of the following conditions must be
met
bufferis sparsebufferis bound completely and contiguously to a singleVkDeviceMemoryobjectbufferwas created with theVK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BITflag and the [VkPhysicalDeviceBufferDeviceAddressFeaturesEXT::bufferDeviceAddress](xref::features-bufferDeviceAddressEXT) feature is enabled on the device
VUID-vkGetBufferDeviceAddress-device-03325
If device was created with multiple physical devices, then the
bufferDeviceAddressMultiDevice
or [VkPhysicalDeviceBufferDeviceAddressFeaturesEXT::bufferDeviceAddressMultiDevice](xref::features-bufferDeviceAddressMultiDeviceEXT)
feature must be enabled
Valid Usage (Implicit)
VUID-vkGetBufferDeviceAddress-device-parameter
device must be a valid VkDevice handle
VUID-vkGetBufferDeviceAddress-pInfo-parameter
pInfo must be a valid pointer to a valid VkBufferDeviceAddressInfo structure