1 |
- {"ast":null,"code":"import { AbstractEngine } from \"./abstractEngine.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { WebGPUTextureHelper } from \"./WebGPU/webgpuTextureHelper.js\";\nimport { WebGPUPerfCounter } from \"./WebGPU/webgpuPerfCounter.js\";\n\n/**\n * The base engine class for WebGPU\n */\nexport class ThinWebGPUEngine extends AbstractEngine {\n constructor() {\n super(...arguments);\n // TODO WEBGPU remove those variables when code stabilized\n /** @internal */\n this.dbgShowShaderCode = false;\n /** @internal */\n this.dbgSanityChecks = true;\n /** @internal */\n this.dbgVerboseLogsNumFrames = 10;\n /** @internal */\n this.dbgLogIfNotDrawWrapper = true;\n /** @internal */\n this.dbgShowEmptyEnableEffectCalls = true;\n /** @internal */\n this.dbgVerboseLogsForFirstFrames = false;\n /** @internal */\n this._currentRenderPass = null;\n this._snapshotRenderingMode = 0;\n /** @internal */\n this._timestampIndex = 0;\n /** @internal */\n this._debugStackRenderPass = [];\n }\n /**\n * Enables or disables GPU timing measurements.\n * Note that this is only supported if the \"timestamp-query\" extension is enabled in the options.\n */\n get enableGPUTimingMeasurements() {\n return this._timestampQuery.enable;\n }\n set enableGPUTimingMeasurements(enable) {\n if (this._timestampQuery.enable === enable) {\n return;\n }\n this.gpuTimeInFrameForMainPass = enable ? new WebGPUPerfCounter() : undefined;\n this._timestampQuery.enable = enable;\n }\n _currentPassIsMainPass() {\n return this._currentRenderTarget === null;\n }\n /** @internal */\n _endCurrentRenderPass() {\n var _this$_debugPopGroup;\n if (!this._currentRenderPass) {\n return 0;\n }\n if (this._debugStackRenderPass.length !== 0) {\n for (let i = 0; i < this._debugStackRenderPass.length; ++i) {\n this._currentRenderPass.popDebugGroup();\n }\n }\n const currentPassIndex = this._currentPassIsMainPass() ? 2 : 1;\n if (!this._snapshotRendering.endRenderPass(this._currentRenderPass) && !this.compatibilityMode) {\n this._bundleList.run(this._currentRenderPass);\n this._bundleList.reset();\n }\n this._currentRenderPass.end();\n this._timestampQuery.endPass(this._timestampIndex, this._currentRenderTarget && this._currentRenderTarget.gpuTimeInFrame ? this._currentRenderTarget.gpuTimeInFrame : this.gpuTimeInFrameForMainPass);\n this._timestampIndex += 2;\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n var _this$_currentRenderT;\n Logger.Log(\"frame #\" + this._count + \" - \" + (currentPassIndex === 2 ? \"main\" : \"render target\") + \" end pass\" + (currentPassIndex === 1 ? \" - internalTexture.uniqueId=\" + ((_this$_currentRenderT = this._currentRenderTarget) === null || _this$_currentRenderT === void 0 || (_this$_currentRenderT = _this$_currentRenderT.texture) === null || _this$_currentRenderT === void 0 ? void 0 : _this$_currentRenderT.uniqueId) : \"\"));\n }\n }\n (_this$_debugPopGroup = this._debugPopGroup) === null || _this$_debugPopGroup === void 0 || _this$_debugPopGroup.call(this, 0);\n this._currentRenderPass = null;\n return currentPassIndex;\n }\n /**\n * @internal\n */\n _generateMipmaps(texture, commandEncoder) {\n var _commandEncoder;\n commandEncoder = (_commandEncoder = commandEncoder) !== null && _commandEncoder !== void 0 ? _commandEncoder : this._renderEncoder;\n const gpuHardwareTexture = texture._hardwareTexture;\n if (!gpuHardwareTexture) {\n return;\n }\n if (commandEncoder === this._renderEncoder) {\n // We must close the current pass (if any) because we are going to use the render encoder to generate the mipmaps (so, we are going to create a new render pass)\n this._endCurrentRenderPass();\n }\n const format = texture._hardwareTexture.format;\n const mipmapCount = WebGPUTextureHelper.ComputeNumMipmapLevels(texture.width, texture.height);\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log(\"frame #\" + this._count + \" - generate mipmaps - width=\" + texture.width + \", height=\" + texture.height + \", isCube=\" + texture.isCube + \", command encoder=\" + (commandEncoder === this._renderEncoder ? \"render\" : \"copy\"));\n }\n }\n if (texture.isCube) {\n this._textureHelper.generateCubeMipmaps(gpuHardwareTexture, format, mipmapCount, commandEncoder);\n } else {\n this._textureHelper.generateMipmaps(gpuHardwareTexture, format, mipmapCount, 0, texture.is3D, commandEncoder);\n }\n }\n}","map":{"version":3,"names":["AbstractEngine","Logger","WebGPUTextureHelper","WebGPUPerfCounter","ThinWebGPUEngine","constructor","arguments","dbgShowShaderCode","dbgSanityChecks","dbgVerboseLogsNumFrames","dbgLogIfNotDrawWrapper","dbgShowEmptyEnableEffectCalls","dbgVerboseLogsForFirstFrames","_currentRenderPass","_snapshotRenderingMode","_timestampIndex","_debugStackRenderPass","enableGPUTimingMeasurements","_timestampQuery","enable","gpuTimeInFrameForMainPass","undefined","_currentPassIsMainPass","_currentRenderTarget","_endCurrentRenderPass","_this$_debugPopGroup","length","i","popDebugGroup","currentPassIndex","_snapshotRendering","endRenderPass","compatibilityMode","_bundleList","run","reset","end","endPass","gpuTimeInFrame","_count","_this$_currentRenderT","Log","texture","uniqueId","_debugPopGroup","call","_generateMipmaps","commandEncoder","_commandEncoder","_renderEncoder","gpuHardwareTexture","_hardwareTexture","format","mipmapCount","ComputeNumMipmapLevels","width","height","isCube","_textureHelper","generateCubeMipmaps","generateMipmaps","is3D"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/thinWebGPUEngine.js"],"sourcesContent":["import { AbstractEngine } from \"./abstractEngine.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { WebGPUTextureHelper } from \"./WebGPU/webgpuTextureHelper.js\";\nimport { WebGPUPerfCounter } from \"./WebGPU/webgpuPerfCounter.js\";\n\n/**\n * The base engine class for WebGPU\n */\nexport class ThinWebGPUEngine extends AbstractEngine {\n constructor() {\n super(...arguments);\n // TODO WEBGPU remove those variables when code stabilized\n /** @internal */\n this.dbgShowShaderCode = false;\n /** @internal */\n this.dbgSanityChecks = true;\n /** @internal */\n this.dbgVerboseLogsNumFrames = 10;\n /** @internal */\n this.dbgLogIfNotDrawWrapper = true;\n /** @internal */\n this.dbgShowEmptyEnableEffectCalls = true;\n /** @internal */\n this.dbgVerboseLogsForFirstFrames = false;\n /** @internal */\n this._currentRenderPass = null;\n this._snapshotRenderingMode = 0;\n /** @internal */\n this._timestampIndex = 0;\n /** @internal */\n this._debugStackRenderPass = [];\n }\n /**\n * Enables or disables GPU timing measurements.\n * Note that this is only supported if the \"timestamp-query\" extension is enabled in the options.\n */\n get enableGPUTimingMeasurements() {\n return this._timestampQuery.enable;\n }\n set enableGPUTimingMeasurements(enable) {\n if (this._timestampQuery.enable === enable) {\n return;\n }\n this.gpuTimeInFrameForMainPass = enable ? new WebGPUPerfCounter() : undefined;\n this._timestampQuery.enable = enable;\n }\n _currentPassIsMainPass() {\n return this._currentRenderTarget === null;\n }\n /** @internal */\n _endCurrentRenderPass() {\n if (!this._currentRenderPass) {\n return 0;\n }\n if (this._debugStackRenderPass.length !== 0) {\n for (let i = 0; i < this._debugStackRenderPass.length; ++i) {\n this._currentRenderPass.popDebugGroup();\n }\n }\n const currentPassIndex = this._currentPassIsMainPass() ? 2 : 1;\n if (!this._snapshotRendering.endRenderPass(this._currentRenderPass) && !this.compatibilityMode) {\n this._bundleList.run(this._currentRenderPass);\n this._bundleList.reset();\n }\n this._currentRenderPass.end();\n this._timestampQuery.endPass(this._timestampIndex, (this._currentRenderTarget && this._currentRenderTarget.gpuTimeInFrame\n ? this._currentRenderTarget.gpuTimeInFrame\n : this.gpuTimeInFrameForMainPass));\n this._timestampIndex += 2;\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log(\"frame #\" +\n this._count +\n \" - \" +\n (currentPassIndex === 2 ? \"main\" : \"render target\") +\n \" end pass\" +\n (currentPassIndex === 1 ? \" - internalTexture.uniqueId=\" + this._currentRenderTarget?.texture?.uniqueId : \"\"));\n }\n }\n this._debugPopGroup?.(0);\n this._currentRenderPass = null;\n return currentPassIndex;\n }\n /**\n * @internal\n */\n _generateMipmaps(texture, commandEncoder) {\n commandEncoder = commandEncoder ?? this._renderEncoder;\n const gpuHardwareTexture = texture._hardwareTexture;\n if (!gpuHardwareTexture) {\n return;\n }\n if (commandEncoder === this._renderEncoder) {\n // We must close the current pass (if any) because we are going to use the render encoder to generate the mipmaps (so, we are going to create a new render pass)\n this._endCurrentRenderPass();\n }\n const format = texture._hardwareTexture.format;\n const mipmapCount = WebGPUTextureHelper.ComputeNumMipmapLevels(texture.width, texture.height);\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log(\"frame #\" +\n this._count +\n \" - generate mipmaps - width=\" +\n texture.width +\n \", height=\" +\n texture.height +\n \", isCube=\" +\n texture.isCube +\n \", command encoder=\" +\n (commandEncoder === this._renderEncoder ? \"render\" : \"copy\"));\n }\n }\n if (texture.isCube) {\n this._textureHelper.generateCubeMipmaps(gpuHardwareTexture, format, mipmapCount, commandEncoder);\n }\n else {\n this._textureHelper.generateMipmaps(gpuHardwareTexture, format, mipmapCount, 0, texture.is3D, commandEncoder);\n }\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,qBAAqB;AACpD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAASC,iBAAiB,QAAQ,+BAA+B;;AAEjE;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,SAASJ,cAAc,CAAC;EACjDK,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC,GAAGC,SAAS,CAAC;IACnB;IACA;IACA,IAAI,CAACC,iBAAiB,GAAG,KAAK;IAC9B;IACA,IAAI,CAACC,eAAe,GAAG,IAAI;IAC3B;IACA,IAAI,CAACC,uBAAuB,GAAG,EAAE;IACjC;IACA,IAAI,CAACC,sBAAsB,GAAG,IAAI;IAClC;IACA,IAAI,CAACC,6BAA6B,GAAG,IAAI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