@animech-public/playcanvas
Version:
PlayCanvas WebGL game engine
2 lines (1 loc) • 937 B
JavaScript
import{TRACEID_GPU_TIMINGS as e}from"../../core/constants.js";import{Tracing as t}from"../../core/tracing.js";class s{constructor(){this.frameAllocations=[],this.pastFrameAllocations=new Map,this._enabled=!1,this._enableRequest=!1,this._frameTime=0}loseContext(){this.pastFrameAllocations.clear()}set enabled(e){this._enableRequest=e}get enabled(){return this._enableRequest}processEnableRequest(){this._enableRequest!==this._enabled&&(this._enabled=this._enableRequest,this._enabled||(this._frameTime=0))}request(e){this.pastFrameAllocations.set(e,this.frameAllocations),this.frameAllocations=[]}report(s,a){if(a){const l=this.pastFrameAllocations.get(s);if(a.length>0&&(this._frameTime=a[0]),t.get(e))for(let e=0;e<l.length;++e)l[e]}this.pastFrameAllocations.delete(s)}getSlot(e){const t=this.frameAllocations.length;return this.frameAllocations.push(e),t}get slotCount(){return this.frameAllocations.length}}export{s as GpuProfiler};