Layer 01
Public surface
createFFTEngine(), real-input FFT APIs, CPU shortcuts, and utilities define the supported contract.
Read this page as a system note, not as marketing copy. It explains where the GPU path begins, where the CPU path remains authoritative, and why the current design stays deliberately narrow.
System map
The project is intentionally narrow. Public APIs define the FFT contract, the execution layer owns planning and resources, GPU passes handle the transform core, and application utilities stay on CPU.
Layer 01
createFFTEngine(), real-input FFT APIs, CPU shortcuts, and utilities define the supported contract.
Layer 02
FFTEngine owns validation, execution-plan caching, buffer lifetime, and dispatch sequencing.
Layer 03
Bit reversal, butterfly stages, and scaling passes form the WebGPU FFT path.
Layer 04
Spectrum analysis and image filtering stay on the CPU path and should never be described as GPU-native.
| Surface | Backend reality | Why it matters |
|---|---|---|
createFFTEngine() | WebGPU-backed FFT execution core | This is the primary acceleration path |
cpuFFT() / cpuIFFT() | CPU reference path | Enables universal fallback and utility reuse |
rfft() / irfft() | Shared contract across GPU and CPU paths | Makes real-input usage explicit |
createSpectrumAnalyzer() | CPU-only helper | Should never be described as GPU-native |
createImageFilter() | CPU-only helper | Uses CPU 2D FFT internally |
| Decision | Why it exists | Consequence |
|---|---|---|
| Radix-2 Cooley-Tukey DIT | Best fit for predictable GPU memory access and maintainable code | Input sizes must remain powers of two |
| Row-column decomposition for 2D FFT | Reuses 1D kernels instead of building a separate 2D butterfly system | Adds an explicit transpose-oriented mental model |
workgroupSize = 256 | Keeps the shader surface stable during closeout | Tuning is hardware-dependent and intentionally not over-exposed |
| Optional bank-conflict optimization | Leaves room for hardware-specific wins without changing the default contract | Default stays conservative until profiling justifies flipping it |
Shader source of truth in src/shaders/sources.ts | Avoids drift between implementation and reference copies | WGSL changes stay centralized |
| Layer | Files | Responsibility |
|---|---|---|
| Public API | src/index.ts, src/types.ts | Exports the supported contract |
| Core engine | src/core/fft-engine.ts, src/core/gpu-fft-backend.ts | Validation, resource lifetime, plan reuse |
| Shader truth | src/shaders/sources.ts | Canonical WGSL source strings |
| CPU utilities | src/utils/**, src/apps/** | Fallback path plus CPU-only helpers |
| Architecture notes | docs/architecture/rfc/** | Historical design context retained as normal documentation |