Struct vulkano::memory::DeviceMemory[][src]

pub struct DeviceMemory { /* fields omitted */ }

Represents memory that has been allocated.

The destructor of DeviceMemory automatically frees the memory.

Example

use vulkano::memory::DeviceMemory;

let mem_ty = device.physical_device().memory_types().next().unwrap();

// Allocates 1KB of memory.
let memory = DeviceMemory::alloc(device.clone(), mem_ty, 1024).unwrap();

Implementations

impl DeviceMemory[src]

pub fn alloc(
    device: Arc<Device>,
    memory_type: MemoryType<'_>,
    size: usize
) -> Result<DeviceMemory, DeviceMemoryAllocError>
[src]

Allocates a chunk 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.

Panic

  • Panics if size is 0.
  • Panics if memory_type doesn’t belong to the same physical device as device.

pub fn dedicated_alloc(
    device: Arc<Device>,
    memory_type: MemoryType<'_>,
    size: usize,
    resource: DedicatedAlloc<'_>
) -> Result<DeviceMemory, DeviceMemoryAllocError>
[src]

Same as alloc, but allows specifying a resource that will be bound to the memory.

If a buffer or an image is specified in resource, then the returned memory must not be bound to a different buffer or image.

If the VK_KHR_dedicated_allocation extension is enabled on the device, then it will be used by this method. Otherwise the resource parameter will be ignored.

pub fn alloc_and_map(
    device: Arc<Device>,
    memory_type: MemoryType<'_>,
    size: usize
) -> Result<MappedDeviceMemory, DeviceMemoryAllocError>
[src]

Allocates a chunk of memory and maps it.

Panic

  • Panics if memory_type doesn’t belong to the same physical device as device.
  • Panics if the memory type is not host-visible.

pub fn dedicated_alloc_and_map(
    device: Arc<Device>,
    memory_type: MemoryType<'_>,
    size: usize,
    resource: DedicatedAlloc<'_>
) -> Result<MappedDeviceMemory, DeviceMemoryAllocError>
[src]

Equivalent of dedicated_alloc for alloc_and_map.

pub fn memory_type(&self) -> MemoryType<'_>[src]

Returns the memory type this chunk was allocated on.

pub fn size(&self) -> usize[src]

Returns the size in bytes of that memory chunk.

Trait Implementations

impl AsMut<DeviceMemory> for MappedDeviceMemory[src]

fn as_mut(&mut self) -> &mut DeviceMemory[src]

Performs the conversion.

impl AsRef<DeviceMemory> for MappedDeviceMemory[src]

fn as_ref(&self) -> &DeviceMemory[src]

Performs the conversion.

impl Debug for DeviceMemory[src]

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl DeviceOwned for DeviceMemory[src]

fn device(&self) -> &Arc<Device>[src]

Returns the device that owns Self.

impl Drop for DeviceMemory[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl VulkanObject for DeviceMemory[src]

type Object = DeviceMemory

The type of the object.

const TYPE: ObjectType[src]

The ObjectType of the internal Vulkan handle.

fn internal_object(&self) -> DeviceMemory[src]

Returns a reference to the object.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> Content for T[src]

pub fn ref_from_ptr(*mut c_void, usize) -> Option<*mut T>[src]

Builds a pointer to this type from a raw pointer.

pub fn is_size_suitable(usize) -> bool[src]

Returns true if the size is suitable to store a type like this.

pub fn indiv_size() -> usize[src]

Returns the size of an individual element.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.