[−][src]Struct vulkayes_core::memory::device::DeviceMemoryAllocation
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]
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
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 thedevice
.bind_offset + size
must be less than or equal to the size of the entirevk::DeviceMemory
allocationmap_impl(device, memory, size, offset)
must return a validNonNull<u8>
that is a mapping ofmemory
range starting atoffset
withsize
.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]
&self,
accessor: impl FnOnce(DeviceMemoryMappingAccess<'_>) -> MappingAccessResult
) -> Result<(), MapError>
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.
fn deref(&self) -> &Self::Target
[src]
impl Drop for DeviceMemoryAllocation
[src]
Auto Trait Implementations
impl !RefUnwindSafe for DeviceMemoryAllocation
[src]
impl !Send for DeviceMemoryAllocation
[src]
impl !Sync for DeviceMemoryAllocation
[src]
impl Unpin for DeviceMemoryAllocation
[src]
impl !UnwindSafe for DeviceMemoryAllocation
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,