Struct gpu_alloc::GpuAllocator
source · [−]pub struct GpuAllocator<M> { /* private fields */ }Expand description
Memory allocator for Vulkan-like APIs.
Implementations
Creates new instance of GpuAllocator.
Provided DeviceProperties should match properties of MemoryDevice that will be used
with created GpuAllocator instance.
pub unsafe fn alloc(
&mut self,
device: &impl MemoryDevice<M>,
request: Request
) -> Result<MemoryBlock<M>, AllocationError>
pub unsafe fn alloc(
&mut self,
device: &impl MemoryDevice<M>,
request: Request
) -> Result<MemoryBlock<M>, AllocationError>
Allocates memory block from specified device according to the request.
Safety
devicemust be one withDevicePropertiesthat were provided to create thisGpuAllocatorinstance.- Same
deviceinstance must be used for all interactions with oneGpuAllocatorinstance and memory blocks allocated from it.
pub unsafe fn alloc_with_dedicated(
&mut self,
device: &impl MemoryDevice<M>,
request: Request,
dedicated: Dedicated
) -> Result<MemoryBlock<M>, AllocationError>
pub unsafe fn alloc_with_dedicated(
&mut self,
device: &impl MemoryDevice<M>,
request: Request,
dedicated: Dedicated
) -> Result<MemoryBlock<M>, AllocationError>
Allocates memory block from specified device according to the request.
This function allows user to force specific allocation strategy.
Improper use can lead to suboptimal performance or too large overhead.
Prefer GpuAllocator::alloc if doubt.
Safety
devicemust be one withDevicePropertiesthat were provided to create thisGpuAllocatorinstance.- Same
deviceinstance must be used for all interactions with oneGpuAllocatorinstance and memory blocks allocated from it.
Deallocates memory block previously allocated from this GpuAllocator instance.
Safety
- Memory block must have been allocated by this
GpuAllocatorinstance devicemust be one withDevicePropertiesthat were provided to create thisGpuAllocatorinstance- Same
deviceinstance must be used for all interactions with oneGpuAllocatorinstance and memory blocks allocated from it
Deallocates leftover memory objects. Should be used before dropping.
Safety
devicemust be one withDevicePropertiesthat were provided to create thisGpuAllocatorinstance- Same
deviceinstance must be used for all interactions with oneGpuAllocatorinstance and memory blocks allocated from it