Add parallel shader compiling

This commit is contained in:
schmelczerandras 2020-09-10 11:32:05 +02:00
parent a6efbc02b9
commit 39a6ee9a20
17 changed files with 209 additions and 77 deletions

View file

@ -36,6 +36,8 @@ export class WebGl2Renderer implements IRenderer {
private lightingPass: RenderingPass;
private autoscaler: FpsAutoscaler;
private initializePromise: Promise<[void, void]> = null;
private matrices: {
distanceScreenToWorld?: mat2d;
worldToDistanceUV?: mat2d;
@ -63,6 +65,11 @@ export class WebGl2Renderer implements IRenderer {
this.lightingFrameBuffer
);
this.initializePromise = Promise.all([
this.distancePass.initialize(),
this.lightingPass.initialize(),
]);
this.autoscaler = new FpsAutoscaler([
this.lightingFrameBuffer,
this.distanceFieldFrameBuffer,
@ -75,6 +82,10 @@ export class WebGl2Renderer implements IRenderer {
}
}
public async initialize(): Promise<void> {
await this.initializePromise;
}
public drawShape(shape: IDrawable) {
this.distancePass.addDrawable(shape);
}