Examples on how to setup rust-gpu with various APIs, use-cases and integration paths.
Install our cargo gpu cli, if you haven't already:
cargo install cargo-gpuThen generate a rust-gpu project with:
cargo gpu generate(This subcommand is merely a wrapper around cargo-generate)
If 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.