#1935 add from_handle to DeviceMemory (#2011)

* #1935 add from_handle to DeviceMemory

* change parameter order and fix documentation
This commit is contained in:
Harald Steinmueller 2022-10-02 15:19:53 +02:00 committed by GitHub
parent 7a34d9c080
commit 75ef5218c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,6 +93,35 @@ impl DeviceMemory {
})
}
/// Creates a new `DeviceMemory` from a raw object handle.
///
/// # Safety
///
/// - `handle` must be a valid Vulkan object handle created from `device`.
/// - `allocate_info` must match the info used to create the object.
pub unsafe fn from_handle(
device: Arc<Device>,
handle: ash::vk::DeviceMemory,
allocate_info: MemoryAllocateInfo<'_>,
) -> DeviceMemory {
let MemoryAllocateInfo {
allocation_size,
memory_type_index,
dedicated_allocation: _,
export_handle_types,
_ne: _,
} = allocate_info;
DeviceMemory {
handle,
device,
allocation_size,
memory_type_index,
export_handle_types,
}
}
/// Imports a block of memory from an external source.
///
/// # Safety