UNPKG

@motion-core/motion-gpu

Version:

Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.

132 lines 4.08 kB
/// <reference types="@webgpu/types" /> import type { TextureData, TextureDefinition, TextureDefinitionMap, TextureUpdateMode, TextureValue } from './types.js'; /** * Texture definition with defaults and normalized numeric limits applied. */ export interface NormalizedTextureDefinition { /** * Normalized source value. */ source: TextureValue; /** * Effective color space. */ colorSpace: 'srgb' | 'linear'; /** * Effective texture format. */ format: GPUTextureFormat; /** * Effective flip-y flag. */ flipY: boolean; /** * Effective mipmap toggle. */ generateMipmaps: boolean; /** * Effective premultiplied-alpha flag. */ premultipliedAlpha: boolean; /** * Effective dynamic update strategy. */ update?: TextureUpdateMode; /** * Effective anisotropy level. */ anisotropy: number; /** * Effective filter mode. */ filter: GPUFilterMode; /** * Effective U address mode. */ addressModeU: GPUAddressMode; /** * Effective V address mode. */ addressModeV: GPUAddressMode; /** * Whether this texture is a storage texture (writable by compute). */ storage: boolean; /** * Whether this texture should be exposed as a fragment-stage sampled binding. */ fragmentVisible: boolean; /** * Explicit width for storage textures. Undefined when derived from source. */ width?: number; /** * Explicit height for storage textures. Undefined when derived from source. */ height?: number; } /** * Validates and returns sorted texture keys. * * @param textures - Texture definition map. * @returns Lexicographically sorted texture keys. */ export declare function resolveTextureKeys(textures: TextureDefinitionMap): string[]; /** * Applies defaults and clamps to a single texture definition. * * @param definition - Optional texture definition. * @returns Normalized definition with deterministic defaults. */ export declare function normalizeTextureDefinition(definition: TextureDefinition | undefined): NormalizedTextureDefinition; /** * Normalizes all texture definitions for already-resolved texture keys. * * @param textures - Source texture definitions. * @param textureKeys - Texture keys to normalize. * @returns Normalized map keyed by `textureKeys`. */ export declare function normalizeTextureDefinitions(textures: TextureDefinitionMap, textureKeys: string[]): Record<string, NormalizedTextureDefinition>; /** * Checks whether a texture value is a structured `{ source, width?, height? }` object. */ export declare function isTextureData(value: TextureValue): value is TextureData; /** * Converts supported texture input variants to normalized `TextureData`. * * @param value - Texture value input. * @returns Structured texture data or `null`. */ export declare function toTextureData(value: TextureValue): TextureData | null; /** * Resolves effective runtime texture update strategy. */ export declare function resolveTextureUpdateMode(input: { source: TextureData['source']; override?: TextureUpdateMode; defaultMode?: TextureUpdateMode; }): TextureUpdateMode; /** * Resolves texture dimensions from explicit values or source metadata. * * @param data - Texture payload. * @returns Positive integer width/height. * @throws {Error} When dimensions cannot be resolved to positive values. */ export declare function resolveTextureSize(data: TextureData): { width: number; height: number; }; /** * Computes the number of mipmap levels for a base texture size. * * @param width - Base width. * @param height - Base height. * @returns Total mip level count (minimum `1`). */ export declare function getTextureMipLevelCount(width: number, height: number): number; /** * Checks whether the source is an `HTMLVideoElement`. */ export declare function isVideoTextureSource(source: TextureData['source']): source is HTMLVideoElement; //# sourceMappingURL=textures.d.ts.map