Skip to content

Commit 1be15c8

Browse files
committed
feat: Add renderer swaps to debug stats
1 parent bc6ab76 commit 1be15c8

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/engine/Debug/DebugConfig.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export interface PhysicsStatistics {
148148
export interface GraphicsStatistics {
149149
drawCalls: number;
150150
drawnImages: number;
151+
rendererSwaps: number;
151152
}
152153

153154
/**
@@ -424,7 +425,8 @@ export class FrameStats implements FrameStatistics {
424425

425426
private _graphicsStats: GraphicsStatistics = {
426427
drawCalls: 0,
427-
drawnImages: 0
428+
drawnImages: 0,
429+
rendererSwaps: 0
428430
};
429431

430432
/**
@@ -444,12 +446,13 @@ export class FrameStats implements FrameStatistics {
444446
this._physicsStats.reset(otherStats.physics);
445447
this.graphics.drawCalls = otherStats.graphics.drawCalls;
446448
this.graphics.drawnImages = otherStats.graphics.drawnImages;
449+
this.graphics.rendererSwaps = otherStats.graphics.rendererSwaps;
447450
} else {
448451
this.id = this.elapsedMs = this.fps = 0;
449452
this.actors.alive = this.actors.killed = this.actors.ui = 0;
450453
this.duration.update = this.duration.draw = 0;
451454
this._physicsStats.reset();
452-
this.graphics.drawnImages = this.graphics.drawCalls = 0;
455+
this.graphics.drawnImages = this.graphics.drawCalls = this.graphics.rendererSwaps = 0;
453456
}
454457
}
455458

src/engine/Engine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,7 @@ O|===|* >________________>\n\
18011801
this.stats.currFrame.duration.draw = afterDraw - afterUpdate;
18021802
this.stats.currFrame.graphics.drawnImages = GraphicsDiagnostics.DrawnImagesCount;
18031803
this.stats.currFrame.graphics.drawCalls = GraphicsDiagnostics.DrawCallCount;
1804+
this.stats.currFrame.graphics.rendererSwaps = GraphicsDiagnostics.RendererSwaps;
18041805

18051806
this.emit('postframe', new PostFrameEvent(this, this.stats.currFrame));
18061807
this.stats.prevFrame.reset(this.stats.currFrame);

src/engine/Graphics/Context/ExcaliburGraphicsContextWebGL.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { ParticleRenderer } from './particle-renderer/particle-renderer';
4343
import { ImageRendererV2 } from './image-renderer-v2/image-renderer-v2';
4444
import { Flags } from '../../Flags';
4545
import { Debug } from '../Debug';
46+
import { GraphicsDiagnostics } from '../GraphicsDiagnostics';
4647

4748
export const pixelSnapEpsilon = 0.0001;
4849

@@ -804,6 +805,7 @@ export class ExcaliburGraphicsContextWebGL implements ExcaliburGraphicsContext {
804805
currentRenderer!.flush();
805806
currentRendererName = this._drawCalls[i].renderer;
806807
currentRenderer = this.get(currentRendererName);
808+
GraphicsDiagnostics.RendererSwaps++;
807809
}
808810

809811
// ! hack to grab screen texture before materials run because they might want it
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
export class GraphicsDiagnostics {
22
public static DrawCallCount: number = 0;
33
public static DrawnImagesCount: number = 0;
4+
public static RendererSwaps: number = 0;
45
public static clear(): void {
56
GraphicsDiagnostics.DrawCallCount = 0;
67
GraphicsDiagnostics.DrawnImagesCount = 0;
8+
GraphicsDiagnostics.RendererSwaps = 0;
79
}
810
}

0 commit comments

Comments
 (0)