Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
path: source/modules/antono2/vulkan
- uses: actions/checkout@v7
with:
repository: antono2/mem
ref: v1.0.3
path: source/modules/antono2/mem
repository: antono2/memory
ref: v1.1.0
path: source/modules/antono2/memory
- uses: prantlf/setup-v-action@v4
- name: Install Vulkan development library
run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libvulkan-volk-dev mesa-vulkan-drivers
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

All notable changes to this project will be documented in this file.

## 2.3.0 - 2026-09-11

- Migrate the allocation-policy dependency to the canonical `antono2.memory`
module and pin it to the immutable v1.1.0 release.

## 2.2.0 - 2026-09-10

- Migrate the allocation-policy dependency to the canonical `antono2.mem`
module and pin it to the immutable v1.0.3 release.
- Pin the allocation-policy dependency to the immutable v1.0.3 short-name
release, superseded by the canonical dependency in v2.3.0.
- Return a local `UploadRingStats` value from `UploadRing.stats()` so the public
Vulkan API does not expose the underlying policy module's type.
- Share one reference-counted Vulkan mapping across mapped suballocations in the
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ enough for examples while avoiding one Vulkan allocation per resource.
v install antono2.vkmemalloc
```

VPM installs the Vulkan bindings and `antono2.mem` dependencies automatically.
VPM installs the Vulkan bindings and `antono2.memory` dependencies automatically.

The Vulkan loader, headers, and a working GPU driver must also be installed.

The allocator uses [`antono2.mem`](https://github.com/antono2/mem),
specifically `mem.RangeAllocator`,
The allocator uses [`antono2.memory`](https://github.com/antono2/memory),
specifically `memory.RangeAllocator`,
for its dependency-free block suballocation policy. Vulkan handles remain
isolated in this module.

Expand Down
8 changes: 4 additions & 4 deletions block_pool.v
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module vkmemalloc

import antono2.mem
import antono2.memory

struct BlockReservation {
owner voidptr
block_id u64
allocation mem.RangeAllocation
allocation memory.RangeAllocation
pub:
memory_type u32
offset u64
Expand All @@ -17,7 +17,7 @@ struct MemoryBlock {
memory_type u32
capacity u64
dedicated bool
ranges &mem.RangeAllocator @[required]
ranges &memory.RangeAllocator @[required]
}

struct BlockPoolStats {
Expand Down Expand Up @@ -106,7 +106,7 @@ fn (mut pool MemoryBlockPool) add_block_with_policy(memory_type u32, capacity u6
memory_type: memory_type
capacity: capacity
dedicated: dedicated
ranges: mem.new_range_allocator(capacity)
ranges: memory.new_range_allocator(capacity)
}
return id
}
Expand Down
10 changes: 5 additions & 5 deletions upload_ring.v
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module vkmemalloc

import antono2.mem
import antono2.memory
import antono2.vulkan as vk

// UploadSlice identifies one persistently mapped staging-buffer range. Slices
// must be retired in allocation order after the GPU no longer reads them.
pub struct UploadSlice {
owner voidptr
allocation mem.RingAllocation
allocation memory.RingAllocation
pub:
offset u64
size u64
Expand Down Expand Up @@ -37,8 +37,8 @@ pub:
mut:
allocator &Allocator = unsafe { nil }
backing AllocationInfo
mapped voidptr = unsafe { nil }
ranges &mem.RingAllocator = unsafe { nil }
mapped voidptr = unsafe { nil }
ranges &memory.RingAllocator = unsafe { nil }
destroyed bool
}

Expand Down Expand Up @@ -77,7 +77,7 @@ pub fn new_upload_ring(mut allocator Allocator, capacity u64) !&UploadRing {
allocator: allocator
backing: backing
mapped: mapped
ranges: mem.new_ring_allocator(capacity)
ranges: memory.new_ring_allocator(capacity)
}
}

Expand Down
8 changes: 4 additions & 4 deletions upload_ring_test.v
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module vkmemalloc

import antono2.mem
import antono2.memory

fn test_upload_ring_returns_aligned_host_pointers_and_wraps() {
mut storage := []u8{len: 64}
mut uploads := UploadRing{
capacity: 64
mapped: storage.data
ranges: mem.new_ring_allocator(64)
ranges: memory.new_ring_allocator(64)
}
first := uploads.allocate(24, 16) or { panic(err) }
second := uploads.allocate(24, 16) or { panic(err) }
Expand Down Expand Up @@ -37,12 +37,12 @@ fn test_upload_ring_rejects_foreign_forged_and_destroyed_slices() {
mut first_ring := UploadRing{
capacity: 32
mapped: first_storage.data
ranges: mem.new_ring_allocator(32)
ranges: memory.new_ring_allocator(32)
}
mut second_ring := UploadRing{
capacity: 32
mapped: second_storage.data
ranges: mem.new_ring_allocator(32)
ranges: memory.new_ring_allocator(32)
}
allocation := first_ring.allocate(8, 1) or { panic(err) }
foreign := second_ring.allocate(8, 1) or { panic(err) }
Expand Down
4 changes: 2 additions & 2 deletions v.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Module {
name: 'antono2.vkmemalloc'
author: 'Anton Oreskin'
description: 'Vulkan block suballocation helpers for buffers and images'
version: '2.2.0'
version: '2.3.0'
license: 'MIT'
repo_url: 'https://github.com/antono2/vulkan_memory_allocator'
tags: ['V','vulkan','allocator']
dependencies: ['antono2.vulkan','antono2.mem@v1.0.3']
dependencies: ['antono2.vulkan','antono2.memory@v1.1.0']
}