{"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { PerfCounter } from \"../../Misc/perfCounter.js\";\nimport { WebGPUQuerySet } from \"./webgpuQuerySet.js\";\nimport { Logger } from \"../../Misc/logger.js\";\n/** @internal */\nexport class WebGPUTimestampQuery {\n get gpuFrameTimeCounter() {\n return this._gpuFrameTimeCounter;\n }\n constructor(engine, device, bufferManager) {\n this._enabled = false;\n this._gpuFrameTimeCounter = new PerfCounter();\n this._measureDurationState = 0;\n this._engine = engine;\n this._device = device;\n this._bufferManager = bufferManager;\n }\n get enable() {\n return this._enabled;\n }\n set enable(value) {\n if (this._enabled === value) {\n return;\n }\n this._enabled = value;\n this._measureDurationState = 0;\n if (value) {\n try {\n this._measureDuration = new WebGPUDurationMeasure(this._engine, this._device, this._bufferManager, 2000, \"QuerySet_TimestampQuery\");\n } catch (e) {\n this._enabled = false;\n Logger.Error(\"Could not create a WebGPUDurationMeasure!\\nError: \" + e.message + \"\\nMake sure timestamp query is supported and enabled in your browser.\");\n return;\n }\n } else {\n this._measureDuration.dispose();\n }\n }\n startFrame(commandEncoder) {\n if (this._enabled && this._measureDurationState === 0) {\n this._measureDuration.start(commandEncoder);\n this._measureDurationState = 1;\n }\n }\n endFrame(commandEncoder) {\n if (this._measureDurationState === 1) {\n this._measureDurationState = 2;\n this._measureDuration.stop(commandEncoder).then(duration => {\n if (duration !== null && duration >= 0) {\n this._gpuFrameTimeCounter.fetchNewFrame();\n this._gpuFrameTimeCounter.addCount(duration, true);\n }\n this._measureDurationState = 0;\n });\n }\n }\n startPass(descriptor, index) {\n if (this._enabled) {\n this._measureDuration.startPass(descriptor, index);\n } else {\n descriptor.timestampWrites = undefined;\n }\n }\n endPass(index, gpuPerfCounter) {\n if (!this._enabled || !gpuPerfCounter) {\n return;\n }\n const currentFrameId = this._engine.frameId;\n this._measureDuration.stopPass(index).then(duration_ => {\n gpuPerfCounter._addDuration(currentFrameId, duration_ !== null && duration_ > 0 ? duration_ : 0);\n });\n }\n dispose() {\n var _this$_measureDuratio;\n (_this$_measureDuratio = this._measureDuration) === null || _this$_measureDuratio === void 0 || _this$_measureDuratio.dispose();\n }\n}\n/** @internal */\nexport class WebGPUDurationMeasure {\n constructor(engine, device, bufferManager, count = 2, querySetLabel) {\n this._count = count;\n this._querySet = new WebGPUQuerySet(engine, count, \"timestamp\" /* WebGPUConstants.QueryType.Timestamp */, device, bufferManager, true, querySetLabel);\n }\n start(encoder) {\n var _encoder$writeTimesta;\n (_encoder$writeTimesta = encoder.writeTimestamp) === null || _encoder$writeTimesta === void 0 || _encoder$writeTimesta.call(encoder, this._querySet.querySet, 0);\n }\n stop(encoder) {\n var _this = this;\n return _asyncToGenerator(function* () {\n var _encoder$writeTimesta2;\n (_encoder$writeTimesta2 = encoder.writeTimestamp) === null || _encoder$writeTimesta2 === void 0 || _encoder$writeTimesta2.call(encoder, _this._querySet.querySet, 1);\n return encoder.writeTimestamp ? _this._querySet.readTwoValuesAndSubtract(0) : 0;\n })();\n }\n startPass(descriptor, index) {\n if (index + 3 > this._count) {\n throw new Error(\"WebGPUDurationMeasure: index out of range (\" + index + \")\");\n }\n descriptor.timestampWrites = {\n querySet: this._querySet.querySet,\n beginningOfPassWriteIndex: index + 2,\n endOfPassWriteIndex: index + 3\n };\n }\n stopPass(index) {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n return _this2._querySet.readTwoValuesAndSubtract(index + 2);\n })();\n }\n dispose() {\n this._querySet.dispose();\n }\n}","map":{"version":3,"names":["PerfCounter","WebGPUQuerySet","Logger","WebGPUTimestampQuery","gpuFrameTimeCounter","_gpuFrameTimeCounter","constructor","engine","device","bufferManager","_enabled","_measureDurationState","_engine","_device","_bufferManager","enable","value","_measureDuration","WebGPUDurationMeasure","e","Error","message","dispose","startFrame","commandEncoder","start","endFrame","stop","then","duration","fetchNewFrame","addCount","startPass","descriptor","index","timestampWrites","undefined","endPass","gpuPerfCounter","currentFrameId","frameId","stopPass","duration_","_addDuration","_this$_measureDuratio","count","querySetLabel","_count","_querySet","encoder","_encoder$writeTimesta","writeTimestamp","call","querySet","_this","_asyncToGenerator","_encoder$writeTimesta2","readTwoValuesAndSubtract","beginningOfPassWriteIndex","endOfPassWriteIndex","_this2"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/WebGPU/webgpuTimestampQuery.js"],"sourcesContent":["import { PerfCounter } from \"../../Misc/perfCounter.js\";\nimport { WebGPUQuerySet } from \"./webgpuQuerySet.js\";\nimport { Logger } from \"../../Misc/logger.js\";\n/** @internal */\nexport class WebGPUTimestampQuery {\n get gpuFrameTimeCounter() {\n return this._gpuFrameTimeCounter;\n }\n constructor(engine, device, bufferManager) {\n this._enabled = false;\n this._gpuFrameTimeCounter = new PerfCounter();\n this._measureDurationState = 0;\n this._engine = engine;\n this._device = device;\n this._bufferManager = bufferManager;\n }\n get enable() {\n return this._enabled;\n }\n set enable(value) {\n if (this._enabled === value) {\n return;\n }\n this._enabled = value;\n this._measureDurationState = 0;\n if (value) {\n try {\n this._measureDuration = new WebGPUDurationMeasure(this._engine, this._device, this._bufferManager, 2000, \"QuerySet_TimestampQuery\");\n }\n catch (e) {\n this._enabled = false;\n Logger.Error(\"Could not create a WebGPUDurationMeasure!\\nError: \" + e.message + \"\\nMake sure timestamp query is supported and enabled in your browser.\");\n return;\n }\n }\n else {\n this._measureDuration.dispose();\n }\n }\n startFrame(commandEncoder) {\n if (this._enabled && this._measureDurationState === 0) {\n this._measureDuration.start(commandEncoder);\n this._measureDurationState = 1;\n }\n }\n endFrame(commandEncoder) {\n if (this._measureDurationState === 1) {\n this._measureDurationState = 2;\n this._measureDuration.stop(commandEncoder).then((duration) => {\n if (duration !== null && duration >= 0) {\n this._gpuFrameTimeCounter.fetchNewFrame();\n this._gpuFrameTimeCounter.addCount(duration, true);\n }\n this._measureDurationState = 0;\n });\n }\n }\n startPass(descriptor, index) {\n if (this._enabled) {\n this._measureDuration.startPass(descriptor, index);\n }\n else {\n descriptor.timestampWrites = undefined;\n }\n }\n endPass(index, gpuPerfCounter) {\n if (!this._enabled || !gpuPerfCounter) {\n return;\n }\n const currentFrameId = this._engine.frameId;\n this._measureDuration.stopPass(index).then((duration_) => {\n gpuPerfCounter._addDuration(currentFrameId, duration_ !== null && duration_ > 0 ? duration_ : 0);\n });\n }\n dispose() {\n this._measureDuration?.dispose();\n }\n}\n/** @internal */\nexport class WebGPUDurationMeasure {\n constructor(engine, device, bufferManager, count = 2, querySetLabel) {\n this._count = count;\n this._querySet = new WebGPUQuerySet(engine, count, \"timestamp\" /* WebGPUConstants.QueryType.Timestamp */, device, bufferManager, true, querySetLabel);\n }\n start(encoder) {\n encoder.writeTimestamp?.(this._querySet.querySet, 0);\n }\n async stop(encoder) {\n encoder.writeTimestamp?.(this._querySet.querySet, 1);\n return encoder.writeTimestamp ? this._querySet.readTwoValuesAndSubtract(0) : 0;\n }\n startPass(descriptor, index) {\n if (index + 3 > this._count) {\n throw new Error(\"WebGPUDurationMeasure: index out of range (\" + index + \")\");\n }\n descriptor.timestampWrites = {\n querySet: this._querySet.querySet,\n beginningOfPassWriteIndex: index + 2,\n endOfPassWriteIndex: index + 3,\n };\n }\n async stopPass(index) {\n return this._querySet.readTwoValuesAndSubtract(index + 2);\n }\n dispose() {\n this._querySet.dispose();\n }\n}\n"],"mappings":";AAAA,SAASA,WAAW,QAAQ,2BAA2B;AACvD,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAC9B,IAAIC,mBAAmBA,CAAA,EAAG;IACtB,OAAO,IAAI,CAACC,oBAAoB;EACpC;EACAC,WAAWA,CAACC,MAAM,EAAEC,MAAM,EAAEC,aAAa,EAAE;IACvC,IAAI,CAACC,QAAQ,GAAG,KAAK;IACrB,IAAI,CAACL,oBAAoB,GAAG,IAAIL,WAAW,CAAC,CAAC;I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