From d93b80719d95d785e806703c6b390cbddb1509ff Mon Sep 17 00:00:00 2001 From: antono2 Date: Sat, 12 Sep 2026 11:21:23 +0200 Subject: [PATCH 1/3] Add one-command Vulkan allocator setup --- .github/workflows/test.yml | 2 +- README.md | 9 +++++++ setup.vsh | 52 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 setup.vsh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 724f743..14072d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: run: v vet block_pool.v block_pool_test.v upload_ring.v upload_ring_test.v vulkan_memory_allocator.v vulkan_memory_allocator_test.v - name: Run allocator tests working-directory: source/modules/antono2/vkmemalloc - run: v test . + run: v run setup.vsh --check - name: Run Vulkan suballocation smoke test working-directory: source/modules/antono2/vkmemalloc run: | diff --git a/README.md b/README.md index b777bfa..91255fa 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,15 @@ VPM installs the Vulkan bindings and `antono2.memory` dependencies automatically The Vulkan loader, headers, and a working GPU driver must also be installed. +For a fresh machine, install the native Vulkan prerequisites, V dependencies, +and run the compile checks with one command: + +```sh +v run setup.vsh +``` + +Use `v run setup.vsh --check` for a read-only diagnostic pass. + The allocator uses [`antono2.memory`](https://github.com/antono2/memory), specifically `memory.RangeAllocator`, for its dependency-free block suballocation policy. Vulkan handles remain diff --git a/setup.vsh b/setup.vsh new file mode 100644 index 0000000..1c736ff --- /dev/null +++ b/setup.vsh @@ -0,0 +1,52 @@ +#!/usr/bin/env -S v run + +// Delegates native Vulkan preparation to antono2.vulkan, then installs and +// verifies the allocator module. + +import os + +fn run(command string) ! { + println('\n> ${command}') + result := os.execute(command) + if result.output.trim_space() != '' { + println(result.output.trim_right('\r\n')) + } + if result.exit_code != 0 { + return error('command failed with exit code ${result.exit_code}') + } +} + +fn main() { + if os.args.len > 2 || (os.args.len == 2 && os.args[1] !in ['--install', '--check', '-h', '--help']) { + eprintln('Usage: v run setup.vsh [--install|--check]') + exit(2) + } + if os.args.len == 2 && os.args[1] in ['-h', '--help'] { + println('Usage: v run setup.vsh [--install|--check]\n\nDefault: install native Vulkan prerequisites and V modules.\n--check: perform read-only prerequisite and compile checks.') + return + } + install := os.args.len == 1 || os.args[1] == '--install' + if install { + run('v install antono2.vulkan') or { panic(err) } + } + vulkan_setup := os.join_path(os.vmodules_dir(), 'antono2', 'vulkan', 'setup.vsh') + if !os.is_file(vulkan_setup) { + eprintln('antono2.vulkan does not include setup.vsh; update it with `v update antono2.vulkan`') + exit(1) + } + mode := if install { '--install' } else { '--check' } + run('v run ${os.quoted_path(vulkan_setup)} ${mode}') or { panic(err) } + $if windows { + vulkan_sdk := os.execute('powershell -NoProfile -Command "[Environment]::GetEnvironmentVariable(\'VULKAN_SDK\', \'Machine\')"') + if vulkan_sdk.exit_code == 0 && vulkan_sdk.output.trim_space() != '' { + os.setenv('VULKAN_SDK', vulkan_sdk.output.trim_space(), true) + } + } + if install { + run('v install antono2.memory') or { panic(err) } + run('v install antono2.vkmemalloc') or { panic(err) } + } + project_dir := os.dir(os.real_path(@FILE)) + run('v test ${os.quoted_path(project_dir)}') or { panic(err) } + println('\nVulkan allocator prerequisites and compile checks are ready.') +} From 075aa3ff10a3c737543336d9441e4df0d5d71179 Mon Sep 17 00:00:00 2001 From: antono2 Date: Sat, 12 Sep 2026 11:23:08 +0200 Subject: [PATCH 2/3] Keep setup compatible with stable V formatting --- setup.vsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.vsh b/setup.vsh index 1c736ff..b1b8a07 100644 --- a/setup.vsh +++ b/setup.vsh @@ -37,7 +37,9 @@ fn main() { mode := if install { '--install' } else { '--check' } run('v run ${os.quoted_path(vulkan_setup)} ${mode}') or { panic(err) } $if windows { - vulkan_sdk := os.execute('powershell -NoProfile -Command "[Environment]::GetEnvironmentVariable(\'VULKAN_SDK\', \'Machine\')"') + vulkan_sdk := os.execute( + 'powershell -NoProfile -Command "[Environment]::GetEnvironmentVariable(\'VULKAN_SDK\', \'Machine\')"', + ) if vulkan_sdk.exit_code == 0 && vulkan_sdk.output.trim_space() != '' { os.setenv('VULKAN_SDK', vulkan_sdk.output.trim_space(), true) } From 2665e484ecfb826a670b68fe36ebd3acda55b555 Mon Sep 17 00:00:00 2001 From: antono2 Date: Sat, 12 Sep 2026 11:27:08 +0200 Subject: [PATCH 3/3] Format setup with supported V release --- setup.vsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/setup.vsh b/setup.vsh index b1b8a07..edf56df 100644 --- a/setup.vsh +++ b/setup.vsh @@ -2,7 +2,6 @@ // Delegates native Vulkan preparation to antono2.vulkan, then installs and // verifies the allocator module. - import os fn run(command string) ! { @@ -17,7 +16,8 @@ fn run(command string) ! { } fn main() { - if os.args.len > 2 || (os.args.len == 2 && os.args[1] !in ['--install', '--check', '-h', '--help']) { + if os.args.len > 2 + || (os.args.len == 2 && os.args[1] !in ['--install', '--check', '-h', '--help']) { eprintln('Usage: v run setup.vsh [--install|--check]') exit(2) } @@ -37,9 +37,8 @@ fn main() { mode := if install { '--install' } else { '--check' } run('v run ${os.quoted_path(vulkan_setup)} ${mode}') or { panic(err) } $if windows { - vulkan_sdk := os.execute( - 'powershell -NoProfile -Command "[Environment]::GetEnvironmentVariable(\'VULKAN_SDK\', \'Machine\')"', - ) + vulkan_sdk := + os.execute('powershell -NoProfile -Command "[Environment]::GetEnvironmentVariable(\'VULKAN_SDK\', \'Machine\')"') if vulkan_sdk.exit_code == 0 && vulkan_sdk.output.trim_space() != '' { os.setenv('VULKAN_SDK', vulkan_sdk.output.trim_space(), true) }