Skip to main content

MemoryAllocation

Struct MemoryAllocation 

Source
pub struct MemoryAllocation {
    pool: MemoryPool,
    inner: Allocation,
}
Available on vulkan only.
Expand description

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

Fields§

§pool: MemoryPool§inner: Allocation

Methods from Deref<Target = Allocation>§

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

pub fn memory_properties(&self) -> MemoryPropertyFlags

Returns the [vk::MemoryPropertyFlags] of this allocation.

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.

pub fn is_dedicated(&self) -> bool

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

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.

pub fn size(&self) -> u64

Returns the size of the allocation

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.

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.

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
§

impl<T> Downcast<T> for T

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = Infallible

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

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

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.
§

impl<T> Upcast<T> for T

§

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

§

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

§

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

§

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

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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