1 unstable release
new 0.0.1 | Mar 27, 2025 |
---|
#4 in #shaders
87 downloads per month
8KB
92 lines
🏗️ wgsl-includes
This tiny crate is meant to solve two major pain points with naga & wgsl: no validation at compile time and no support for shader includes. Note that shaders are only included ONCE, meaning circular includes are not allowed. All shader paths must be relative to the crate root directory.
Features
- Wgsl shader includes
- Shader syntax validation
Example
my_crate/shaders/shared.wgsl
contents:
// Define shared logic in a separate wgsl shader, this file is free to include more files
const VALUE: u32 = 0;
my_crate/shaders/some_compute_shader.wgsl
contents:
// We can now include our shared logic
@include shaders/shared.wgsl
@compute
@workgroup_size(128)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
// And use the contents from `shared.wgsl`
let maths: u32 = global_id.x * VALUE;
}
On the rust side we can now include and validate our shader source code as follows:
let shader_src: &str = include_wgsl!("shaders/some_compute_shader.wgsl");
Dependencies
~6–15MB
~171K SLoC