|
1 | 1 | # Examples
|
2 | 2 |
|
3 |
| -The examples here are split into a few categories: |
4 |
| - |
5 |
| -- The shaders folder contain various rust-gpu shaders, and are examples of how to use rust-gpu. |
6 |
| -- The runners folder contains programs that build and execute the shaders in the shaders folder using, for example, |
7 |
| - Vulkan. These programs are not exactly examples of how to use rust-gpu, as they're rather generic vulkan sample apps, |
8 |
| - but they do contain some infrastructure examples of how to integrate rust-gpu shaders into a build system (although |
9 |
| - both aren't the cleanest of examples, as they're also testing some of the more convoluted ways of consuming rust-gpu). |
10 |
| -- Finally, the multibuilder folder is a very short sample app of how to use the `multimodule` feature of `spirv-builder`. |
| 3 | +This directory contains several examples of rust-gpu use. There are shader |
| 4 | +examples in `shaders`, and runner programs that build and execute the shaders |
| 5 | +in a variety of ways in `runners`. |
| 6 | + |
| 7 | +The shaders: |
| 8 | +- **sky:** draws a landscape with a small white sun, blue sky, and yellow |
| 9 | + ground. This is the default shader. |
| 10 | +- **simplest:** draws a red triangle on a green background. |
| 11 | +- **mouse:** a swirling animation that can be influenced by the mouse cursor. |
| 12 | +- **compute:** a compute shader that prints a sequence of integers from the |
| 13 | + '3x+1' problem. |
| 14 | + |
| 15 | +The runners: |
| 16 | +- **WGPU:** runs the shader code on the GPU using [wgpu](https://wgpu.rs), a |
| 17 | + graphics crate based on WebGPU. |
| 18 | +- **ash:** runs the shader code on the GPU using |
| 19 | + [ash](https://crates.io/crates/ash), a Vulkan wrapper crate for Rust. |
| 20 | +- **CPU:** runs the shader code directly on the CPU. |
| 21 | + |
| 22 | +Not all shaders work with all runners. The following combinations are |
| 23 | +supported. |
| 24 | + |
| 25 | +- WGPU runner: |
| 26 | + - `cargo run --bin example-runner-wgpu` runs the sky shader. |
| 27 | + - `cargo run --bin example-runner-wgpu -- --shader=sky` also runs the sky |
| 28 | + shader. |
| 29 | + - `cargo run --bin example-runner-wgpu -- --shader=simplest` runs the |
| 30 | + simplest shader. |
| 31 | + - `cargo run --bin example-runner-wgpu -- --shader=mouse` runs the mouse |
| 32 | + shader. |
| 33 | + - `cargo run --bin example-runner-wgpu -- --shader=compute` runs the compute |
| 34 | + shader. |
| 35 | + |
| 36 | +- ash runner: |
| 37 | + - `cargo run --bin example-runner-ash` runs the sky shader. Use the up and |
| 38 | + down arrows to adjust the sun's intensity. Use F5 to recompile the shader |
| 39 | + code (but note that the image won't redraw afterwards unless the intensity is |
| 40 | + adjusted). |
| 41 | + |
| 42 | +- CPU runner: |
| 43 | + - `cargo run --bin example-runner-cpu` runs the sky shader. |
| 44 | + |
| 45 | +Finally, the `multibuilder` folder is a very short example of how to use the |
| 46 | +`multimodule` feature of `spirv-builder`. |
0 commit comments