Expand description
§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
- Draw You a Triangle for Great Good
- Chinese version of 学习 wgpu
- GPU Architecture, a presentation by Kangz on how GPUs work under the hood.
Reference material:
- The
wgpuexamples; see Running the Examples. - The WebGPU specification, which
wgpufollows closely.
Runtimes:
- The Deno 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 RenderPipelines 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 CommandBuffers. The
TextureView on a RenderPassColorAttachment can come from a
Surface — a special target for the final output.