pub struct Fft1d { /* private fields */ }Expand description
GPU-accelerated radix-2 1D FFT (or IFFT) kernel.
A single Fft1d instance is bound to a specific transform size and
direction (forward/inverse). Construct it once with Fft1d::new and
reuse it for multiple Fft1d::execute or Fft1d::execute_batch calls.
Implementations§
Source§impl Fft1d
impl Fft1d
Sourcepub fn new(ctx: &GpuContext, size: u32, inverse: bool) -> GpuResult<Self>
pub fn new(ctx: &GpuContext, size: u32, inverse: bool) -> GpuResult<Self>
Create a new FFT kernel for the given transform size and direction.
§Validation (pure-Rust, no GPU required)
sizemust be a power of two.sizemust be in the range[4, 2048].
§Errors
Returns GpuError::InvalidConfig if the size fails validation, or a
pipeline / shader error if WGSL compilation fails on the GPU device.
Sourcepub fn is_inverse(&self) -> bool
pub fn is_inverse(&self) -> bool
true when this kernel computes the inverse FFT.
Sourcepub fn execute(
&self,
ctx: &GpuContext,
real_in: &[f32],
imag_in: &[f32],
) -> GpuResult<(Vec<f32>, Vec<f32>)>
pub fn execute( &self, ctx: &GpuContext, real_in: &[f32], imag_in: &[f32], ) -> GpuResult<(Vec<f32>, Vec<f32>)>
Execute a single 1D FFT/IFFT.
§Arguments
real_in— real parts of the input (length must equalself.size).imag_in— imaginary parts of the input (length must equalself.size).
§Returns
A tuple (real_out, imag_out) each of length self.size.
§Errors
Returns an error if input lengths are wrong or any GPU operation fails.
Sourcepub fn execute_batch(
&self,
ctx: &GpuContext,
batch: &[(Vec<f32>, Vec<f32>)],
) -> GpuResult<Vec<(Vec<f32>, Vec<f32>)>>
pub fn execute_batch( &self, ctx: &GpuContext, batch: &[(Vec<f32>, Vec<f32>)], ) -> GpuResult<Vec<(Vec<f32>, Vec<f32>)>>
Execute a batch of FFT/IFFT transforms in one GPU dispatch.
All transforms in the batch must use the same size (enforced by the
shader’s workgroup layout). Each workgroup handles one transform.
§Errors
Returns an error if any batch element has the wrong size or if a GPU operation fails.