| 1 | export interface StreamBuffer { |
| 2 | /** |
| 3 | * Writes a new vertex payload into the streaming buffer. |
| 4 | * |
| 5 | * Notes: |
| 6 | * - `data` is interpreted as interleaved `vec2<f32>` vertices: `[x0, y0, x1, y1, ...]`. |
| 7 | * - Uses double buffering (alternates GPU buffers each write) to avoid writing into the same |
| 8 | * buffer the GPU might still be reading from the prior frame. |
| 9 | * - Uses a per-buffer CPU mirror (Uint32 bit patterns) to compute partial updates. |
| 10 | */ |
| 11 | write(data: Float32Array): void; |
| 12 | /** Returns the GPUBuffer that contains the most recently written data. */ |
| 13 | getBuffer(): GPUBuffer; |
| 14 | /** Returns the vertex count for the most recently written data. */ |
| 15 | getVertexCount(): number; |
| 16 | /** Destroys GPU resources (best-effort). Safe to call multiple times. */ |
| 17 | dispose(): void; |
| 18 | } |
| 19 | |
| 20 | const align4 = (n: number): number => (n + 3) & ~3; |
| 21 | |