#spirv #cross

spv-cross

Safe wrapper around SPIRV-Cross

5 releases

0.23.5 Apr 19, 2023
0.23.4 Apr 19, 2023
0.23.3 Apr 11, 2023
0.23.2 Mar 11, 2023
0.23.1 Mar 7, 2023

#393 in Graphics APIs

Download history 11/week @ 2023-11-04 18/week @ 2023-11-11 10/week @ 2023-11-18 23/week @ 2023-11-25 16/week @ 2023-12-02 8/week @ 2023-12-09 14/week @ 2023-12-16 19/week @ 2023-12-23 6/week @ 2023-12-30 13/week @ 2024-01-06 10/week @ 2024-01-13 6/week @ 2024-01-20 15/week @ 2024-01-27 5/week @ 2024-02-03 26/week @ 2024-02-10 103/week @ 2024-02-17

151 downloads per month
Used in phobos

MIT/Apache

7.5MB
179K SLoC

GLSL 104K SLoC // 0.0% comments C++ 47K SLoC // 0.1% comments Rust 9K SLoC // 0.0% comments Forth 4K SLoC Assembly 3.5K SLoC // 0.0% comments C 3.5K SLoC // 0.0% comments ActionScript 2.5K SLoC FORTRAN Legacy 1.5K SLoC // 0.0% comments Coq 1.5K SLoC Python 883 SLoC // 0.0% comments SWIG 434 SLoC GNU Style Assembly 229 SLoC D 203 SLoC R 105 SLoC // 0.2% comments Shell 91 SLoC // 0.1% comments Scheme 90 SLoC Swift 60 SLoC // 0.1% comments AsciiDoc 6 SLoC // 0.3% comments

spirv_cross

Safe wrapper around SPIR-V Cross

Crate Travis Build Status Appveyor Build Status

Disclaimer

This is a continued version of spirv-cross with updated dependencies. MSL is currently not supported. All credit for the original version goes to Joshua Groves. If possible, I would merge the changes in this crate into the original repo (after fixing MSL).

Additional features of this fork compared to the original:

  • Acceleration structures.

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, ErrorCode};

fn example(module: spirv::Module) -> Result<(), ErrorCode> {
    // Compile to HLSL
    let ast = spirv::Ast::<hlsl::Target>::parse(&module)?;
    println!("{}", ast.compile()?);

    // Compile to MSL
    let ast = spirv::Ast::<msl::Target>::parse(&module)?;
    println!("{}", ast.compile()?);

    Ok(())
}

License

This project is licensed under either of Apache License, Version 2.0 or MIT license, at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache 2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See CONTRIBUTING.md.

Dependencies