@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
80 lines • 3.75 kB
TypeScript
/// <reference types="@webgpu/types" />
/** Storage access modes described by the WebGPU texture capability table. */
export type MotionGPUStorageTextureAccess = 'write-only' | 'read-only' | 'read-write';
/** Device-aware capabilities for one WebGPU texture format. */
export interface TextureFormatCapabilities {
format: GPUTextureFormat;
supported: boolean;
renderable: boolean;
colorRenderable: boolean;
sampleType: GPUTextureSampleType | null;
filterable: boolean;
storageAccess: readonly MotionGPUStorageTextureAccess[];
requiredFeatures: Readonly<{
format?: GPUFeatureName;
renderable?: GPUFeatureName;
filterable?: GPUFeatureName;
storageAccess?: Readonly<Partial<Record<MotionGPUStorageTextureAccess, GPUFeatureName>>>;
}>;
}
export interface FormatCapabilityDiagnostic {
target: string;
format: unknown;
pass: string;
capability: string;
detail?: string;
}
/** Texture formats recognized by the WebGPU typings supported in this release. */
export declare const TEXTURE_FORMATS: ReadonlySet<string>;
/** Rejects texture format strings outside the WebGPU contract known to this release. */
export declare function assertTextureFormat(format: unknown, label?: string): asserts format is GPUTextureFormat;
/** Reports whether a texture format uses 32-bit floating-point channels. */
export declare function isFloat32TextureFormat(format: GPUTextureFormat): boolean;
/** Reports whether the format has any storage-texture access in the WebGPU capability table. */
export declare function isStorageTextureFormat(format: GPUTextureFormat): boolean;
/** Resolves the WGSL sampled scalar represented by a texture format. */
export declare function textureSampleScalarType(format: GPUTextureFormat): 'f32' | 'u32' | 'i32' | 'depth' | null;
/**
* Returns the effective capabilities of a texture format on the active device.
* This is the sole format classification table used by render, sampling and compute paths.
*/
export declare function resolveTextureFormatCapabilities(format: GPUTextureFormat, deviceFeatures?: ReadonlySet<string>): TextureFormatCapabilities;
/** Creates a stable classified error for an unmet format capability. */
export declare function createFormatCapabilityError(input: FormatCapabilityDiagnostic): Error;
/** Validates a format used as a MotionGPU color render target. */
export declare function assertRenderableFormat(input: {
format: unknown;
target: string;
pass: string;
deviceFeatures?: ReadonlySet<string>;
}): TextureFormatCapabilities;
/** Validates a built-in pass input declared as `texture_2d<f32>`. */
export declare function assertFloatSampledFormat(input: {
format: unknown;
target: string;
pass: string;
deviceFeatures?: ReadonlySet<string>;
}): TextureFormatCapabilities;
/** Validates a built-in pass output written by a `vec4f` fragment result. */
export declare function assertFloatRenderableFormat(input: {
format: unknown;
target: string;
pass: string;
deviceFeatures?: ReadonlySet<string>;
}): TextureFormatCapabilities;
/** Validates a storage texture access against the active device. */
export declare function assertStorageTextureAccess(input: {
format: unknown;
target: string;
pass: string;
access: MotionGPUStorageTextureAccess;
deviceFeatures?: ReadonlySet<string>;
}): TextureFormatCapabilities;
/** Validates that a device supports the format itself, independent of a specific usage. */
export declare function assertTextureFormatSupported(input: {
format: unknown;
target: string;
pass: string;
deviceFeatures?: ReadonlySet<string>;
}): TextureFormatCapabilities;
//# sourceMappingURL=format-capabilities.d.ts.map