Getting there
This commit is contained in:
parent
ed5a4379db
commit
f300dbd394
43 changed files with 1213 additions and 459 deletions
|
|
@ -46,16 +46,19 @@ export class SimulationFrameRenderer {
|
|||
const commandEncoder = this.device.createCommandEncoder();
|
||||
this.gpuProfiler?.beginFrame();
|
||||
|
||||
this.textures.copyTrailMapAToB(commandEncoder);
|
||||
// Clear the deposit map up-front so agents write fresh deposits each frame
|
||||
// and diffuse sees only this frame's contributions added to trailMapA.
|
||||
this.textures.clearDepositMap(commandEncoder);
|
||||
let wroteSourceMap = false;
|
||||
if (isErasing) {
|
||||
if (this.pipelines.eraserAgentPipeline.hasActiveMask()) {
|
||||
const eraserMask = this.textures.eraserMask.getTextureView();
|
||||
// Erase trailMapA directly — it's what agent and diffuse will read.
|
||||
this.pipelines.eraserTexturePipeline.executeCombined(
|
||||
commandEncoder,
|
||||
eraserMask,
|
||||
this.textures.sourceMapA.getTextureView(),
|
||||
this.textures.trailMapB.getTextureView(),
|
||||
this.textures.trailMapA.getTextureView(),
|
||||
this.gpuProfiler?.timestampWrites('eraserTexture')
|
||||
);
|
||||
this.pipelines.eraserAgentPipeline.execute(
|
||||
|
|
@ -86,19 +89,20 @@ export class SimulationFrameRenderer {
|
|||
this.pipelines.agentPipeline.execute(
|
||||
commandEncoder,
|
||||
this.textures.trailMapA.getTextureView(),
|
||||
this.textures.trailMapB.getTextureView(),
|
||||
this.textures.depositMap.getTextureView(),
|
||||
this.gpuProfiler?.timestampWrites('agent')
|
||||
);
|
||||
this.pipelines.diffusionPipeline.execute(
|
||||
commandEncoder,
|
||||
this.textures.trailMapB.getTextureView(),
|
||||
this.textures.trailMapA.getTextureView(),
|
||||
this.textures.trailMapB.getTextureView(),
|
||||
this.textures.trailMapA.getSize(),
|
||||
this.textures.depositMap.getTextureView(),
|
||||
this.gpuProfiler?.timestampWrites('trailDiffusion')
|
||||
);
|
||||
const canvasTexture = this.pipelines.renderPipeline.execute(
|
||||
commandEncoder,
|
||||
this.textures.trailMapA.getTextureView(),
|
||||
this.textures.trailMapB.getTextureView(),
|
||||
this.textures.sourceMapA.getTextureView(),
|
||||
useSourceMap,
|
||||
this.gpuProfiler?.timestampWrites('render')
|
||||
|
|
@ -111,6 +115,7 @@ export class SimulationFrameRenderer {
|
|||
this.textures.sourceMapA.getTextureView(),
|
||||
this.textures.sourceMapB.getTextureView(),
|
||||
this.textures.sourceMapB.getSize(),
|
||||
null,
|
||||
this.gpuProfiler?.timestampWrites('sourceDiffusion')
|
||||
);
|
||||
}
|
||||
|
|
@ -118,6 +123,10 @@ export class SimulationFrameRenderer {
|
|||
this.device.queue.submit([commandEncoder.finish()]);
|
||||
afterGpuProfileSubmit?.();
|
||||
canvasReadbackRequest?.afterSubmit();
|
||||
// After this frame's diffuse, trailMapB holds the fresh trail; swap so
|
||||
// trailMapA is "current trail" again for the next frame and any external
|
||||
// readers (e.g. export snapshot).
|
||||
this.textures.swapTrailMaps();
|
||||
if (useSourceMap) {
|
||||
this.textures.swapSourceMaps();
|
||||
this.sourceActiveFramesRemaining -= 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue