Skip to main content

Crate wgsl_fft

Crate wgsl_fft 

Source
Expand description

GPU-accelerated FFT using wgpu compute shaders.

This crate provides fast Fourier transform (FFT) computation on GPU hardware using WebGPU compute shaders via the wgpu library.

§Features

  • GPU-accelerated: Uses wgpu compute shaders for high-performance FFT computation.
  • Stockham Radix-4/2: Fast algorithm for power-of-two FFT sizes.
  • Arbitrary sizes: Bluestein’s algorithm for non-power-of-two sizes (GPU-accelerated via power-of-2 FFTs).
  • Batch processing: Efficiently process multiple FFTs in a single call.
  • Fallback support: Automatically falls back to CPU software rendering if no GPU is available.

§Quick Start

use wgsl_fft::GpuFft;
use num_complex::Complex;

let fft = GpuFft::new().expect("GPU or CPU fallback required");
let input = vec![vec![Complex::new(1.0, 0.0); 1024]];
let spectrum = fft.fft(&input).expect("FFT failed");

§Module Structure

  • [fft] - Main FFT implementation with GpuFft and FftExecutor trait
  • [pipelines] - Pre-compiled FFT pipelines for embedding in larger GPU pipelines
  • shaders - WGSL compute shader source code
  • benchmark - Benchmarking utilities
  • [error] - Error types for FFT operations

Modules§

benchmark
rivals
The FFT Rivalry Registry
shaders

Structs§

FftPipelines
Pre-compiled Cooley-Tukey Radix-2 FFT pipelines for embedding in a larger GPU pipeline.
FftUniforms
Uniforms passed to the compute shader (16-byte aligned).
GpuFft
GPU-accelerated FFT engine backed by wgpu compute shaders.
SizeCache
Pre-allocated GPU resources for a specific FFT size.

Enums§

FftDirection
Direction for FFT operations
FftError
Main error type for FFT operations

Traits§

FftExecutor
Trait for FFT implementations that can be benchmarked.
GpuFftTrait
Trait for GPU FFT implementations that support GPU-only benchmarking.

Type Aliases§

Result
Result type alias for FFT operations