import type { Effect, Frame, Gpu, Surface } from "vgpu"; import { QualityMonitor } from "./quality.js"; import type { ShaderName } from "./registry.js"; import type { ResolvedUniforms } from "./types.js"; /** * Every renderer on the page shares one GPU context and one frame loop. * * That matters for a gallery: twenty canvases each calling `init()` would mean * twenty devices and twenty rAF callbacks. Here they are twenty passes inside * a single command buffer, and the loop stops entirely when nothing is * animating. */ export interface StageInstance { readonly surface: Surface; readonly effect: Effect; active: boolean; /** Set when the instance wants exactly one more frame while paused. */ dirty: boolean; /** * Held out of the loop entirely. A source shader whose layer is still being * built has a binding pointing at nothing, and drawing it would fault. */ blocked?: boolean; localTime: number; update(deltaTime: number): ResolvedUniforms; /** * Encoded just before this instance's own pass, into the same frame. * * A source shader draws its backdrop here, so the texture it is about to read * is written by an earlier pass of the same command buffer. */ prepare?(frame: Frame, deltaTime: number): void; } export declare class Stage { readonly gpu: Gpu; /** * The page's adaptive-quality signals, here because the loop is here: the * frame rate they judge is the one loop's, and a verdict about the device * or the battery is a verdict for every canvas on the page. */ readonly quality: QualityMonitor; private readonly instances; private handle; private lastTime; constructor(gpu: Gpu); add(instance: StageInstance): void; remove(instance: StageInstance): void; /** Starts the loop if anything needs drawing. Cheap to call repeatedly. */ wake(): void; private hasWork; private sleep; } export declare function isWebGpuSupported(): boolean; /** One `Gpu` per page, created on first use. */ export declare function getStage(): Promise; export declare function createSurface(stage: Stage, canvas: HTMLCanvasElement, dpr: readonly [number, number]): Surface; export declare function createEffect(stage: Stage, name: ShaderName, initial: ResolvedUniforms): Effect; //# sourceMappingURL=stage.d.ts.map