Expand description
Keep your WGSL in Rust.
This crate answers the following questions:
- How do I write shaders?
- By writing Rust code in a module annotated by the
#[wgsl_rs]macro. - It looks like this https://renderling.xyz/wgsl-rs/manual/examples/hello-triangle.html#rust-source.
- How do I package my shaders?
- They are already packaged in that same module, automatically. No need to deal with shader source files. Instead, you access the module at runtime.
- How do I run my shaders?
- That’s still up to you, but if your runtime is
wgpu, then with thelinkage-wgpufeature provided by this crate you can avoid a lot of boiler plate by having your linkage auto-generated.
For more info see the Operator’s Manual.
Re-exports§
pub use extension::WgslExtension;pub use extension::any_ext_claims;pub use extension::contains_str;pub use source_error::SourceError;pub use wgsl_rs_ir as ir;
Modules§
- extension
- Extension trait for downstream crates to modify WGSL IR after transpilation but before rendering/instantiation.
- linkage
- Linkage machinery for
wgsl-rs. - source_
error - Errors produced by
Source-level operations. - std
- The WGSL standard library, for Rust.
Macros§
- discard
- Marks the current fragment invocation as discarded.
- get
- Provides access to a storage, uniform, or workgroup variable.
- get_mut
- Provides mutable access to a storage or workgroup variable.
- load
- Copies the value of a uniform, storage, or workgroup variable into a local.
- slab_
copy - Copy
$sizeelements from$srcstarting at$src_offsetinto$deststarting at$dest_offset.
Structs§
- Generic
Template - A generic function (or struct) template defined within a module.
- Source
- A WGSL source.
- Template
Dependency - A transitive dependency from one generic template to another.
- Template
Instantiation - A request to instantiate a generic template with concrete types.
Functions§
- validate_
wgsl_ source - Validates arbitrary WGSL source text using naga.
Attribute Macros§
- wgsl
- Transpiles a Rust module to WGSL.
- wgsl_
allow - Suppresses specific wgsl-rs warnings/errors on annotated statements.
- wgsl_
ignore - Ignores any item following the attribute during parsing, skipping WGSL code generation.