$ spirv
v0.4.0+sdk-1.4.341.0MAJOR UPDATERust definition of SPIR-V structs and enums
Latest Update Summary
Crate
Name: spirv New version: 0.4.0+sdk-1.4.341.0 Release date: 2026-03-13T15:38:20.118579Z
Crate readme
Short description Rust implementation of SPIR-V module processing functionalities.
Long description rspirv provides APIs for processing SPIR-V modules and command line tools for common processing tasks. It defines a common SPIR-V data representation and provides a builder to create SPIR-V modules and a parser to convert SPIR-V binaries into a structured representation. The current implementation supports SPIR-V 1.5, and its features include SPIR-V header parsing, grammar validation, and various utilities for building and disassembling SPIR-V modules.
Features • SPIR-V module builder • SPIR-V binary module parser • SPIR-V header and grammar support • Data representation of SPIR-V modules • Command line tools for SPIR-V processing
Code Examples Building and parsing a SPIR-V module
use rspirv::binary::Assemble;
use rspirv::binary::Disassemble;
fn main() {
// Building
let mut b = rspirv::dr::Builder::new();
b.set_version(1, 0);
b.capability(spirv::Capability::Shader);
b.memory_model(spirv::AddressingModel::Logical, spirv::MemoryModel::GLSL450);
let void = b.type_void();
let voidf = b.type_function(void, vec![]);
let fun = b.begin_function(void, None, spirv::FunctionControl::DONT_INLINE | spirv::FunctionControl::CONST, voidf).unwrap();
b.begin_basic_block(None).unwrap();
b.ret().unwrap();
b.end_function().unwrap();
b.entry_point(spirv::ExecutionModel::Vertex, fun, "foo", vec![]);
let module = b.module();
// Assembling
let code = module.assemble();
assert!(code.len() > 20); // Module header contains 5 words
assert_eq!(spirv::MAGIC_NUMBER, code[0]);
// Parsing
let mut loader = rspirv::dr::Loader::new();
rspirv::binary::parse_words(&code, &mut loader).unwrap();
let module = loader.module();
// Disassembling
assert_eq!(module.disassemble(), "; SPIR-V\n\;");
}
Links • https://crates.io/crates/rspirv • https://docs.rs/rspirv • https://crates.io/crates/spirv • https://docs.rs/spirv
https://docs.rs/spirv https://api.github.com/repos/gfx-rs/rspirv/releases/52309737
Release info
Release version:
Release description
Code Examples
Minor update: 0.3.0+sdk-1.3.268.0 → 0.4.0+sdk-1.4.341.0
$ DOWNLOADS TREND
$ VERSION HISTORY
$ LINKS
$ INSTALL
cargo add spirvOr add to Cargo.toml: spirv = "0.4.0+sdk-1.4.341.0"