/** * WebGPU Compute Pipeline for Particle Physics * * Manages the compute pipeline, bind groups, and dispatch logic for GPU-accelerated * particle physics simulation. * * @module gpu/ComputePipeline */ import type { WebGPUContext } from './WebGPUContext.js'; import type { GPUBufferManager, UniformData } from './GPUBuffers.js'; export interface ComputePipelineOptions { /** WGSL shader code */ shaderCode: string; /** Entry point function name (default: "main") */ entryPoint?: string; /** Workgroup size (must match shader @workgroup_size) */ workgroupSize?: number; } /** * WebGPU Compute Pipeline Manager * * Wraps WebGPU compute pipeline creation and execution for particle physics. * * @example * ```typescript * const pipeline = new ComputePipeline(context, bufferManager, { * shaderCode: particlePhysicsShader, * workgroupSize: 256, * }); * * await pipeline.initialize(); * * // Simulation loop * for (let frame = 0; frame < 1000; frame++) { * pipeline.updateUniforms({ dt: 0.016, gravity: 9.8, ... }); * await pipeline.dispatch(); * bufferManager.swap(); * } * ``` */ export declare class ComputePipeline { private context; private bufferManager; private device; private options; private pipeline; private bindGroupLayout; private bindGroup; private workgroupsX; constructor(context: WebGPUContext, bufferManager: GPUBufferManager, options: ComputePipelineOptions); /** * Initialize compute pipeline and bind groups */ initialize(): Promise; /** * Create bind group linking buffers to shader bindings */ private createBindGroup; /** * Update uniform buffer with simulation parameters */ updateUniforms(uniforms: UniformData): void; /** * Dispatch compute shader to update all particles * * @param commandEncoder Optional command encoder (creates new one if not provided) * @returns Command encoder (for chaining or submission) */ dispatch(commandEncoder?: GPUCommandEncoder): GPUCommandEncoder; /** * Execute a single simulation step * * Convenience method that dispatches compute shader and submits to queue. * * @param uniforms Simulation parameters for this step */ step(uniforms: UniformData): Promise; /** * Execute multiple simulation steps (batch processing) * * @param steps Number of steps to execute * @param uniforms Simulation parameters (same for all steps) * @param onProgress Optional progress callback */ run(steps: number, uniforms: UniformData, onProgress?: (step: number, total: number) => void): Promise; /** * Get pipeline statistics */ getStats(): { particleCount: number; workgroupSize: number; workgroups: number; threadsTotal: number; }; /** * Cleanup resources */ destroy(): void; } /** * Helper: Create and initialize a complete GPU physics simulation * * @example * ```typescript * const sim = await createGPUPhysicsSimulation({ * particleCount: 100000, * shaderCode: particlePhysicsWGSL, * }); * * // Upload initial particle data * sim.bufferManager.uploadParticleData(initialData); * * // Run simulation * await sim.pipeline.run(1000, { * dt: 0.016, * gravity: 9.8, * groundY: 0, * restitution: 0.3, * friction: 0.9, * particleCount: 100000, * }); * * // Get results * const results = await sim.bufferManager.downloadParticleData(); * ``` */ export declare function createGPUPhysicsSimulation(options: { particleCount: number; shaderCode: string; contextOptions?: any; workgroupSize?: number; }): Promise<{ context: WebGPUContext; bufferManager: GPUBufferManager; pipeline: ComputePipeline; }>; //# sourceMappingURL=ComputePipeline.d.ts.map