Examples on how to setup rust-gpu with various APIs, use-cases and integration paths.
Install cargo-generate
cargo install cargo-generateor if you have no time, use cargo-binstall:
cargo binstall cargo-generateThen generate this template and answer the questions to configure it: (more details below)
cargo generate --git https://github.com/Rust-GPU/rust-gpu-templateIf you don't want to install cargo generate, you can also go to the
generated/ folder and navigate its subfolders, each level corresponding to the questions below.
- Which sub-template should be expanded?
We currently only have a "graphics" template, showcasing how to use rust-gpu for vertex and fragment shaders. More templates to come!
- What API?
You can choose between the high-level wgpu API with browser support and ash, a lightweight wrapper around the low level Vulkan API. If you're new to graphics, we recommend you start at learn wgpu, and once you have a basic triangle or compute shader working, return here.
- How to integrate rust-gpu?
cargo-gpu is a rust-gpu installation manager, which isolates the specific nightly toolchain that rust-gpu requires, thus allowing the rest of your project to remain on a stable toolchain (or any other toolchain). In addition, it is also a command line tool you can use. Whereas the "raw" spirv-builder setup requires your entire project to be compiled using the specific nightly rust-gpu toolchain. Note that cargo-gpu merely wraps spirv-builder, making it easy to switch and keep most of your configuration between both platforms.