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§

Enums§

Traits§

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