UNPKG

@motion-core/motion-gpu

Version:

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

105 lines 3.01 kB
import type { ComputePassOptions, ComputeDispatchContext } from './ComputePass.js'; /** * Options for constructing a `PingPongComputePass`. */ export interface PingPongComputePassOptions { /** * Compute shader WGSL source code. */ compute: string; /** * Target texture key from `material.textures`. * The engine will auto-generate `{target}A` and `{target}B` bindings. */ target: string; /** * Number of compute iterations per frame. Default: 1. */ iterations?: number; /** * Dispatch workgroup counts (same as ComputePass). */ dispatch?: ComputePassOptions['dispatch']; /** * Enables/disables this pass. */ enabled?: boolean; } /** * Ping-pong compute pass for iterative GPU simulations. * * Manages two texture buffers (A/B) and alternates between them each iteration, * enabling read-from-previous-write patterns commonly used in fluid simulations, * reaction-diffusion, and particle systems. */ export declare class PingPongComputePass { /** * Enables/disables this pass without removing it from graph. */ enabled: boolean; /** * Discriminant flag for render graph to identify compute passes. */ readonly isCompute: true; /** * Discriminant flag to identify ping-pong compute passes. */ readonly isPingPong: true; private compute; private target; private iterations; private dispatch; private workgroupSize; private totalIterations; constructor(options: PingPongComputePassOptions); private static assertIterations; /** * Returns the texture key holding the latest result. * Alternates between `{target}A` and `{target}B` based on accumulated iteration parity. */ getCurrentOutput(): string; /** * Advances the iteration accumulator by the current iteration count * (called by renderer after each frame's iterations). */ advanceFrame(): void; /** * Replaces compute shader and updates workgroup size. */ setCompute(compute: string): void; /** * Updates iteration count. * * @param count - Must be >= 1. */ setIterations(count: number): void; /** * Updates dispatch strategy. */ setDispatch(dispatch: ComputePassOptions['dispatch']): void; /** * Returns the target texture key. */ getTarget(): string; /** * Returns the current iteration count. */ getIterations(): number; /** * Returns current compute shader source. */ getCompute(): string; /** * Returns parsed workgroup size. */ getWorkgroupSize(): [number, number, number]; /** * Resolves dispatch workgroup counts for current frame. */ resolveDispatch(ctx: ComputeDispatchContext): [number, number, number]; /** * Releases resources (no-op, GPU lifecycle is renderer-managed). */ dispose(): void; } //# sourceMappingURL=PingPongComputePass.d.ts.map