DeviceOptions
Type in Runtime
How createDevice() opens a device.
import type { DeviceOptions } from 'typeshade'import type { DeviceOptions } from 'typeshade/runtime'
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
type DeviceOptions = { /** WebGPU limits required by this owner, independent of configure(). Requested devices * negotiate them with their adapter; supplied devices and runtimes must already enable them. * WebGL2 and CPU fallbacks have no WebGPU limits. */ readonly limits?: Readonly<Record<string, number>>; /** WebGPU features required by this owner, independent of configure(). Supplied devices * and runtimes must already enable them. Unsupported requirements skip WebGPU when the * owner's preference permits another tier. */ readonly features?: readonly string[]; /** The most bytes of released arrays the device keeps for a later `array()` of the same * element and length. 64 MiB by default. `0` keeps none. */ readonly poolBytes?: number; /** The flavor setting of the emulated double (change 0085). Omission or `'auto'` selects * `'integer'` from Apple or Metal signals on the actual device, otherwise `'float'`; CPU * selects `'float'`. Explicit `'float'` and `'integer'` override selection. Unknown GPU * signals retain the selector's float fallback, without establishing hardware precision. A kernel * call, an entry call and a `fuse()` plan of the device dispatch the WGSL of that flavor for a * module that emulates `f64`, the `_fp64` guard bound under `'float'` and absent under * `'integer'`. A module that emulates no `f64` is unchanged. */ readonly fp64Flavor?: 'auto' | Fp64Flavor; /** Whether a kernel call of the device dispatches the subgroup variant of a function's WGSL * (change 0119, Rule 11.23). `'auto'`, the default, runs the subgroup probe when a WebGPU device that has * the `subgroups` feature opens, and dispatches the variant where the probe passed; * `info.subgroups` holds what it saw. `'off'` runs no probe and keeps every call on the * tree, for a measurement of the two texts on one device. There is no `'on'`: a device * without the feature cannot compile the variant. */ readonly subgroups?: 'auto' | 'off'; /** The time one chunk of a long kernel may take, in milliseconds (change 0074): 250 by default. * `device.chunkSize()` sizes each chunk of a key to fit eight tenths of it. A value that is not * a finite number from 1 to 60000 is a `RangeError`. */ readonly timeBudgetMs?: number;} & ( | { /** The tiers to try, in order, `['webgpu', 'webgl2', 'cpu']` by default. One tier makes it * required. Tiers after the one that opens stay a call's fallback (Rule 11.8). */ readonly prefer?: readonly Tier[]; readonly device?: never; readonly runtime?: never; } | { /** A `GPUDevice` the host already has. The device uses it and never destroys it. */ readonly device: object; readonly prefer?: never; readonly runtime?: never; } | { /** A program runtime of `createRuntime()` whose device the owner never destroys. * A WebGL2 runtime is refused: calls use a context of their own there (Rule 11.11). */ readonly runtime: { readonly device: object; readonly tier?: string }; readonly prefer?: never; readonly device?: never; });Description
prefer, device and runtime are exclusive in
TypeScript and at runtime (change 0085). Compose extra options with an intersection,
DeviceOptions & { label?: string }; an interface cannot extend this union.
Source
src/runtime/device.ts, line 56, at commit af54ddad5