import { TgpuRoot, TgpuBindGroup, TgpuBindGroupLayout, TgpuTexture, TgpuFixedSampler } from 'typegpu'; /** Formats a data texture may take (float/byte, for compute/lookup inputs). */ export type DataTextureFormat = 'r32float' | 'r16float' | 'rg16float' | 'rg32float' | 'rgba8unorm' | 'rgba16float' | 'rgba32float'; type AnyImageSource = HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | ImageBitmap | ImageData | OffscreenCanvas | VideoFrame; /** A managed texture wrapper: the TypeGPU texture plus lifecycle + upload + view helpers. */ export interface ManagedTexture { /** The underlying TypeGPU texture (already `$usage`-flagged). */ readonly texture: TgpuTexture; readonly width: number; readonly height: number; readonly format: GPUTextureFormat; /** Re-upload pixel data. Media: an image source; data: a TypedArray/ArrayBuffer. */ write(source: AnyImageSource | ArrayBuffer | ArrayBufferView): void; /** The raw GPUTexture (for HTMLInCanvas's `queue.copyElementImageToTexture`). */ unwrap(): GPUTexture; /** * A raw sRGB GPUTextureView when the texture was created with `srgb: true` (media only); * `undefined` otherwise. Sampling through it applies the sRGB→linear EOTF in hardware. */ createSrgbView(): GPUTextureView | undefined; /** Regenerate mipmaps (no-op unless created with sampled+render and mipLevelCount > 1). */ generateMipmaps(): void; /** Destroy the GPU texture and drop it from the live count. */ destroy(): void; } /** A render-to-texture target that can be resized (destroy + recreate). */ export interface RenderTexture extends ManagedTexture { /** Resize by destroying and recreating the backing texture. Returns false if already that size (no-op). */ resize(width: number, height: number): boolean; } /** Per-frame external-texture binding (video/webcam). */ export interface ExternalTextureBinding { /** * Import the current source and (re)build the bind group for this frame. Returns the fresh * bind group, or `null` when there is no current source (nothing to render this frame). */ update(): TgpuBindGroup | null; /** The bind group from the last successful `update()`, or `null`. */ readonly current: TgpuBindGroup | null; destroy(): void; } export interface CreateMediaTextureOptions { width: number; height: number; /** Base (linear) format. Default `rgba8unorm`. */ format?: GPUTextureFormat; /** Add an `-srgb` viewFormat + expose `createSrgbView()`. */ srgb?: boolean; mipLevelCount?: number; label?: string; } export interface CreateDataTextureOptions { width: number; height: number; format: DataTextureFormat; /** Optional initial pixel data. */ data?: ArrayBufferView; label?: string; } export interface CreateRenderTextureOptions { width: number; height: number; /** Default `rgba16float` (the RTT target format). */ format?: GPUTextureFormat; mipLevelCount?: number; label?: string; } export interface CreateExternalTextureBindingOptions { /** The bind group layout whose entry `entryKey` is a `d.textureExternal()`. */ layout: TgpuBindGroupLayout; /** The external-texture entry key in `layout`. */ entryKey: string; /** Returns the live source each frame, or null/undefined when unavailable. */ getSource: () => HTMLVideoElement | VideoFrame | null | undefined; /** Other (constant) bind group entries — samplers, uniform buffers, etc. */ staticEntries?: Record; } /** Shared sampler set. Created lazily; each getter caches. */ export interface SharedSamplers { readonly linearClamp: TgpuFixedSampler; readonly nearestClamp: TgpuFixedSampler; readonly linearRepeat: TgpuFixedSampler; readonly nearestRepeat: TgpuFixedSampler; } export interface TextureManager { readonly samplers: SharedSamplers; createMediaTexture(options: CreateMediaTextureOptions): ManagedTexture; createDataTexture(options: CreateDataTextureOptions): ManagedTexture; createRenderTexture(options: CreateRenderTextureOptions): RenderTexture; createExternalTextureBinding(options: CreateExternalTextureBindingOptions): ExternalTextureBinding; /** Number of live GPU textures this manager currently owns. */ readonly textureCount: number; /** Destroy every texture (and drop samplers) this manager created. */ destroy(): void; } export declare function createTextureManager(root: TgpuRoot): TextureManager; export {}; //# sourceMappingURL=textures.d.ts.map