Crate vk_alloc

Source
Expand description

A segregated list memory allocator for Vulkan.

The allocator can pool allocations of a user defined lifetime together to help reducing the fragmentation.

§Example:

#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
enum Lifetime {
    Buffer,
    Image,
}

impl vk_alloc::Lifetime for Lifetime {}

unsafe {
    Allocator::<Lifetime>::new(
        &instance,
        &physical_device,
        &AllocatorDescriptor {
            ..Default::default()
        },
    ).unwrap();

    let allocation = alloc
        .allocate(
            &logical_device,
            &AllocationDescriptor {
                location: MemoryLocation::GpuOnly,
                requirements: vk::MemoryRequirementsBuilder::new()
                    .alignment(512)
                    .size(1024)
                    .memory_type_bits(u32::MAX)
                    .build(),
                lifetime: Lifetime::Buffer,
                is_dedicated: false,
                is_optimal: false,
            },
        )
        .unwrap();
}

Structs§

Allocation
An allocation of the Allocator.
AllocationDescriptor
The descriptor for an allocation on the allocator.
Allocator
The general purpose memory allocator. Implemented as a segregated list allocator.
AllocatorDescriptor
Describes the configuration of an Allocator.

Enums§

AllocatorError
Errors that the allocators can throw.
MemoryLocation
The intended location of the memory.

Traits§

Lifetime
The lifetime of an allocation. Used to pool allocations and reduce fragmentation.