Struct vulkano::memory::DeviceMemory
source · [−]pub struct DeviceMemory { /* private fields */ }
Expand description
Represents memory that has been allocated from the device.
The destructor of DeviceMemory
automatically frees the memory.
Example
use vulkano::memory::{DeviceMemory, MemoryAllocateInfo};
let memory_type = device.physical_device().memory_types().next().unwrap();
// Allocates 1KB of memory.
let memory = DeviceMemory::allocate(
device.clone(),
MemoryAllocateInfo {
allocation_size: 1024,
memory_type_index: memory_type.id(),
..Default::default()
},
).unwrap();
Implementations
sourceimpl DeviceMemory
impl DeviceMemory
sourcepub fn allocate(
device: Arc<Device>,
allocate_info: MemoryAllocateInfo<'_>
) -> Result<Self, DeviceMemoryAllocationError>
pub fn allocate(
device: Arc<Device>,
allocate_info: MemoryAllocateInfo<'_>
) -> Result<Self, DeviceMemoryAllocationError>
Allocates a block of memory from the device.
Some platforms may have a limit on the maximum size of a single allocation. For example, certain systems may fail to create allocations with a size greater than or equal to 4GB.
Panics
- Panics if
allocate_info.allocation_size
is 0. - Panics if
allocate_info.dedicated_allocation
isSome
and the contained buffer or image does not belong todevice
.
sourcepub unsafe fn import(
device: Arc<Device>,
allocate_info: MemoryAllocateInfo<'_>,
import_info: MemoryImportInfo
) -> Result<Self, DeviceMemoryAllocationError>
pub unsafe fn import(
device: Arc<Device>,
allocate_info: MemoryAllocateInfo<'_>,
import_info: MemoryImportInfo
) -> Result<Self, DeviceMemoryAllocationError>
Imports a block of memory from an external source.
Safety
- See the documentation of the variants of
MemoryImportInfo
.
Panics
- Panics if
allocate_info.allocation_size
is 0. - Panics if
allocate_info.dedicated_allocation
isSome
and the contained buffer or image does not belong todevice
.
sourcepub fn memory_type(&self) -> MemoryType<'_>
pub fn memory_type(&self) -> MemoryType<'_>
Returns the memory type that this memory was allocated from.
sourcepub fn allocation_size(&self) -> DeviceSize
pub fn allocation_size(&self) -> DeviceSize
Returns the size in bytes of the memory allocation.
sourcepub fn export_fd(
&self,
handle_type: ExternalMemoryHandleType
) -> Result<File, DeviceMemoryExportError>
pub fn export_fd(
&self,
handle_type: ExternalMemoryHandleType
) -> Result<File, DeviceMemoryExportError>
Exports the device memory into a Unix file descriptor. The caller owns the returned File
.
Panic
- Panics if the user requests an invalid handle type for this device memory object.
Trait Implementations
sourceimpl AsMut<DeviceMemory> for MappedDeviceMemory
impl AsMut<DeviceMemory> for MappedDeviceMemory
sourcefn as_mut(&mut self) -> &mut DeviceMemory
fn as_mut(&mut self) -> &mut DeviceMemory
Performs the conversion.
sourceimpl AsRef<DeviceMemory> for MappedDeviceMemory
impl AsRef<DeviceMemory> for MappedDeviceMemory
sourcefn as_ref(&self) -> &DeviceMemory
fn as_ref(&self) -> &DeviceMemory
Performs the conversion.
sourceimpl Debug for DeviceMemory
impl Debug for DeviceMemory
sourceimpl DeviceOwned for DeviceMemory
impl DeviceOwned for DeviceMemory
sourceimpl Drop for DeviceMemory
impl Drop for DeviceMemory
sourceimpl Hash for DeviceMemory
impl Hash for DeviceMemory
sourceimpl PartialEq<DeviceMemory> for DeviceMemory
impl PartialEq<DeviceMemory> for DeviceMemory
sourceimpl VulkanObject for DeviceMemory
impl VulkanObject for DeviceMemory
type Object = DeviceMemory
type Object = DeviceMemory
The type of the object.
sourcefn internal_object(&self) -> DeviceMemory
fn internal_object(&self) -> DeviceMemory
Returns a reference to the object.
impl Eq for DeviceMemory
Auto Trait Implementations
impl RefUnwindSafe for DeviceMemory
impl Send for DeviceMemory
impl Sync for DeviceMemory
impl Unpin for DeviceMemory
impl UnwindSafe for DeviceMemory
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more