3 releases

0.1.2 Dec 1, 2023
0.1.1 Jul 31, 2023
0.1.0 Jul 30, 2023

#710 in WebAssembly

MIT license

10MB
251K SLoC

GLSL 202K SLoC // 0.0% comments C++ 47K SLoC // 0.1% comments Rust 1K SLoC Python 887 SLoC // 0.0% comments C 192 SLoC Shell 91 SLoC // 0.1% comments Swift 60 SLoC // 0.1% comments Assembly 55 SLoC // 0.1% comments Just 10 SLoC AsciiDoc 6 SLoC // 0.3% comments

spirv-cross

High and low level bindigns to the SPIRV-Cross API

Example

use spirvcross::{
    bytes_to_words,
    compiler::{glsl::GlslCompiler, Compiler},
    Result,
    Context,
};

fn compile(bytes: &[u8]) -> Result<()> {
    let words = bytes_to_words(bytes).unwrap();

    let mut context = Context::new()?;
    context.set_error_callback(|err| eprintln!("{}", err.to_string_lossy()));

    let compiler = GlslCompiler::new(&mut context, &words)?
        .vulkan_semantics(true)?;

    println!("{}", compiler.compile()?);
    return Ok(());
}

Supported Targets

  • Linux
  • macOS
  • Windows
  • WebAssembly (WASI)
    • Compiling to WebAssembly from a Windows machine currently doesn't work.

Dependencies

~1.3–7.5MB
~147K SLoC