2025-12-31 14:31:55 +01:00
|
|
|
import { RenderPass } from "./framework/RenderPass.js";
|
2025-12-31 14:22:45 +01:00
|
|
|
|
2025-12-31 14:31:55 +01:00
|
|
|
import Shader from "./framework/WebGpu.js";
|
2025-12-31 14:22:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|