Skip to main content

Fft1d

Struct Fft1d 

Source
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

Source

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)
  • size must be a power of two.
  • size must 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.

Source

pub fn size(&self) -> u32

Transform size (number of complex samples).

Source

pub fn is_inverse(&self) -> bool

true when this kernel computes the inverse FFT.

Source

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 equal self.size).
  • imag_in — imaginary parts of the input (length must equal self.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.

Source

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.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Fft1d

§

impl !UnwindSafe for Fft1d

§

impl Freeze for Fft1d

§

impl Send for Fft1d

§

impl Sync for Fft1d

§

impl Unpin for Fft1d

§

impl UnsafeUnpin for Fft1d

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more