UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

98 lines (95 loc) 2.17 kB
import { getApplication } from './globals.js'; class ApplicationStats { get scene() { return getApplication().scene._stats; } get lightmapper() { return getApplication().lightmapper?.stats; } get batcher() { const batcher = getApplication()._batcher; return batcher ? batcher._stats : null; } frameEnd() { this.frame.gsplatSort = 0; } constructor(device){ this.frame = { fps: 0, ms: 0, dt: 0, updateStart: 0, updateTime: 0, renderStart: 0, renderTime: 0, physicsStart: 0, physicsTime: 0, scriptUpdateStart: 0, scriptUpdate: 0, scriptPostUpdateStart: 0, scriptPostUpdate: 0, animUpdateStart: 0, animUpdate: 0, cullTime: 0, sortTime: 0, skinTime: 0, morphTime: 0, instancingTime: 0, triangles: 0, gsplats: 0, gsplatSort: 0, gsplatBufferCopy: 0, otherPrimitives: 0, shaders: 0, materials: 0, cameras: 0, shadowMapUpdates: 0, shadowMapTime: 0, depthMapTime: 0, forwardTime: 0, lightClustersTime: 0, lightClusters: 0, _timeToCountFrames: 0, _fpsAccum: 0 }; this.drawCalls = { forward: 0, depth: 0, shadow: 0, immediate: 0, misc: 0, total: 0, skinned: 0, instanced: 0, removedByInstancing: 0 }; this.misc = { renderTargetCreationTime: 0 }; this.particles = { updatesPerFrame: 0, _updatesPerFrame: 0, frameTime: 0, _frameTime: 0 }; this.shaders = device._shaderStats; this.vram = device._vram; this.gpu = device.gpuProfiler?.passTimings ?? new Map(); Object.defineProperty(this.vram, 'totalUsed', { get: function() { return this.tex + this.vb + this.ib + this.ub + this.sb; } }); Object.defineProperty(this.vram, 'geom', { get: function() { return this.vb + this.ib; } }); Object.defineProperty(this.vram, 'buffers', { get: function() { return this.ub + this.sb; } }); } } export { ApplicationStats };