$ spirv

v0.4.0+sdk-1.4.341.0MAJOR UPDATE

Rust definition of SPIR-V structs and enums

Downloads: 15.1M
Recent: 3.1M
Versions: 5
Updated: March 13, 2026

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\;");
}

Linkshttps://crates.io/crates/rspirvhttps://docs.rs/rspirvhttps://crates.io/crates/spirvhttps://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

10.5M15.1M

$ VERSION HISTORY

v0.4.0+sdk-1.4.341.0March 13, 2026
v0.3.0+sdk-1.3.268.0December 20, 2023

$ LINKS

$ INSTALL

cargo add spirv

Or add to Cargo.toml: spirv = "0.4.0+sdk-1.4.341.0"