[][src]Struct vulkayes_core::memory::device::DeviceMemoryAllocation

pub struct DeviceMemoryAllocation { /* fields omitted */ }

Struct that represents a device memory allocation.

Implementations

impl DeviceMemoryAllocation[src]

pub unsafe fn new(
    device: Vrc<Device>,
    memory: DeviceMemory,
    bind_offset: DeviceSize,
    size: NonZeroU64,
    map_impl: Box<dyn FnMut(&Vrc<Device>, DeviceMemory, DeviceSize, NonZeroU64) -> Result<NonNull<[u8]>, MapError>>,
    unmap_impl: Box<dyn FnMut(&Vrc<Device>, DeviceMemory, DeviceSize, NonZeroU64, NonNull<[u8]>)>,
    drop_impl: Box<dyn FnOnce(&Vrc<Device>, DeviceMemory, DeviceSize, NonZeroU64)>
) -> Self
[src]

Creates a new memory allocation from parameters.

The map_impl parameter is a FnMut that is called when the memory is to be mapped. The memory mapping is stored inside the allocation Vutex until it is manually unmapped. Note that it is up to the user to ensure that the memory is actually mappable.

The unmap_impl parameter is a FnMut that is called when the memory is to be unmapped. It is guaranteed to be called with the same parameters as the corresponding map_impl and the pointer returned from the corresponding map_impl.

The drop_impl parameter is a FnOnce that is called in the Drop implementation of this struct. It should properly clean up the allocation according to the allocator implementation.

Safety

  • memory must have been allocated from the device.
  • bind_offset + size must be less than or equal to the size of the entire vk::DeviceMemory allocation
  • map_impl(device, memory, size, offset) must return a valid NonNull<u8> that is a mapping of memory range starting at offset with size.
  • map_impl must return an error if the memory object is already mapped

pub const fn device(&self) -> &Vrc<Device>[src]

pub const fn bind_offset(&self) -> DeviceSize[src]

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

pub fn is_mapped(&self) -> bool[src]

Returns true if this memory is currently mapped.

Note that this check requires locking a Vutex.

Panic

This function will panic if the Vutex is poisoned.

pub fn unmap(&self) -> bool[src]

Unmaps the memory if it is currently mapped.

Returns whether the memory was mapped.

Panic

This function will panic if the Vutex is poisoned.

pub fn map_memory_with(
    &self,
    accessor: impl FnOnce(DeviceMemoryMappingAccess<'_>) -> MappingAccessResult
) -> Result<(), MapError>
[src]

Provides mutable access to the mapped memory, possibly mapping it in the process.

The accessor parameter receives an access object into the mapped memory. If it returns false, the memory will be unmapped before returning.

Panic

This function will panic if the Vutex is poisoned.

Methods from Deref<Target = DeviceMemory>

Trait Implementations

impl Debug for DeviceMemoryAllocation[src]

impl Deref for DeviceMemoryAllocation[src]

type Target = DeviceMemory

The resulting type after dereferencing.

impl Drop for DeviceMemoryAllocation[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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.

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.