UNPKG

@motion-core/motion-gpu

Version:

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

58 lines 2.33 kB
/// <reference types="@webgpu/types" /> import type { StorageBufferType, UniformLayout } from './types.js'; /** * Regex contract for the single public compute entrypoint. * * Keep the workgroup-size grammar aligned with `extractWorkgroupSize` so a * malformed attribute cannot make the expression scan across later attributes. */ export declare const COMPUTE_ENTRY_CONTRACT: RegExp; export type ResolvedComputeShaderBinding = Readonly<{ kind: 'sampled-texture'; alias: string; binding: number; scalarType: 'f32' | 'u32' | 'i32'; }> | Readonly<{ kind: 'storage-texture'; alias: string; binding: number; format: GPUTextureFormat; }> | Readonly<{ kind: 'storage-buffer'; alias: string; binding: number; access: 'storage-read' | 'storage-read-write'; wgslType: StorageBufferType; }> | Readonly<{ kind: 'sampler'; alias: string; binding: number; samplerType: GPUSamplerBindingType; }>; export interface ComputeShaderSourceLocation { kind: 'compute'; line: number; } /** 1-based line map from generated compute WGSL to user compute source. */ export type ComputeShaderLineMap = Array<ComputeShaderSourceLocation | null>; export interface BuiltComputeShaderSource { code: string; lineMap: ComputeShaderLineMap; } export interface BuildComputeShaderSourceOptions { compute: string; uniformLayout: UniformLayout; resources: readonly ResolvedComputeShaderBinding[]; } export declare function assertComputeContract(compute: string): void; export declare function extractWorkgroupSize(compute: string): [number, number, number]; /** * Emits the heterogeneous group 1 declarations from the resolver-owned order. */ export declare function buildComputeResourceBindings(resources: readonly ResolvedComputeShaderBinding[]): string; /** Maps storage texture format to sampled `texture_2d<T>` scalar type. */ export declare function storageTextureSampleScalarType(format: GPUTextureFormat): 'f32' | 'u32' | 'i32'; export declare function buildComputeShaderSource(options: BuildComputeShaderSourceOptions): string; /** The renderer's only compute WGSL generation path. */ export declare function buildComputeShaderSourceWithMap(options: BuildComputeShaderSourceOptions): BuiltComputeShaderSource; //# sourceMappingURL=compute-shader.d.ts.map