Crate spirvcross

source ·
Expand description

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.

Modules

  • Implementations for the various supported compilers.
  • Raw bindings to the C API.

Structs

  • Manager of SPIRV-Cross resources
  • A SPIRV-Cross API error, alongside it’s error message.

Constants

  • Semantic version of the underlying SPIRV-Cross API

Traits

  • A SPIRV-Cross compiler to an unkown target.

Functions

  • Converts a byte slice into a word slice, avoiding a new allocation if possible.

Type Aliases