msiglreith / spirv_cross

Safe Rust wrapper around SPIRV-Cross

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spirv_cross

Safe wrapper around SPIR-V Cross

Crate Travis Build Status Appveyor Build Status

Example

spirv_cross provides a safe wrapper around SPIRV-Cross for use with Rust. For example, here is a simple function to parse a SPIR-V module and compile it to HLSL and MSL:

extern crate spirv_cross;
use spirv_cross::{spirv, hlsl, msl};

fn example(module: spirv::Module) {
    // Parse a SPIR-V module
    let parsed_module = spirv::Parser::new()
        .parse(&module, &spirv::ParserOptions::default())
        .unwrap();

    // Compile to HLSL
    let hlsl = hlsl::Compiler::new()
        .compile(&parsed_module, &hlsl::CompilerOptions::default())
        .unwrap();

    println!("{}", hlsl);

    // Compile to MSL
    let msl = msl::Compiler::new()
        .compile(&parsed_module, &msl::CompilerOptions::default())
        .unwrap();

    println!("{}", msl);
}

About

Safe Rust wrapper around SPIRV-Cross

License:Apache License 2.0


Languages

Language:Rust 92.0%Language:C++ 8.0%