Files
WebGPU-FFT-Ocean-Demo/passes/RowFFTPass.js
2025-12-31 14:31:55 +01:00

51 lines
1.1 KiB
JavaScript

import { RenderPass } from "./framework/RenderPass.js";
import Shader from "./framework/WebGpu.js";
export class RowFFTPass extends RenderPass {
async create( ) {
this.shader = new Shader( this.device );
await this.shader.setup( "shaders/fft_row.wgsl" );
const oceanBlock = this.pipeline.getBlockByName( "ocean" );
const spectrumPass = oceanBlock.getPass( "Spectrum" );
const spectrumReal = spectrumPass.shader.getBuffer( "spectrumReal" );
const spectrumImag = spectrumPass.shader.getBuffer( "spectrumImag" );
await this.shader.setBuffer( "inputReal", spectrumReal );
await this.shader.setBuffer( "inputImag", spectrumImag );
this.shader.setVariable( "outputReal", this.pipeline.memory.rowReal );
this.shader.setVariable( "outputImag", this.pipeline.memory.rowImag );
this.shader.setVariable( "params", this.pipeline.memory.computeParams );
}
bindBuffers( ) {
this.shader.setVariable( "params", this.pipeline.memory.computeParams );
}
async execute( ) {
const groups = this.pipeline.gridSize;
await this.shader.execute( groups, 1, 1 );
}
}