zust-vm-spirv 0.9.3

SPIR-V code generation backend for the Zust scripting language.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use anyhow::Result;
use std::fs;
use vm_spirv::compile_source_with_workgroup_size;

fn main() -> Result<()> {
    let source = fs::read_to_string("zusts/gpu/pathfind.zs")?;
    let kernel = compile_source_with_workgroup_size(&source, "pathfind", "main", [32, 32, 1])?;
    let words = kernel.spirv.words();
    let bytes: Vec<u8> = words.iter().flat_map(|w| w.to_le_bytes()).collect();
    fs::write("pathfind.spv", &bytes)?;
    println!("compiled pathfind.zs -> pathfind.spv ({} words, {} bytes)", words.len(), bytes.len());
    Ok(())
}