Skip to content

Commit

Permalink
#1935 add from_handle to DeviceMemory (#2011)
Browse files Browse the repository at this point in the history
* #1935 add from_handle to DeviceMemory

* change parameter order and fix documentation
  • Loading branch information
hsteinmueller authored Oct 2, 2022
1 parent 7a34d9c commit 75ef521
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions vulkano/src/memory/device_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 75ef521

Please sign in to comment.