logo
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

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 is Some and the contained buffer or image does not belong to device.

Imports a block of memory from an external source.

Safety
Panics
  • Panics if allocate_info.allocation_size is 0.
  • Panics if allocate_info.dedicated_allocation is Some and the contained buffer or image does not belong to device.

Returns the memory type that this memory was allocated from.

Returns the size in bytes of the memory allocation.

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

Performs the conversion.

Performs the conversion.

Formats the value using the given formatter. Read more

Returns the device that owns Self.

Executes the destructor for this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type of the object.

Returns a reference to the object.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.