Skip to main content

MemoryAllocation

Struct MemoryAllocation 

Source
pub struct MemoryAllocation { /* private fields */ }
Available on vulkan only.
Expand description

A sub-allocation that records which pool to free it to.

Methods from Deref<Target = Allocation>§

Source

pub fn chunk_id(&self) -> Option<NonZero<u64>>

Source

pub fn memory_properties(&self) -> MemoryPropertyFlags

Returns the vk::MemoryPropertyFlags of this allocation.

Source

pub unsafe fn memory(&self) -> DeviceMemory

Returns the vk::DeviceMemory object that is backing this allocation.

This memory object can be shared with multiple other allocations and shouldn’t be freed or allocated from without this library, because that will lead to undefined behavior.

§Safety

The result of this function can safely be passed into ash::Device::bind_buffer_memory(), ash::Device::bind_image_memory() etc. It is exposed for this reason. Keep in mind to also pass Self::offset() along to those.

Also, this Allocation must not be Allocator::free()d while such a created resource on this vk::DeviceMemory is still live.

Source

pub fn is_dedicated(&self) -> bool

Returns true if this allocation is using a dedicated underlying allocation.

Source

pub fn offset(&self) -> u64

Returns the offset of the allocation on the vk::DeviceMemory. When binding the memory to a buffer or image, this offset needs to be supplied as well.

Source

pub fn size(&self) -> u64

Returns the size of the allocation

Source

pub fn mapped_ptr(&self) -> Option<NonNull<c_void>>

Returns a valid mapped pointer if the memory is host visible, otherwise it will return None. The pointer already points to the exact memory region of the suballocation, so no offset needs to be applied.

Source

pub fn mapped_slice(&self) -> Option<&[u8]>

Returns a valid mapped slice if the memory is host visible, otherwise it will return None. The slice already references the exact memory region of the allocation, so no offset needs to be applied.

Source

pub fn is_null(&self) -> bool

Trait Implementations§

Source§

impl Debug for MemoryAllocation

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for MemoryAllocation

Source§

type Target = Allocation

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,