import { TgpuRoot } from 'typegpu'; export interface AcquireRootOptions { /** * Inject an existing device (shared-device / Projects path). When present we adopt it * via `tgpu.initFromDevice` and reuse one cached root per device; `root.destroy()` * will NOT destroy an adopted device (see `createdDevice`). */ device?: GPUDevice; /** * The adapter that produced an injected device, if the caller has it. Stored on the * returned context for `getGPUContext()` reporting; never used to request a device. */ adapter?: GPUAdapter; /** * Called when the device is lost for a reason other than `'destroyed'`. Wiring point * only; the renderer decides whether to rebuild. */ onDeviceLost?: (info: GPUDeviceLostInfo) => void; } export interface RootContext { root: TgpuRoot; device: GPUDevice; adapter?: GPUAdapter; /** * True only when this renderer EXCLUSIVELY owns the device and its `cleanup()` may * destroy it. Always false today: an injected device belongs to the caller, and the * default device is shared page-wide and must outlive any one renderer. Kept because it * is part of the public `RootContext` shape and guards the destroy path. */ createdDevice: boolean; /** * Unsubscribe this renderer's device-loss callback. MUST be called from `cleanup()`: the * default device outlives every renderer on it, so a missed release leaks the callback * (and later fires it on a torn-down renderer) for the life of the page. */ release?: () => void; } /** * Acquire a TgpuRoot: around an injected device when the caller supplies one, otherwise * around the shared page-wide default (see the module header). SSR-safe: no `navigator.gpu` * access happens until this is called. * * @throws {GpuUnavailableError} when a device can't be obtained — this renderer is * WebGPU-only, there is no fallback. */ export declare function acquireRoot(options?: AcquireRootOptions): Promise; /** * Destroy the shared default device and forget it, so the next acquire builds a fresh one. * * Nothing in the library calls this — the default device is meant to outlive components (see * the module header). It exists for tests and for hosts that genuinely want to reclaim GPU * memory when they know no shader will mount again. */ export declare function destroyDefaultGpuDevice(): void; /** Testing seam — drop the cached default root WITHOUT destroying it. */ export declare function __resetDefaultRoot(): void; /** * Create and configure a WebGPU context for a canvas. Each canvas gets its own context * even when several share a device. Output is `premultiplied` by default; shaders * emit straight alpha, so the final pass premultiplies RGB by A. Pass overrides here to * change alpha/sRGB behaviour. */ export declare function configureCanvasContext(root: TgpuRoot, canvas: HTMLCanvasElement, options?: Omit[0], 'canvas'>): GPUCanvasContext; /** Look up the cached root for an already-adopted device, if any (Projects multi-tile). */ export declare function getRootForDevice(device: GPUDevice): TgpuRoot | undefined; //# sourceMappingURL=root.d.ts.map