Naga to TokenStream
This library takes a Naga module and produces a proc_macro::TokenStream
giving information about the module. It is intended for use in other libraries which process a shader at compile time, for example in a proc macro or build script, to expose a large collection of useful information to the Rust compiler (and hence programmer) about items in the module.
Generated Items
As an example, take the following shader, written in wgsl:
const ELEMENTS_LENGTH: u32 = 128u;
struct Foo {
a: i32,
b: vec4<u32>,
c: vec4<u32>,
}
struct Bar {
size: u32,
elements: array<vec2<bool>, ELEMENTS_LENGTH>,
foos: array<Foo>
}
@group(0) @binding(0) var<storage> bar: Bar;
@compute
@workgroup_size(256,1,1)
fn main() {
...
}
Then this crate would generate something like the following:
/// Equivalent Rust definitions of the constants defined in this module
/// Equivalent Rust definitions of the types defined in this module
/// Information about the entry points within the module.
/// The sourcecode for the shader, as a constant string.
pub const SOURCE: &'static str = "...";