Skip to content

Commit 12ee31d

Browse files
authored
Update examples readme files (#4774)
* Fix indentation in main examples readme file * Update examples readme files * Update hello_compute example readme and fix example not running with new command * Fix srgb_blend example not working correctly and set readme accordingly
1 parent 7a37229 commit 12ee31d

File tree

26 files changed

+103
-43
lines changed

26 files changed

+103
-43
lines changed

examples/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ The rest of the example are for demonstrating specific features that you can com
1919
#### Graphics
2020

2121
- `hello-triangle` - Provides an example of a bare-bones WGPU workflow using the Winit crate that simply renders a red triangle on a green background.
22-
- `uniform-values` - Demonstrates the basics of enabling shaders and the GPU in general to access app state through uniform variables. `uniform-values` also serves as an example of rudimentary app building as the app stores state and takes window-captured keyboard events. The app displays the Mandelbrot Set in grayscale (similar to `storage-texture`) but allows the user to navigate and explore it using their arrow keys and scroll wheel.
23-
- `cube` - Introduces the user to slightly more advanced models. The example creates a set of triangles to form a cube on the CPU and then uses a vertex and index buffer to send the generated model to the GPU for usage in rendering. It also uses a texture generated on the CPU to shade the sides of the cube and a uniform variable to apply a transformation matrix to the cube in the shader.
24-
- `bunnymark` - Demonstrates many things but chief among them, preforming numerous draw calls with different bind groups in one render pass. The example also uses textures for the icon and uniform buffers to transfer both global and per-particle state.
25-
- `skybox` - Shows off too many concepts to list here. The name comes from game development where a "skybox" acts as a background for rendering, usually to add a sky texture for immersion although they can also be used for backdrops to give the idea of a world beyond of the game scene. This example does so much more than this though as it uses a car model loaded from a file and uses the user's mouse to rotate the car model in 3d. `skybox` also makes use of depth textures and similar app patterns to `uniform-values`.
26-
- `shadow` - Likely by far the most complex example (certainly the largest in lines of code) of the official WGPU examples. `shadow` demonstrates basic scene rendering with the main attraction being lighting and shadows (as the name implies). It is recommended that any user looking into lighting be very familiar with the basic concepts of not only rendering with WGPU but the primary mathematical ideas of computer graphics.
22+
- `uniform-values` - Demonstrates the basics of enabling shaders and the GPU in general to access app state through uniform variables. `uniform-values` also serves as an example of rudimentary app building as the app stores state and takes window-captured keyboard events. The app displays the Mandelbrot Set in grayscale (similar to `storage-texture`) but allows the user to navigate and explore it using their arrow keys and scroll wheel.
23+
- `cube` - Introduces the user to slightly more advanced models. The example creates a set of triangles to form a cube on the CPU and then uses a vertex and index buffer to send the generated model to the GPU for usage in rendering. It also uses a texture generated on the CPU to shade the sides of the cube and a uniform variable to apply a transformation matrix to the cube in the shader.
24+
- `bunnymark` - Demonstrates many things but chief among them, preforming numerous draw calls with different bind groups in one render pass. The example also uses textures for the icon and uniform buffers to transfer both global and per-particle state.
25+
- `skybox` - Shows off too many concepts to list here. The name comes from game development where a "skybox" acts as a background for rendering, usually to add a sky texture for immersion although they can also be used for backdrops to give the idea of a world beyond of the game scene. This example does so much more than this though as it uses a car model loaded from a file and uses the user's mouse to rotate the car model in 3d. `skybox` also makes use of depth textures and similar app patterns to `uniform-values`.
26+
- `shadow` - Likely by far the most complex example (certainly the largest in lines of code) of the official WGPU examples. `shadow` demonstrates basic scene rendering with the main attraction being lighting and shadows (as the name implies). It is recommended that any user looking into lighting be very familiar with the basic concepts of not only rendering with WGPU but the primary mathematical ideas of computer graphics.
2727
- `render-to-texture` - Renders to an image texture offscreen, demonstrating both off-screen rendering as well as how to add a sort of resolution-agnostic screenshot feature to an engine. This example either outputs an image file of your naming (pass command line arguments after specifying a `--` like `cargo run --bin render-to-texture -- "test.png"`) or adds an `img` element containing the image to the page in WASM.
2828

2929
#### Compute
3030

3131
- `hello-compute` - Demonstrates the basic workflow for getting arrays of numbers to the GPU, executing a shader on them, and getting the results back. The operation it preforms is finding the Collatz value (how many iterations of the [Collatz equation](https://en.wikipedia.org/wiki/Collatz_conjecture) it takes for the number to either reach 1 or overflow) of a set of numbers and prints the results.
32-
- `repeated-compute` - Mostly for going into detail on subjects `hello-compute` did not. It, too, computes the Collatz conjecture but this time, it automatically loads large arrays of randomly generated numbers, prints them, runs them, and prints the result. It does this cycle 10 times.
33-
- `hello-workgroups` - Teaches the user about the basics of compute workgroups; what they are and what they can do.
34-
- `hello-synchronization` - Teaches the user about synchronization in WGSL, the ability to force all invocations in a workgroup to synchronize with each other before continuing via a sort of barrier.
35-
- `storage-texture` - Demonstrates the use of storage textures as outputs to compute shaders. The example on the outside seems very similar to `render-to-texture` in that it outputs an image either to the file system or the web page except displaying a grayscale render of the Mandelbrot Set. However, inside, the example dispatches a grid of compute workgroups, one for each pixel which calculates the pixel value and stores it to the corresponding pixel of the output storage texture.
32+
- `repeated-compute` - Mostly for going into detail on subjects `hello-compute` did not. It, too, computes the Collatz conjecture but this time, it automatically loads large arrays of randomly generated numbers, prints them, runs them, and prints the result. It does this cycle 10 times.
33+
- `hello-workgroups` - Teaches the user about the basics of compute workgroups; what they are and what they can do.
34+
- `hello-synchronization` - Teaches the user about synchronization in WGSL, the ability to force all invocations in a workgroup to synchronize with each other before continuing via a sort of barrier.
35+
- `storage-texture` - Demonstrates the use of storage textures as outputs to compute shaders. The example on the outside seems very similar to `render-to-texture` in that it outputs an image either to the file system or the web page except displaying a grayscale render of the Mandelbrot Set. However, inside, the example dispatches a grid of compute workgroups, one for each pixel which calculates the pixel value and stores it to the corresponding pixel of the output storage texture.
3636

3737
#### Combined
3838

examples/src/boids/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Flocking boids example with gpu compute update pass
55
## To Run
66

77
```
8-
cargo run --bin boids
8+
cargo run --bin wgpu-examples boids
99
```
1010

1111
## Screenshots

examples/src/bunnymark/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# bunnymark
2+
3+
4+
## To Run
5+
6+
```
7+
cargo run --bin wgpu-examples bunnymark
8+
```
9+
10+
## Example output
11+
12+
![Example output](./screenshot.png)

examples/src/conservative_raster/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# conservative-raster
1+
# conservative_raster
22

33
This example shows how to render with conservative rasterization (native extension with limited support).
44

@@ -12,7 +12,7 @@ Pixels only drawn with conservative rasterization enabled are depicted red.
1212
## To Run
1313

1414
```
15-
cargo run --bin conservative-raster
15+
cargo run --bin wgpu-examples conservative_raster
1616
```
1717

1818
## Screenshots

examples/src/cube/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This example renders a textured cube.
55
## To Run
66

77
```
8-
cargo run --bin cube
8+
cargo run --bin wgpu-examples cube
99
```
1010

1111
## Screenshots

examples/src/hello/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This example prints output describing the adapter in use.
55
## To Run
66

77
```
8-
cargo run --bin hello
8+
cargo run --bin wgpu-examples hello
99
```
1010

1111
## Example output

examples/src/hello_compute/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ that it will take to finish and reach the number `1`.
1212

1313
```
1414
# Pass in any 4 numbers as arguments
15-
RUST_LOG=hello_compute cargo run --bin hello-compute 1 4 3 295
15+
RUST_LOG=hello_compute cargo run --bin wgpu-examples hello_compute 1 4 3 295
1616
```
1717

1818
## Example Output

examples/src/hello_compute/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async fn run() {
1212
default
1313
} else {
1414
std::env::args()
15-
.skip(1)
15+
.skip(2)
1616
.map(|s| u32::from_str(&s).expect("You must pass a list of positive integers!"))
1717
.collect()
1818
};

examples/src/hello_synchronization/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
# hello-synchronization
1+
# hello_synchronization
22

33
This example is
44
1. A small demonstration of the importance of synchronization.
55
2. How basic synchronization you can understand from the CPU is preformed on the GPU.
66

7+
## To Run
8+
9+
```
10+
cargo run --bin wgpu-examples hello_synchronization
11+
```
12+
713
## A Primer on WGSL Synchronization Functions
814

915
The official documentation is a little scattered and sparse. The meat of the subject is found [here](https://www.w3.org/TR/2023/WD-WGSL-20230629/#sync-builtin-functions) but there's also a bit on control barriers [here](https://www.w3.org/TR/2023/WD-WGSL-20230629/#control-barrier). The most important part comes from that first link though, where the spec says "the affected memory and atomic operations program-ordered before the synchronization function must be visible to all other threads in the workgroup before any affected memory or atomic operation program-ordered after the synchronization function is executed by a member of the workgroup." And at the second, we also get "a control barrier is executed by all invocations in the same workgroup as if it were executed concurrently."

examples/src/hello_triangle/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# hello-triangle
1+
# hello_triangle
22

33
This example renders a triangle to a window.
44

55
## To Run
66

77
```
8-
cargo run --bin hello-triangle
8+
cargo run --bin wgpu-examples hello_triangle
99
```
1010

1111
## Screenshots

0 commit comments

Comments
 (0)