1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*!
# Learning wgpu: Key Concepts and Resources
If you are new to `wgpu` and graphics programming, this page collects
external learning resources and a primer on the core concepts of the API.
## External resources
Learning materials:
- [Learn Wgpu tutorial](https://sotrh.github.io/learn-wgpu/)
- [Draw You a Triangle for Great Good](https://github.com/dwbrite/wgpu-rendering-project/wiki/Draw-You-a-Triangle-for-Great-Good)
- Chinese version of [学习 wgpu](https://jinleili.github.io/learn-wgpu-zh/)
- [GPU Architecture](https://docs.google.com/presentation/d/1qi2j-SZuzew7Rrf5VKEPDZAQQEitV40k9fKvwJNyicM/edit),
a presentation by Kangz on how GPUs work under the hood.
Reference material:
- The `wgpu` examples; see
[Running the Examples](crate::documentation::getting_started::running_the_examples).
- The [WebGPU specification](https://www.w3.org/TR/webgpu/), which `wgpu`
follows closely.
Runtimes:
- The [Deno](https://deno.land/) JS/TS runtime.
## Important concepts
### Device and Queue
- [`Device`]
- All resource creation.
- All of its methods take `&self` (no `&mut`!).
- [`Queue`]
- All GPU work submission.
_Typically_ both are created once on startup, one of each. A [`Device`] is
created with a set of [`Features`] and [`Limits`], which are enforced
independently of the underlying hardware's actual capabilities (e.g. texture
size and formats, number of bound resources, native extensions, …).
### Relationship of [`RenderPipeline`]s and resource binding
A slightly simplified overview of what you need to set up before rendering a
frame.
*/
/*!
- _Round boxes:_ temporary descriptor structs.
- _Cornered boxes:_ resources created from a [`Device`].
- _Bold:_ what you deal with on a per-frame basis.
Each [`BindGroupLayoutEntry`] has a (mostly) corresponding
[`BindingResource`]. Compute pipelines follow a similar pattern.
### Drawing a "frame"
A simplified overview of what you need to do to draw a frame.
*/
/*!
- _Full lines:_ needed for creation.
- _Dashed lines:_ provided as "information".
[`CommandEncoder::finish`] consumes a [`CommandEncoder`] and produces a
[`CommandBuffer`]; [`Queue::submit`] consumes [`CommandBuffer`]s. The
[`TextureView`] on a [`RenderPassColorAttachment`] can come from a
[`Surface`] — a special target for the final output.
*/
use crate::;