Expand description
Shared wgpu device context for Right Suite apps (#1159): per-OS backend policy, a crash sentinel around device creation, adapter pick and limits, an exit gate for in-flight GPU work, and a device-memory budget that adapts to out-of-memory. Native only; the apps’ kernels stay in the apps.
backend: which backends wgpu may load (Windows DX12 alone, Metal on Apple, Vulkan elsewhere, overridable by the app’s own environment variable) and the crash sentinel (backend::set_init_marker,backend::take_init_marker) that lets the next launch know a driver killed the last one during device creation.GpuContext::create: adapter by name or default, software adapters refused, limits, error and device-loss callbacks.exit: every entry into the device goes throughexit::enter; the host ends the process withexit::begin_shutdownandexit::wait_idle.MemoryBudget: renders ask for room, wait fairly, halve the budget on out-of-memory and grow it back with each success.
wgpu is pinned at 30 here (the version Ember builds on, and rightkit-compositor’s). CutRight
moves from 29.0.1 to 30 to use this crate; the crate does not carry both.
Adapted from Ember crates/gpu (backend.rs, exit.rs, budget.rs, the generic part of
ctx.rs); see NOTICE.
Re-exports§
pub use wgpu;
Modules§
- backend
- Which wgpu backends an app lets wgpu use, for its compute device and for its window, and the
crash sentinel around device creation (issue #136). Adapted from Ember
crates/gpu. - exit
- Leaving: no GPU work may be in flight when the process ends (issue #620). Adapted from Ember
crates/gpu.
Structs§
- Context
Options - How the app wants the device made.
- GpuContext
- A wgpu device and queue on a chosen adapter.
- Limits
Cap - An upper bound on the device’s limits.
- Memory
Budget - Permit
- Room on the device for one render, released when dropped.
Functions§
- adapter_
names - The names of the usable adapters for
backends. Loads the drivers; the device is not created. - footprint
- Device memory a render is expected to hold: the source, two working copies and the output, as float RGBA, at the source’s size.
- initial
- Where the budget starts: 1.5 × the largest buffer the device allows (about the device’s memory on small cards), at least 1 GiB.
- parse_
limits_ cap - Parses a limits cap the way Ember’s
LIGHTCRAFT_GPU_LIMITSdoes:webgpu/downlevel/default= the WebGPU defaults (128 MiB storage bindings, 256 MiB buffers),<n>(or<n>MiB,<n>MB) = n MiB storage bindings and 2n MiB buffers. Empty or unparsable:None. - pick_
adapter - The index of the adapter called
wantedinnames(the first with that name), orNonewhen there is none, so the default choice is used.