more
This commit is contained in:
parent
2fe3c69963
commit
6bc125be1c
104 changed files with 3088 additions and 2414 deletions
|
|
@ -12,6 +12,7 @@ import { RenderPipeline } from '../pipelines/render/render-pipeline';
|
|||
import { settings } from '../settings';
|
||||
import { initializeContext } from '../utils/graphics/initialize-context';
|
||||
import { CanvasReadbackRequest, RenderInputs } from './game-loop-types';
|
||||
import { GpuProfiler } from './gpu-profiler';
|
||||
import { SimulationFrameRenderer } from './simulation-frame';
|
||||
import { SimulationTextures } from './simulation-textures';
|
||||
|
||||
|
|
@ -36,6 +37,7 @@ export class GameLoopResources {
|
|||
public readonly eraserTexturePipeline: EraserTexturePipeline;
|
||||
public readonly diffusionPipeline: DiffusionPipeline;
|
||||
public readonly renderPipeline: RenderPipeline;
|
||||
public readonly gpuProfiler: GpuProfiler | null;
|
||||
|
||||
private readonly frameRenderer: SimulationFrameRenderer;
|
||||
|
||||
|
|
@ -52,7 +54,6 @@ export class GameLoopResources {
|
|||
this.commonState = new CommonState(this.device);
|
||||
this.commonState.setParameters({
|
||||
canvasSize,
|
||||
time: 0,
|
||||
});
|
||||
|
||||
this.agentGenerationPipeline = new AgentGenerationPipeline(
|
||||
|
|
@ -73,15 +74,21 @@ export class GameLoopResources {
|
|||
this.eraserTexturePipeline = new EraserTexturePipeline(this.device, this.commonState);
|
||||
this.diffusionPipeline = new DiffusionPipeline(this.device);
|
||||
this.renderPipeline = new RenderPipeline(context, this.device, this.commonState);
|
||||
this.gpuProfiler = GpuProfiler.create(this.device);
|
||||
|
||||
this.frameRenderer = new SimulationFrameRenderer(this.device, this.textures, {
|
||||
agentPipeline: this.agentPipeline,
|
||||
brushPipeline: this.brushPipeline,
|
||||
eraserAgentPipeline: this.eraserAgentPipeline,
|
||||
eraserTexturePipeline: this.eraserTexturePipeline,
|
||||
diffusionPipeline: this.diffusionPipeline,
|
||||
renderPipeline: this.renderPipeline,
|
||||
});
|
||||
this.frameRenderer = new SimulationFrameRenderer(
|
||||
this.device,
|
||||
this.textures,
|
||||
{
|
||||
agentPipeline: this.agentPipeline,
|
||||
brushPipeline: this.brushPipeline,
|
||||
eraserAgentPipeline: this.eraserAgentPipeline,
|
||||
eraserTexturePipeline: this.eraserTexturePipeline,
|
||||
diffusionPipeline: this.diffusionPipeline,
|
||||
renderPipeline: this.renderPipeline,
|
||||
},
|
||||
this.gpuProfiler
|
||||
);
|
||||
}
|
||||
|
||||
public resizeSimulationTo(nextSize: vec2): vec2 | null {
|
||||
|
|
@ -93,6 +100,10 @@ export class GameLoopResources {
|
|||
this.frameRenderer.resetSourceMapActivity();
|
||||
}
|
||||
|
||||
public get isSourceMapActive(): boolean {
|
||||
return this.frameRenderer.isSourceMapActive;
|
||||
}
|
||||
|
||||
public setFrameParameters({
|
||||
time,
|
||||
deltaTime,
|
||||
|
|
@ -107,7 +118,6 @@ export class GameLoopResources {
|
|||
}: FrameParameters): void {
|
||||
this.commonState.setParameters({
|
||||
canvasSize,
|
||||
time,
|
||||
});
|
||||
this.agentPipeline.setParameters({
|
||||
...settings,
|
||||
|
|
@ -130,11 +140,13 @@ export class GameLoopResources {
|
|||
this.diffusionPipeline.setParameters(settings);
|
||||
this.renderPipeline.setParameters({
|
||||
...settings,
|
||||
backgroundGrainStrength: 0,
|
||||
channelColors,
|
||||
backgroundColor,
|
||||
});
|
||||
this.eraserAgentPipeline.setParameters({
|
||||
agentCount: activeAgentCount,
|
||||
eraserSize: eraserPixelSize,
|
||||
eraserMaskAlphaThreshold: settings.eraserMaskAlphaThreshold,
|
||||
maskSize: canvasSize,
|
||||
});
|
||||
|
|
@ -163,6 +175,7 @@ export class GameLoopResources {
|
|||
this.eraserTexturePipeline.destroy();
|
||||
this.diffusionPipeline.destroy();
|
||||
this.renderPipeline.destroy();
|
||||
this.gpuProfiler?.destroy();
|
||||
this.commonState.destroy();
|
||||
this.textures.destroy();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue