Skip to main content

rightkit_gpu/
lib.rs

1//! Shared wgpu device context for Right Suite apps (#1159): per-OS backend policy, a crash
2//! sentinel around device creation, adapter pick and limits, an exit gate for in-flight GPU work,
3//! and a device-memory budget that adapts to out-of-memory. Native only; the apps' kernels stay in
4//! the apps.
5//!
6//! * [`backend`]: which backends wgpu may load (Windows DX12 alone, Metal on Apple, Vulkan
7//!   elsewhere, overridable by the app's own environment variable) and the crash sentinel
8//!   ([`backend::set_init_marker`], [`backend::take_init_marker`]) that lets the next launch know a
9//!   driver killed the last one during device creation.
10//! * [`GpuContext::create`]: adapter by name or default, software adapters refused, limits, error
11//!   and device-loss callbacks.
12//! * [`exit`]: every entry into the device goes through [`exit::enter`]; the host ends the process
13//!   with [`exit::begin_shutdown`] and [`exit::wait_idle`].
14//! * [`MemoryBudget`]: renders ask for room, wait fairly, halve the budget on out-of-memory and
15//!   grow it back with each success.
16//!
17//! wgpu is pinned at 30 here (the version Ember builds on, and `rightkit-compositor`'s). CutRight
18//! moves from 29.0.1 to 30 to use this crate; the crate does not carry both.
19//!
20//! Adapted from Ember `crates/gpu` (`backend.rs`, `exit.rs`, `budget.rs`, the generic part of
21//! `ctx.rs`); see NOTICE.
22
23#![cfg(not(target_arch = "wasm32"))]
24
25pub mod backend;
26mod budget;
27mod context;
28pub mod exit;
29
30pub use budget::{MemoryBudget, Permit, footprint, initial};
31pub use context::{
32    ContextOptions, GpuContext, LimitsCap, adapter_names, parse_limits_cap, pick_adapter,
33};
34pub use wgpu;