Expand description
wgpu device + surface bundle and the surface-acquire recovery policy the platform shells share. wgpu device + surface bundle for one OS window, and the surface-acquire recovery policy that goes with it.
Every native shell needs the same thing: an instance, an adapter, a device
and queue, a non-sRGB surface format, a clamped surface configuration, and a
per-frame get_current_texture that recovers from a stale swapchain instead
of painting nothing. That was hand-rolled twice (demo-wgpu’s
native_shell and demo-native’s gpu), with the two copies disagreeing
about the Timeout case; this module is the single implementation both now
use.
Frame acquisition, and the retry of a failed Surface::configure it
drives, live in the child module gpu_acquire.rs; the pure retry policy
is crate::surface_retry.
wasm shells configure their canvas surface through the browser and never block on an adapter request, so this module is native-only.
Structs§
- Gpu
- wgpu device + surface bundle for one OS window.
- GpuConfig
- Everything
Gpu::newneeds beyond the window handle.
Enums§
- CopySrc
- How badly the caller needs
COPY_SRCon the surface texture. - Frame
Acquire - Result of
Gpu::try_acquire_frame. - GpuInit
Error - Why
Gpu::newcould not produce a usable surface. - Retry
Wake - When the caller should try
Gpu::try_acquire_frameagain after aFrameAcquire::Skip. - Surface
Acquire - How to handle the result of
Surface::get_current_texture. - Surface
Error - Why
Gpu::try_acquire_framecould not produce frames any more.
Functions§
- clamp_
surface_ size - Clamp a surface configuration size to
[1, max_dim]on both axes. - pick_
present_ mode - Pick the present mode to configure the swap chain with.
- surface_
acquire_ action - Decide how to handle a surface-acquire status. A pure function so the recovery policy is unit-testable without a live GPU surface (the no-payload variants are constructible in tests).