UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

34 lines (31 loc) 922 B
import { GpuProfiler } from '../gpu-profiler.js'; import { WebgpuQuerySet } from './webgpu-query-set.js'; class WebgpuGpuProfiler extends GpuProfiler { constructor(device){ super(); this.device = device; this.timestampQueriesSet = device.supportsTimestampQuery ? new WebgpuQuerySet(device, true, 512) : null; } destroy() { this.timestampQueriesSet?.destroy(); this.timestampQueriesSet = null; } frameStart() { this.processEnableRequest(); } frameEnd() { if (this._enabled) { this.timestampQueriesSet?.resolve(this.slotCount * 2); } } request() { if (this._enabled) { const renderVersion = this.device.renderVersion; this.timestampQueriesSet?.request(this.slotCount, renderVersion).then((results)=>{ this.report(results.renderVersion, results.timings); }); super.request(renderVersion); } } } export { WebgpuGpuProfiler };