Skip to main content

Module gpu

Module gpu 

Source
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::new needs beyond the window handle.

Enums§

CopySrc
How badly the caller needs COPY_SRC on the surface texture.
FrameAcquire
Result of Gpu::try_acquire_frame.
GpuInitError
Why Gpu::new could not produce a usable surface.
RetryWake
When the caller should try Gpu::try_acquire_frame again after a FrameAcquire::Skip.
SurfaceAcquire
How to handle the result of Surface::get_current_texture.
SurfaceError
Why Gpu::try_acquire_frame could 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).