DeviceOptions
타입, 런타임 분류
createDevice()가 디바이스를 여는 방식입니다.
import type { DeviceOptions } from 'typeshade'import type { DeviceOptions } from 'typeshade/runtime'
설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.
구문
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; });설명
prefer, device, runtime은 TypeScript 타입과 런타임에서 모두 상호 배타적입니다(변경 0085). 추가 옵션은 DeviceOptions & { label?: string }처럼 교차 타입으로 결합합니다. 인터페이스는 이 유니언 타입을 확장할 수 없습니다.
소스
src/runtime/device.ts, 56행, 커밋 af54ddad5 기준