mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
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
This commit is contained in:
parent
7a37229630
commit
12ee31d6f9
@ -5,7 +5,7 @@ Flocking boids example with gpu compute update pass
|
|||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin boids
|
cargo run --bin wgpu-examples boids
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
12
examples/src/bunnymark/README.md
Normal file
12
examples/src/bunnymark/README.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# bunnymark
|
||||||
|
|
||||||
|
|
||||||
|
## To Run
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run --bin wgpu-examples bunnymark
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example output
|
||||||
|
|
||||||
|

|
||||||
@ -1,4 +1,4 @@
|
|||||||
# conservative-raster
|
# conservative_raster
|
||||||
|
|
||||||
This example shows how to render with conservative rasterization (native extension with limited support).
|
This example shows how to render with conservative rasterization (native extension with limited support).
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ Pixels only drawn with conservative rasterization enabled are depicted red.
|
|||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin conservative-raster
|
cargo run --bin wgpu-examples conservative_raster
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -5,7 +5,7 @@ This example renders a textured cube.
|
|||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin cube
|
cargo run --bin wgpu-examples cube
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -5,7 +5,7 @@ This example prints output describing the adapter in use.
|
|||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin hello
|
cargo run --bin wgpu-examples hello
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example output
|
## Example output
|
||||||
|
|||||||
@ -12,7 +12,7 @@ that it will take to finish and reach the number `1`.
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Pass in any 4 numbers as arguments
|
# Pass in any 4 numbers as arguments
|
||||||
RUST_LOG=hello_compute cargo run --bin hello-compute 1 4 3 295
|
RUST_LOG=hello_compute cargo run --bin wgpu-examples hello_compute 1 4 3 295
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example Output
|
## Example Output
|
||||||
|
|||||||
@ -12,7 +12,7 @@ async fn run() {
|
|||||||
default
|
default
|
||||||
} else {
|
} else {
|
||||||
std::env::args()
|
std::env::args()
|
||||||
.skip(1)
|
.skip(2)
|
||||||
.map(|s| u32::from_str(&s).expect("You must pass a list of positive integers!"))
|
.map(|s| u32::from_str(&s).expect("You must pass a list of positive integers!"))
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,9 +1,15 @@
|
|||||||
# hello-synchronization
|
# hello_synchronization
|
||||||
|
|
||||||
This example is
|
This example is
|
||||||
1. A small demonstration of the importance of synchronization.
|
1. A small demonstration of the importance of synchronization.
|
||||||
2. How basic synchronization you can understand from the CPU is preformed on the GPU.
|
2. How basic synchronization you can understand from the CPU is preformed on the GPU.
|
||||||
|
|
||||||
|
## To Run
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run --bin wgpu-examples hello_synchronization
|
||||||
|
```
|
||||||
|
|
||||||
## A Primer on WGSL Synchronization Functions
|
## A Primer on WGSL Synchronization Functions
|
||||||
|
|
||||||
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."
|
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."
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
# hello-triangle
|
# hello_triangle
|
||||||
|
|
||||||
This example renders a triangle to a window.
|
This example renders a triangle to a window.
|
||||||
|
|
||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin hello-triangle
|
cargo run --bin wgpu-examples hello_triangle
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
# hello-windows
|
# hello_windows
|
||||||
|
|
||||||
This example renders a set of 16 windows, with a differently colored background
|
This example renders a set of 16 windows, with a differently colored background
|
||||||
|
|
||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin hello-windows
|
cargo run --bin wgpu-examples hello_windows
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# hello-workgroups
|
# hello_workgroups
|
||||||
|
|
||||||
Now you finally know what that silly little `@workgroup_size(1)` means!
|
Now you finally know what that silly little `@workgroup_size(1)` means!
|
||||||
|
|
||||||
@ -6,6 +6,12 @@ This example is an extremely bare-bones and arguably somewhat unreasonable demon
|
|||||||
|
|
||||||
The example starts with two arrays of numbers. One where `a[i] = i` and the other where `b[i] = 2i`. Both are bound to the shader. The program dispatches a workgroup for each index, each workgroup representing both elements at that index in both arrays. Each invocation in each workgroup works on its respective array and adds 1 to the element there.
|
The example starts with two arrays of numbers. One where `a[i] = i` and the other where `b[i] = 2i`. Both are bound to the shader. The program dispatches a workgroup for each index, each workgroup representing both elements at that index in both arrays. Each invocation in each workgroup works on its respective array and adds 1 to the element there.
|
||||||
|
|
||||||
|
## To Run
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run --bin wgpu-examples hello_workgroups
|
||||||
|
```
|
||||||
|
|
||||||
## What are Workgroups?
|
## What are Workgroups?
|
||||||
|
|
||||||
### TLDR / Key Takeaways
|
### TLDR / Key Takeaways
|
||||||
|
|||||||
@ -5,7 +5,7 @@ This example shows how to generate and make use of mipmaps.
|
|||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin mipmap
|
cargo run --bin wgpu-examples mipmap
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
# msaa-line
|
# msaa_line
|
||||||
|
|
||||||
This example shows how to render lines using MSAA.
|
This example shows how to render lines using MSAA.
|
||||||
|
|
||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin msaa-line
|
cargo run --bin wgpu-examples msaa_line
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
# render-to-texture
|
# render_to_texture
|
||||||
|
|
||||||
Similar to hello-triangle but instead of rendering to a window or canvas, renders to a texture that is then output as an image like the storage-texture example.
|
Similar to hello-triangle but instead of rendering to a window or canvas, renders to a texture that is then output as an image like the storage-texture example.
|
||||||
|
|
||||||
If all goes well, the end result should look familiarly like hello-triangle with its red triangle on a green background.
|
If all goes well, the end result should look familiarly like hello-triangle with its red triangle on a green background.
|
||||||
|
|
||||||
|
## To Run
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run --bin wgpu-examples render_to_texture
|
||||||
|
```
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
# repeated-compute
|
# repeated_compute
|
||||||
|
|
||||||
Repeatedly performs the Collatz calculation used in `hello-compute` on sets of random numbers.
|
Repeatedly performs the Collatz calculation used in `hello-compute` on sets of random numbers.
|
||||||
|
|
||||||
|
## To Run
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run --bin wgpu-examples repeated_compute
|
||||||
|
```
|
||||||
|
|
||||||
## Sample
|
## Sample
|
||||||
|
|
||||||
Randomly generated input:
|
Randomly generated input:
|
||||||
|
|||||||
@ -5,7 +5,7 @@ This animated example demonstrates shadow mapping.
|
|||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin shadow
|
cargo run --bin wgpu-examples shadow
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -6,7 +6,7 @@ It hooks up `winit` mouse controls for camera rotation around the model at the c
|
|||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin skybox
|
cargo run --bin wgpu-examples skybox
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
# cube
|
# srgb_blend
|
||||||
|
|
||||||
This example shows blending in sRGB or linear space.
|
This example shows blending in sRGB or linear space.
|
||||||
|
|
||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin cube -- linear
|
cargo run --bin wgpu-examples srgb_blend linear
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin cube
|
cargo run --bin wgpu-examples srgb_blend
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
Blending in linear space:
|
Blending in linear space:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Blending in sRGB space:
|
Blending in sRGB space:
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@ -214,7 +214,7 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut args = std::env::args();
|
let mut args = std::env::args();
|
||||||
args.next();
|
args.next();
|
||||||
if Some("linear") == args.next().as_deref() {
|
if Some("linear") == args.nth(1).as_deref() {
|
||||||
crate::framework::run::<Example<false>>("srgb-blend-linear");
|
crate::framework::run::<Example<false>>("srgb-blend-linear");
|
||||||
} else {
|
} else {
|
||||||
crate::framework::run::<Example<true>>("srgb-blend-srg");
|
crate::framework::run::<Example<true>>("srgb-blend-srg");
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# hello-triangle
|
# stencil_triangles
|
||||||
|
|
||||||
This example renders two different sized triangles to display three same sized triangles,
|
This example renders two different sized triangles to display three same sized triangles,
|
||||||
by demonstrating the use of stencil buffers.
|
by demonstrating the use of stencil buffers.
|
||||||
@ -10,7 +10,7 @@ Then, it draws a larger "outer" triangle which only touches pixels where the ste
|
|||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin stencil-triangles
|
cargo run --bin wgpu-examples stencil_triangles
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@ -1,7 +1,14 @@
|
|||||||
# storage-texture
|
# storage_texture
|
||||||
|
|
||||||
A simple example that uses a storage texture to compute an image of the Mandelbrot set (https://en.wikipedia.org/wiki/Mandelbrot_set) and either saves it as an image or presents it to the browser screen in such a way that it can be saved as an image.
|
A simple example that uses a storage texture to compute an image of the Mandelbrot set (https://en.wikipedia.org/wiki/Mandelbrot_set) and either saves it as an image or presents it to the browser screen in such a way that it can be saved as an image.
|
||||||
|
|
||||||
|
## To Run
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run --bin wgpu-examples storage_texture
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Example Output
|
## Example Output
|
||||||
|
|
||||||

|

|
||||||
11
examples/src/texture_arrays/README.md
Normal file
11
examples/src/texture_arrays/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# texture_arrays
|
||||||
|
|
||||||
|
## To Run
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run --bin wgpu-examples texture_arrays
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example Output
|
||||||
|
|
||||||
|

|
||||||
@ -1,9 +1,9 @@
|
|||||||
# timestamp-queries
|
# timestamp_queries
|
||||||
|
|
||||||
This example shows various ways of querying time when supported.
|
This example shows various ways of querying time when supported.
|
||||||
|
|
||||||
## To Run
|
## To Run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin timestamp-queries
|
cargo run --bin wgpu-examples timestamp_queries
|
||||||
```
|
```
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
# uniform-values
|
# uniform_values
|
||||||
|
|
||||||
Creates a window which displays a grayscale render of the [Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set). Pressing the arrow keys will translate the set and scrolling the mouse wheel will zoom in and out. If the image appears too 'bright', it may be because you are using too few iterations or 'samples'. Use U and D to increase or decrease respectively the max number of iterations used. Make sure to play around with this too to get an optimally photogenic screen cap. The window can be resized and pressing ESC will close the window. Explore the Mandelbrot set using the power of uniform variables to transfer state from the main program to the shader!
|
Creates a window which displays a grayscale render of the [Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set). Pressing the arrow keys will translate the set and scrolling the mouse wheel will zoom in and out. If the image appears too 'bright', it may be because you are using too few iterations or 'samples'. Use U and D to increase or decrease respectively the max number of iterations used. Make sure to play around with this too to get an optimally photogenic screen cap. The window can be resized and pressing ESC will close the window. Explore the Mandelbrot set using the power of uniform variables to transfer state from the main program to the shader!
|
||||||
|
|
||||||
|
## To Run
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run --bin wgpu-examples uniform_values
|
||||||
|
```
|
||||||
|
|
||||||
## Usage of Uniform Buffers / Variables
|
## Usage of Uniform Buffers / Variables
|
||||||
|
|
||||||
Since the codebase of this example is so large (because why not demonstrate with a sort-of game) and the points of interest in terms of the actual point of the example so small, there is a module doc comment at the top of main.rs that points out the important points of the usage of uniform values.
|
Since the codebase of this example is so large (because why not demonstrate with a sort-of game) and the points of interest in terms of the actual point of the example so small, there is a module doc comment at the top of main.rs that points out the important points of the usage of uniform values.
|
||||||
|
|||||||
@ -19,7 +19,7 @@ water
|
|||||||
## To run
|
## To run
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo run --bin water
|
cargo run --bin wgpu-examples water
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshot
|
## Screenshot
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user