@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
96 lines • 2.83 kB
TypeScript
import type { ComputeResourceMap } from '../core/types.js';
import type { ComputePassOptions, ComputeDispatchContext } from './ComputePass.js';
/**
* Options for constructing a `PingPongComputePass`.
*/
export interface PingPongComputePassOptions {
/**
* Compute shader WGSL source code.
*/
compute: string;
/**
* Pass-local resources keyed by their WGSL binding aliases.
* Must contain one sampled `pingPong: 'read'` descriptor and one
* storage-write `pingPong: 'write'` descriptor for the same texture.
*/
resources: ComputeResourceMap;
/**
* 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 readonly resources;
private iterations;
private dispatch;
private workgroupSize;
constructor(options: PingPongComputePassOptions);
private static assertIterations;
/**
* 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 current iteration count.
*/
getIterations(): number;
/**
* Returns current compute shader source.
*/
getCompute(): string;
/**
* Returns a defensive copy of the immutable pass resource topology.
*/
getResources(): ComputeResourceMap;
/**
* 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