Crate naga_rust_embed

Source
Expand description

Translates WGSL shader code to Rust embedded in your crate via macros.

This does not necessarily mean you can run your compute or render pipelines in Rust on your CPU unchanged; this is not a full “software renderer”. Rather, the primary goal of the library is to allow you to share simple functions between CPU and GPU code, so that the two parts of your code can agree on definitions.

If you need additional control over the translation or to use a different source language, use the naga_rust_back library directly instead.

§Example

naga_rust_embed::wgsl!(r"
    fn add_one(x: i32) -> i32 {
        return x + 1;
    }
");

assert_eq!(add_one(10), 11);

This library is in an early stage of development and many features do not work yet. Expect compilation failures and to have to tweak your code to fit. Broadly, simple mathematical functions will work, and bindings, textures, atomics, derivatives, and workgroup operations will not.

Re-exports§

pub use naga_rust_rt as rt;

Macros§

include_wgsl_mr
Takes the pathname of a WGSL source file, as a string literal, and embeds its Rust translation.
wgsl
Converts the provided WGSL string literal to Rust.