|
@@ -419,16 +419,24 @@
|
|
|
|
|
|
// Private
|
|
|
private _engine: Engine;
|
|
|
- private _totalVertices = 0;
|
|
|
- public _activeIndices = 0;
|
|
|
- public _activeParticles = 0;
|
|
|
- private _lastFrameDuration = 0;
|
|
|
- private _evaluateActiveMeshesDuration = 0;
|
|
|
- private _renderTargetsDuration = 0;
|
|
|
- public _particlesDuration = 0;
|
|
|
- private _renderDuration = 0;
|
|
|
- public _spritesDuration = 0;
|
|
|
- private _animationRatio = 0;
|
|
|
+
|
|
|
+ // Performance counters
|
|
|
+ private _totalMeshesCounter = new PerfCounter();
|
|
|
+ private _totalLightsCounter = new PerfCounter();
|
|
|
+ private _totalMaterialsCounter = new PerfCounter();
|
|
|
+ private _totalTexturesCounter = new PerfCounter();
|
|
|
+ private _totalVertices = new PerfCounter();
|
|
|
+ public _activeIndices = new PerfCounter();
|
|
|
+ public _activeParticles = new PerfCounter();
|
|
|
+ private _lastFrameDuration = new PerfCounter();
|
|
|
+ private _evaluateActiveMeshesDuration = new PerfCounter();
|
|
|
+ private _renderTargetsDuration = new PerfCounter();
|
|
|
+ public _particlesDuration = new PerfCounter();
|
|
|
+ private _renderDuration = new PerfCounter();
|
|
|
+ public _spritesDuration = new PerfCounter();
|
|
|
+ private _animationRatio = new PerfCounter();
|
|
|
+ public _activeBones = new PerfCounter();
|
|
|
+
|
|
|
private _animationStartDate: number;
|
|
|
public _cachedMaterial: Material;
|
|
|
|
|
@@ -445,7 +453,6 @@
|
|
|
public _activeParticleSystems = new SmartArray<ParticleSystem>(256);
|
|
|
private _activeSkeletons = new SmartArray<Skeleton>(32);
|
|
|
private _softwareSkinnedMeshes = new SmartArray<Mesh>(32);
|
|
|
- public _activeBones = 0;
|
|
|
|
|
|
private _renderingManager: RenderingManager;
|
|
|
private _physicsEngine: PhysicsEngine;
|
|
@@ -584,27 +591,51 @@
|
|
|
}
|
|
|
|
|
|
public getTotalVertices(): number {
|
|
|
+ return this._totalVertices.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get totalVerticesPerfCounter(): PerfCounter {
|
|
|
return this._totalVertices;
|
|
|
}
|
|
|
|
|
|
public getActiveIndices(): number {
|
|
|
+ return this._activeIndices.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get totalActiveIndicesPerfCounter(): PerfCounter {
|
|
|
return this._activeIndices;
|
|
|
}
|
|
|
|
|
|
public getActiveParticles(): number {
|
|
|
+ return this._activeParticles.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get activeParticlesPerfCounter(): PerfCounter {
|
|
|
return this._activeParticles;
|
|
|
}
|
|
|
|
|
|
public getActiveBones(): number {
|
|
|
+ return this._activeBones.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get activeBonesPerfCounter(): PerfCounter {
|
|
|
return this._activeBones;
|
|
|
}
|
|
|
|
|
|
// Stats
|
|
|
public getLastFrameDuration(): number {
|
|
|
+ return this._lastFrameDuration.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get lastFramePerfCounter(): PerfCounter {
|
|
|
return this._lastFrameDuration;
|
|
|
}
|
|
|
|
|
|
public getEvaluateActiveMeshesDuration(): number {
|
|
|
+ return this._evaluateActiveMeshesDuration.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get evaluateActiveMeshesDurationPerfCounter(): PerfCounter {
|
|
|
return this._evaluateActiveMeshesDuration;
|
|
|
}
|
|
|
|
|
@@ -613,22 +644,38 @@
|
|
|
}
|
|
|
|
|
|
public getRenderTargetsDuration(): number {
|
|
|
- return this._renderTargetsDuration;
|
|
|
+ return this._renderTargetsDuration.current;
|
|
|
}
|
|
|
|
|
|
public getRenderDuration(): number {
|
|
|
+ return this._renderDuration.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get renderDurationPerfCounter(): PerfCounter {
|
|
|
return this._renderDuration;
|
|
|
}
|
|
|
|
|
|
public getParticlesDuration(): number {
|
|
|
+ return this._particlesDuration.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get particlesDurationPerfCounter(): PerfCounter {
|
|
|
return this._particlesDuration;
|
|
|
}
|
|
|
|
|
|
public getSpritesDuration(): number {
|
|
|
+ return this._spritesDuration.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public get spriteDuractionPerfCounter(): PerfCounter {
|
|
|
return this._spritesDuration;
|
|
|
}
|
|
|
|
|
|
public getAnimationRatio(): number {
|
|
|
+ return this._animationRatio.current;
|
|
|
+ }
|
|
|
+
|
|
|
+ public animationRatioPerfCounter(): PerfCounter {
|
|
|
return this._animationRatio;
|
|
|
}
|
|
|
|
|
@@ -1774,7 +1821,7 @@
|
|
|
}
|
|
|
|
|
|
// Dispatch
|
|
|
- this._activeIndices += subMesh.indexCount;
|
|
|
+ this._activeIndices.addCount(subMesh.indexCount, false);
|
|
|
this._renderingManager.dispatch(subMesh);
|
|
|
}
|
|
|
}
|
|
@@ -1815,7 +1862,7 @@
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- this._totalVertices += mesh.getTotalVertices();
|
|
|
+ this._totalVertices.addCount(mesh.getTotalVertices(), false);
|
|
|
|
|
|
if (!mesh.isReady() || !mesh.isEnabled()) {
|
|
|
continue;
|
|
@@ -1847,6 +1894,7 @@
|
|
|
}
|
|
|
|
|
|
// Particle systems
|
|
|
+ this._particlesDuration.beginMonitoring();
|
|
|
var beforeParticlesDate = Tools.Now;
|
|
|
if (this.particlesEnabled) {
|
|
|
Tools.StartPerformanceCounter("Particles", this.particleSystems.length > 0);
|
|
@@ -1864,7 +1912,7 @@
|
|
|
}
|
|
|
Tools.EndPerformanceCounter("Particles", this.particleSystems.length > 0);
|
|
|
}
|
|
|
- this._particlesDuration += Tools.Now - beforeParticlesDate;
|
|
|
+ this._particlesDuration.endMonitoring(false);
|
|
|
}
|
|
|
|
|
|
private _activeMesh(mesh: AbstractMesh): void {
|
|
@@ -1915,6 +1963,7 @@
|
|
|
|
|
|
private _renderForCamera(camera: Camera): void {
|
|
|
var engine = this._engine;
|
|
|
+ var startTime = Tools.Now;
|
|
|
|
|
|
this.activeCamera = camera;
|
|
|
|
|
@@ -1934,10 +1983,10 @@
|
|
|
this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
|
|
|
|
|
|
// Meshes
|
|
|
- var beforeEvaluateActiveMeshesDate = Tools.Now;
|
|
|
+ this._evaluateActiveMeshesDuration.beginMonitoring();
|
|
|
Tools.StartPerformanceCounter("Active meshes evaluation");
|
|
|
this._evaluateActiveMeshes();
|
|
|
- this._evaluateActiveMeshesDuration += Tools.Now - beforeEvaluateActiveMeshesDate;
|
|
|
+ this._evaluateActiveMeshesDuration.endMonitoring(false);
|
|
|
Tools.EndPerformanceCounter("Active meshes evaluation");
|
|
|
|
|
|
// Software skinning
|
|
@@ -1948,6 +1997,7 @@
|
|
|
}
|
|
|
|
|
|
// Render targets
|
|
|
+ this._renderTargetsDuration.beginMonitoring();
|
|
|
var beforeRenderTargetDate = Tools.Now;
|
|
|
if (this.renderTargetsEnabled && this._renderTargets.length > 0) {
|
|
|
this._intermediateRendering = true;
|
|
@@ -1966,12 +2016,12 @@
|
|
|
this._renderId++;
|
|
|
engine.restoreDefaultFramebuffer(); // Restore back buffer
|
|
|
}
|
|
|
- this._renderTargetsDuration += Tools.Now - beforeRenderTargetDate;
|
|
|
+ this._renderTargetsDuration.endMonitoring(false);
|
|
|
|
|
|
// Prepare Frame
|
|
|
this.postProcessManager._prepareFrame();
|
|
|
|
|
|
- var beforeRenderDate = Tools.Now;
|
|
|
+ this._renderDuration.beginMonitoring();
|
|
|
// Backgrounds
|
|
|
var layerIndex;
|
|
|
var layer;
|
|
@@ -2024,7 +2074,7 @@
|
|
|
engine.setDepthBuffer(true);
|
|
|
}
|
|
|
|
|
|
- this._renderDuration += Tools.Now - beforeRenderDate;
|
|
|
+ this._renderDuration.endMonitoring(false);
|
|
|
|
|
|
// Finalize frame
|
|
|
this.postProcessManager._finalizeFrame(camera.isIntermediate);
|
|
@@ -2098,17 +2148,17 @@
|
|
|
}
|
|
|
|
|
|
public render(): void {
|
|
|
- var startDate = Tools.Now;
|
|
|
- this._particlesDuration = 0;
|
|
|
- this._spritesDuration = 0;
|
|
|
- this._activeParticles = 0;
|
|
|
- this._renderDuration = 0;
|
|
|
- this._renderTargetsDuration = 0;
|
|
|
- this._evaluateActiveMeshesDuration = 0;
|
|
|
- this._totalVertices = 0;
|
|
|
- this._activeIndices = 0;
|
|
|
- this._activeBones = 0;
|
|
|
- this.getEngine().resetDrawCalls();
|
|
|
+ this._lastFrameDuration.beginMonitoring();
|
|
|
+ this._particlesDuration.fetchNewFrame();
|
|
|
+ this._spritesDuration.fetchNewFrame();
|
|
|
+ this._activeParticles.fetchNewFrame();
|
|
|
+ this._renderDuration.fetchNewFrame();
|
|
|
+ this._renderTargetsDuration.fetchNewFrame();
|
|
|
+ this._evaluateActiveMeshesDuration.fetchNewFrame();
|
|
|
+ this._totalVertices.fetchNewFrame();
|
|
|
+ this._activeIndices.fetchNewFrame();
|
|
|
+ this._activeBones.fetchNewFrame();
|
|
|
+ this.getEngine()._drawCalls.fetchNewFrame();;
|
|
|
this._meshesForIntersections.reset();
|
|
|
this.resetCachedMaterial();
|
|
|
|
|
@@ -2126,7 +2176,7 @@
|
|
|
|
|
|
// Animations
|
|
|
var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
|
|
|
- this._animationRatio = deltaTime * (60.0 / 1000.0);
|
|
|
+ this._animationRatio.addCount(deltaTime * (60.0 / 1000.0), true);
|
|
|
this._animate();
|
|
|
|
|
|
// Physics
|
|
@@ -2140,6 +2190,7 @@
|
|
|
this.onBeforeRenderObservable.notifyObservers(this);
|
|
|
|
|
|
// Customs render targets
|
|
|
+ this._renderTargetsDuration.beginMonitoring();
|
|
|
var beforeRenderTargetDate = Tools.Now;
|
|
|
var engine = this.getEngine();
|
|
|
var currentActiveCamera = this.activeCamera;
|
|
@@ -2172,7 +2223,7 @@
|
|
|
if (this.customRenderTargets.length > 0) { // Restore back buffer
|
|
|
engine.restoreDefaultFramebuffer();
|
|
|
}
|
|
|
- this._renderTargetsDuration += Tools.Now - beforeRenderTargetDate;
|
|
|
+ this._renderTargetsDuration.endMonitoring();
|
|
|
this.activeCamera = currentActiveCamera;
|
|
|
|
|
|
// Procedural textures
|
|
@@ -2257,7 +2308,14 @@
|
|
|
}
|
|
|
|
|
|
Tools.EndPerformanceCounter("Scene rendering");
|
|
|
- this._lastFrameDuration = Tools.Now - startDate;
|
|
|
+ this._lastFrameDuration.endMonitoring();
|
|
|
+ this._totalMeshesCounter.addCount(this.meshes.length, true);
|
|
|
+ this._totalLightsCounter.addCount(this.lights.length, true);
|
|
|
+ this._totalMaterialsCounter.addCount(this.materials.length, true);
|
|
|
+ this._totalTexturesCounter.addCount(this.textures.length, true);
|
|
|
+ this._activeBones.addCount(0, true);
|
|
|
+ this._activeIndices.addCount(0, true);
|
|
|
+ this._activeParticles.addCount(0, true);
|
|
|
}
|
|
|
|
|
|
private _updateAudioParameters() {
|