#vk #vulkan #erupt #allocator #memory

vk-alloc

A segregated list memory allocator for Vulkan

29 releases (12 stable)

2.3.0 Jan 26, 2022
2.2.0 Dec 11, 2021
2.1.0 Sep 5, 2021
2.0.2 Jul 28, 2021
0.7.2 Mar 29, 2021

#158 in Graphics APIs

Download history 22/week @ 2022-08-06 19/week @ 2022-08-13 73/week @ 2022-08-20 10/week @ 2022-08-27 20/week @ 2022-09-03 47/week @ 2022-09-10 12/week @ 2022-09-17 14/week @ 2022-09-24 27/week @ 2022-10-01 20/week @ 2022-10-08 10/week @ 2022-10-15 11/week @ 2022-10-22 22/week @ 2022-10-29 53/week @ 2022-11-05 38/week @ 2022-11-12 20/week @ 2022-11-19

139 downloads per month
Used in asche

Zlib OR MIT OR Apache-2.0

56KB
1K SLoC

vk-alloc

Latest version Documentation ZLIB MIT Apache

A segregated list memory allocator for Vulkan written in Rust.

Targets Vulkan 1.2+ using erupt.

Features

All features are optional by default.

  • tracing Adds logging using tracing.
  • profiling Adds support for profiling.
  • vk-buffer-device-address: Enables the usage of "vkGetBufferDeviceAddress". Needs the Vulkan 1.2 "bufferDeviceAddress" device feature enabled.

License

Licensed under MIT or Apache-2.0 or ZLIB.


lib.rs:

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();
}

Dependencies

~7–34MB
~605K SLoC