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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions setup.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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.')
}