d1ceeab2fda7ff86df1a15a257ce0caa0620e3fd71c26a073f625c5edb984432.json 7.6 KB

1
  1. {"ast":null,"code":"/** @internal */\nexport class WebGPUSnapshotRendering {\n constructor(engine, renderingMode, bundleList) {\n this._record = false;\n this._play = false;\n this._playBundleListIndex = 0;\n this._allBundleLists = [];\n this._enabled = false;\n this._engine = engine;\n this._mode = renderingMode;\n this._bundleList = bundleList;\n }\n get enabled() {\n return this._enabled;\n }\n get play() {\n return this._play;\n }\n get record() {\n return this._record;\n }\n set enabled(activate) {\n this._allBundleLists.length = 0;\n this._record = this._enabled = activate;\n this._play = false;\n if (activate) {\n this._modeSaved = this._mode;\n this._mode = 0; // need to reset to standard for the recording pass to avoid some code being bypassed\n }\n }\n get mode() {\n return this._mode;\n }\n set mode(mode) {\n if (this._record) {\n this._modeSaved = mode;\n } else {\n this._mode = mode;\n }\n }\n endRenderPass(currentRenderPass) {\n if (!this._record && !this._play) {\n // Snapshot rendering mode is not enabled\n return false;\n }\n let bundleList;\n if (this._record) {\n bundleList = this._bundleList.clone();\n this._allBundleLists.push(bundleList);\n this._bundleList.reset();\n } else {\n // We are playing the snapshot\n if (this._playBundleListIndex >= this._allBundleLists.length) {\n throw new Error(`Invalid playBundleListIndex! Your snapshot is no longer valid for the current frame, you should recreate a new one. playBundleListIndex=${this._playBundleListIndex}, allBundleLists.length=${this._allBundleLists.length}}`);\n }\n bundleList = this._allBundleLists[this._playBundleListIndex++];\n }\n bundleList.run(currentRenderPass);\n if (this._mode === 1) {\n this._engine._reportDrawCall(bundleList.numDrawCalls);\n }\n return true;\n }\n endFrame() {\n if (this._record) {\n // We stop recording and switch to replay mode for the next frames\n this._record = false;\n this._play = true;\n this._mode = this._modeSaved;\n }\n this._playBundleListIndex = 0;\n }\n reset() {\n if (this._record) {\n this._mode = this._modeSaved;\n }\n this.enabled = false;\n this.enabled = true;\n }\n}","map":{"version":3,"names":["WebGPUSnapshotRendering","constructor","engine","renderingMode","bundleList","_record","_play","_playBundleListIndex","_allBundleLists","_enabled","_engine","_mode","_bundleList","enabled","play","record","activate","length","_modeSaved","mode","endRenderPass","currentRenderPass","clone","push","reset","Error","run","_reportDrawCall","numDrawCalls","endFrame"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/WebGPU/webgpuSnapshotRendering.js"],"sourcesContent":["\n/** @internal */\nexport class WebGPUSnapshotRendering {\n constructor(engine, renderingMode, bundleList) {\n this._record = false;\n this._play = false;\n this._playBundleListIndex = 0;\n this._allBundleLists = [];\n this._enabled = false;\n this._engine = engine;\n this._mode = renderingMode;\n this._bundleList = bundleList;\n }\n get enabled() {\n return this._enabled;\n }\n get play() {\n return this._play;\n }\n get record() {\n return this._record;\n }\n set enabled(activate) {\n this._allBundleLists.length = 0;\n this._record = this._enabled = activate;\n this._play = false;\n if (activate) {\n this._modeSaved = this._mode;\n this._mode = 0; // need to reset to standard for the recording pass to avoid some code being bypassed\n }\n }\n get mode() {\n return this._mode;\n }\n set mode(mode) {\n if (this._record) {\n this._modeSaved = mode;\n }\n else {\n this._mode = mode;\n }\n }\n endRenderPass(currentRenderPass) {\n if (!this._record && !this._play) {\n // Snapshot rendering mode is not enabled\n return false;\n }\n let bundleList;\n if (this._record) {\n bundleList = this._bundleList.clone();\n this._allBundleLists.push(bundleList);\n this._bundleList.reset();\n }\n else {\n // We are playing the snapshot\n if (this._playBundleListIndex >= this._allBundleLists.length) {\n throw new Error(`Invalid playBundleListIndex! Your snapshot is no longer valid for the current frame, you should recreate a new one. playBundleListIndex=${this._playBundleListIndex}, allBundleLists.length=${this._allBundleLists.length}}`);\n }\n bundleList = this._allBundleLists[this._playBundleListIndex++];\n }\n bundleList.run(currentRenderPass);\n if (this._mode === 1) {\n this._engine._reportDrawCall(bundleList.numDrawCalls);\n }\n return true;\n }\n endFrame() {\n if (this._record) {\n // We stop recording and switch to replay mode for the next frames\n this._record = false;\n this._play = true;\n this._mode = this._modeSaved;\n }\n this._playBundleListIndex = 0;\n }\n reset() {\n if (this._record) {\n this._mode = this._modeSaved;\n }\n this.enabled = false;\n this.enabled = true;\n }\n}\n"],"mappings":"AACA;AACA,OAAO,MAAMA,uBAAuB,CAAC;EACjCC,WAAWA,CAACC,MAAM,EAAEC,aAAa,EAAEC,UAAU,EAAE;IAC3C,IAAI,CAACC,OAAO,GAAG,KAAK;IACpB,IAAI,CAACC,KAAK,GAAG,KAAK;IAClB,IAAI,CAACC,oBAAoB,GAAG,CAAC;IAC7B,IAAI,CAACC,eAAe,GAAG,EAAE;IACzB,IAAI,CAACC,QAAQ,GAAG,KAAK;IACrB,IAAI,CAACC,OAAO,GAAGR,MAAM;IACrB,IAAI,CAACS,KAAK,GAAGR,aAAa;IAC1B,IAAI,CAACS,WAAW,GAAGR,UAAU;EACjC;EACA,IAAIS,OAAOA,CAAA,EAAG;IACV,OAAO,IAAI,CAACJ,QAAQ;EACxB;EACA,IAAIK,IAAIA,CAAA,EAAG;IACP,OAAO,IAAI,CAACR,KAAK;EACrB;EACA,IAAIS,MAAMA,CAAA,EAAG;IACT,OAAO,IAAI,CAACV,OAAO;EACvB;EACA,IAAIQ,OAAOA,CAACG,QAAQ,EAAE;IAClB,IAAI,CAACR,eAAe,CAACS,MAAM,GAAG,CAAC;IAC/B,IAAI,CAACZ,OAAO,GAAG,IAAI,CAACI,QAAQ,GAAGO,QAAQ;IACvC,IAAI,CAACV,KAAK,GAAG,KAAK;IAClB,IAAIU,QAAQ,EAAE;MACV,IAAI,CAACE,UAAU,GAAG,IAAI,CAACP,KAAK;MAC5B,IAAI,CAACA,KAAK,GAAG,CAAC,CAAC,CAAC;IACpB;EACJ;EACA,IAAIQ,IAAIA,CAAA,EAAG;IACP,OAAO,IAAI,CAACR,KAAK;EACrB;EACA,IAAIQ,IAAIA,CAACA,IAAI,EAAE;IACX,IAAI,IAAI,CAACd,OAAO,EAAE;MACd,IAAI,CAACa,UAAU,GAAGC,IAAI;IAC1B,CAAC,MACI;MACD,IAAI,CAACR,KAAK,GAAGQ,IAAI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O,GAAG,KAAK;IACpB,IAAI,CAACA,OAAO,GAAG,IAAI;EACvB;AACJ","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}