pub struct Allocator<LT: Lifetime> { /* private fields */ }
Expand description
The general purpose memory allocator. Implemented as a segregated list allocator.
Implementations
pub unsafe fn new(
instance: &InstanceLoader,
physical_device: PhysicalDevice,
descriptor: &AllocatorDescriptor
) -> Result<Self, AllocatorError>
pub unsafe fn new(
instance: &InstanceLoader,
physical_device: PhysicalDevice,
descriptor: &AllocatorDescriptor
) -> Result<Self, AllocatorError>
Creates a new allocator.
Safety
Caller needs to make sure that the provided instance and device are in a valid state.
pub unsafe fn allocate_memory_for_buffer(
&self,
device: &DeviceLoader,
buffer: Buffer,
location: MemoryLocation,
lifetime: LT
) -> Result<Allocation<LT>, AllocatorError>
pub unsafe fn allocate_memory_for_buffer(
&self,
device: &DeviceLoader,
buffer: Buffer,
location: MemoryLocation,
lifetime: LT
) -> Result<Allocation<LT>, AllocatorError>
Allocates memory for a buffer.
Safety
Caller needs to make sure that the provided device and buffer are in a valid state.
pub unsafe fn allocate_memory_for_image(
&self,
device: &DeviceLoader,
image: Image,
location: MemoryLocation,
lifetime: LT,
is_optimal: bool
) -> Result<Allocation<LT>, AllocatorError>
pub unsafe fn allocate_memory_for_image(
&self,
device: &DeviceLoader,
image: Image,
location: MemoryLocation,
lifetime: LT,
is_optimal: bool
) -> Result<Allocation<LT>, AllocatorError>
Allocates memory for an image. is_optimal
must be set true if the image is a optimal image (a regular texture).
Safety
Caller needs to make sure that the provided device and image are in a valid state.
pub unsafe fn allocate(
&self,
device: &DeviceLoader,
descriptor: &AllocationDescriptor<LT>
) -> Result<Allocation<LT>, AllocatorError>
pub unsafe fn allocate(
&self,
device: &DeviceLoader,
descriptor: &AllocationDescriptor<LT>
) -> Result<Allocation<LT>, AllocatorError>
Allocates memory on the allocator.
Safety
Caller needs to make sure that the provided device is in a valid state.
pub unsafe fn deallocate(
&self,
device: &DeviceLoader,
allocation: &Allocation<LT>
) -> Result<(), AllocatorError>
pub unsafe fn deallocate(
&self,
device: &DeviceLoader,
allocation: &Allocation<LT>
) -> Result<(), AllocatorError>
Frees the allocation.
Safety
Caller needs to make sure that the allocation is not in use anymore and will not be used after being deallocated.
Releases all memory blocks back to the system. Should be called before drop.
Safety
Caller needs to make sure that no allocations are used anymore and will not being used after calling this function.
Number of allocations.
Number of unused ranges between allocations.
Number of bytes used by the allocations.
Number of bytes used by the unused ranges between allocations.
Number of allocated Vulkan memory blocks.