pub struct MemoryAllocation {
pool: MemoryPool,
inner: Allocation,
}vulkan only.Expand description
A sub-allocation that records which pool to free it to.
Fields§
§pool: MemoryPool§inner: AllocationMethods from Deref<Target = Allocation>§
pub fn chunk_id(&self) -> Option<NonZero<u64>>
pub fn memory_properties(&self) -> MemoryPropertyFlags
pub fn memory_properties(&self) -> MemoryPropertyFlags
Returns the [vk::MemoryPropertyFlags] of this allocation.
pub unsafe fn memory(&self) -> DeviceMemory
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
pub fn is_dedicated(&self) -> bool
Returns true if this allocation is using a dedicated underlying allocation.
pub fn offset(&self) -> u64
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 mapped_ptr(&self) -> Option<NonNull<c_void>>
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]>
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
impl Debug for MemoryAllocation
Auto Trait Implementations§
impl Freeze for MemoryAllocation
impl RefUnwindSafe for MemoryAllocation
impl Send for MemoryAllocation
impl Sync for MemoryAllocation
impl Unpin for MemoryAllocation
impl UnsafeUnpin for MemoryAllocation
impl UnwindSafe for MemoryAllocation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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