wgsl_to_wgpu is an experimental library for generating typesafe Rust bindings from WGSL shaders to wgpu.
The write_module_file function is intended for use in build scripts. This facilitates a shader focused workflow where edits to WGSL code are automatically reflected in the corresponding Rust file. For example, changing the type of a uniform in WGSL will raise a compile error in Rust code using the generated struct to initialize the buffer.
This project currently supports a small subset of WGSL types and doesn’t enforce certain key properties such as field alignment. It’s recommended for now to only run the Rust file generation as needed and rely on WGPU’s runtime validation to fix any potential errors.
Parses the WGSL shader from
input_wgsl_path and writes the Rust file to
wgsl_include_path should be a valid path for the
include_wgsl! macro used in the output file.