/** * WebGPU device initialization */ export declare class WebGPUDevice { private adapter; private device; private context; private format; private canvas; private lastWidth; private lastHeight; private contextConfigured; private frameCount; /** Async GPU validation errors (not caught by try-catch) */ _uncapturedErrorCount: number; _lastUncapturedError: string; /** * Notified when the GPU device is lost for a reason OTHER than intentional * teardown (`reason === 'destroyed'`) — e.g. a driver reset from the OS GPU * watchdog (Windows TDR) or VRAM exhaustion on a weak/integrated GPU. Once a * device is lost every GPU resource created from it is dead, so the renderer * cannot present again until it is fully re-initialised. Consumers subscribe * (see `Renderer.onDeviceLost`) to react — e.g. reload the model — instead of * leaving a permanently blank canvas. */ private deviceLostHandler; /** Guards against firing the handler more than once for a single device. */ private deviceLostFired; /** * Initialize WebGPU device and canvas context */ init(canvas: HTMLCanvasElement): Promise; /** * Configure/reconfigure the canvas context * Must be called after canvas resize or when context becomes invalid */ configureContext(): void; /** * Check if context needs reconfiguration (canvas resized or context invalid) */ needsReconfigure(): boolean; /** * Mark context as needing reconfiguration (call after WebGPU errors) */ invalidateContext(): void; /** * Ensure context is valid before rendering * Returns true if context is ready, false if we need to skip this frame */ ensureContext(): boolean; /** * Get current frame's texture safely * Returns null if texture is not available (context needs reconfiguration) */ getCurrentTexture(): GPUTexture | null; getDevice(): GPUDevice; /** * Register the callback fired when this device is lost for a non-intentional * reason (see `deviceLostHandler`). Only one handler is kept; the renderer * owns it and fans out to its own subscribers. Set before `init()` so a loss * during the very first frames is not missed. */ onDeviceLost(handler: (info: { message: string; reason: string; }) => void): void; /** * Max 2D texture dimension reported by the GPU adapter. WebGPU's spec floor is 8192; * iGPUs and most desktop GPUs report 8192 or 16384. Render targets / depth textures * must not exceed this in either axis or the device fails validation. */ getMaxTextureDimension(): number; getContext(): GPUCanvasContext; getFormat(): GPUTextureFormat; isInitialized(): boolean; /** * Intentionally tear down the GPU device, freeing the device, its queue, and * the canvas-context configuration. An app that recreates a renderer per model * otherwise leaks one live GPUDevice (and its VRAM) per reload. The device's * `lost` promise resolves with reason `'destroyed'`, which the loss handler * above deliberately ignores (intentional teardown, not a fault). After this * `isInitialized()` reports false, so the renderer's per-frame guard skips * rendering until a fresh `init()`. Idempotent — safe to call more than once. */ destroy(): void; } //# sourceMappingURL=device.d.ts.map