UNPKG

playcanvas

Version:

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

41 lines (40 loc) 1.39 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); import { GpuProfiler } from "../gpu-profiler.js"; import { WebgpuQuerySet } from "./webgpu-query-set.js"; class WebgpuGpuProfiler extends GpuProfiler { constructor(device) { super(); __publicField(this, "device"); /** @type {number} */ __publicField(this, "frameGPUMarkerSlot"); this.device = device; this.maxCount = 1024; this.timestampQueriesSet = device.supportsTimestampQuery ? new WebgpuQuerySet(device, true, 2 * this.maxCount) : 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 };