{"ast":null,"code":"import { FrameGraphPass } from \"./Passes/pass.js\";\nimport { FrameGraphRenderPass } from \"./Passes/renderPass.js\";\nimport { FrameGraphCullPass } from \"./Passes/cullPass.js\";\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext.js\";\nimport { FrameGraphContext } from \"./frameGraphContext.js\";\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager.js\";\nimport { Observable } from \"../Misc/observable.js\";\nvar FrameGraphPassType;\n(function (FrameGraphPassType) {\n FrameGraphPassType[FrameGraphPassType[\"Render\"] = 0] = \"Render\";\n FrameGraphPassType[FrameGraphPassType[\"Cull\"] = 1] = \"Cull\";\n FrameGraphPassType[FrameGraphPassType[\"Compute\"] = 2] = \"Compute\";\n})(FrameGraphPassType || (FrameGraphPassType = {}));\n/**\n * Class used to implement a frame graph\n * @experimental\n */\nexport class FrameGraph {\n /**\n * Gets the engine used by the frame graph\n */\n get engine() {\n return this._engine;\n }\n /**\n * Constructs the frame graph\n * @param engine defines the hosting engine\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector\n * @param scene defines the scene the frame graph is associated with\n */\n constructor(engine, debugTextures = false, scene) {\n this._tasks = [];\n this._currentProcessedTask = null;\n /**\n * Observable raised when the node render graph is built\n */\n this.onBuildObservable = new Observable();\n this._engine = engine;\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\n this._passContext = new FrameGraphContext();\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\n }\n /**\n * Gets a task by name\n * @param name Name of the task to get\n * @returns The task or undefined if not found\n */\n getTaskByName(name) {\n return this._tasks.find(t => t.name === name);\n }\n /**\n * Adds a task to the frame graph\n * @param task Task to add\n */\n addTask(task) {\n if (this._currentProcessedTask !== null) {\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\n }\n this._tasks.push(task);\n }\n /**\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\n * @param name The name of the pass\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\n * @returns The render pass created\n */\n addRenderPass(name, whenTaskDisabled = false) {\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled);\n }\n /**\n * Adds a cull pass to a task. This method can only be called during a Task.record execution.\n * @param name The name of the pass\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\n * @returns The cull pass created\n */\n addCullPass(name, whenTaskDisabled = false) {\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled);\n }\n _addPass(name, passType, whenTaskDisabled = false) {\n if (!this._currentProcessedTask) {\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\n }\n let pass;\n switch (passType) {\n case FrameGraphPassType.Render:\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\n break;\n case FrameGraphPassType.Cull:\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\n break;\n default:\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\n break;\n }\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\n return pass;\n }\n /**\n * Builds the frame graph.\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\n */\n build() {\n this.textureManager._releaseTextures(false);\n for (const task of this._tasks) {\n task._reset();\n this._currentProcessedTask = task;\n this.textureManager._isRecordingTask = true;\n task.record();\n this.textureManager._isRecordingTask = false;\n this._currentProcessedTask = null;\n }\n this.textureManager._allocateTextures();\n for (const task of this._tasks) {\n task._checkTask();\n }\n this.onBuildObservable.notifyObservers(this);\n }\n /**\n * Returns a promise that resolves when the frame graph is ready to be executed\n * This method must be called after the graph has been built (FrameGraph.build called)!\n * @param timeout Timeout in ms between retries (default is 16)\n * @returns The promise that resolves when the graph is ready\n */\n whenReadyAsync(timeout = 16) {\n return new Promise(resolve => {\n const checkReady = () => {\n let ready = this._renderContext._isReady();\n for (const task of this._tasks) {\n ready = task.isReady() && ready;\n }\n if (ready) {\n resolve();\n } else {\n setTimeout(checkReady, timeout);\n }\n };\n checkReady();\n });\n }\n /**\n * Executes the frame graph.\n */\n execute() {\n this._renderContext.bindRenderTarget();\n this.textureManager._updateHistoryTextures();\n for (const task of this._tasks) {\n const passes = task._getPasses();\n for (const pass of passes) {\n pass._execute();\n }\n }\n }\n /**\n * Clears the frame graph (remove the tasks and release the textures).\n * The frame graph can be built again after this method is called.\n */\n clear() {\n for (const task of this._tasks) {\n task._reset();\n }\n this._tasks.length = 0;\n this.textureManager._releaseTextures();\n this._currentProcessedTask = null;\n }\n /**\n * Disposes the frame graph\n */\n dispose() {\n this.clear();\n this.textureManager._dispose();\n this._renderContext._dispose();\n }\n}","map":{"version":3,"names":["FrameGraphPass","FrameGraphRenderPass","FrameGraphCullPass","FrameGraphRenderContext","FrameGraphContext","FrameGraphTextureManager","Observable","FrameGraphPassType","FrameGraph","engine","_engine","constructor","debugTextures","scene","_tasks","_currentProcessedTask","onBuildObservable","textureManager","_passContext","_renderContext","getTaskByName","name","find","t","addTask","task","Error","push","addRenderPass","whenTaskDisabled","_addPass","Render","addCullPass","Cull","passType","pass","build","_releaseTextures","_reset","_isRecordingTask","record","_allocateTextures","_checkTask","notifyObservers","whenReadyAsync","timeout","Promise","resolve","checkReady","ready","_isReady","isReady","setTimeout","execute","bindRenderTarget","_updateHistoryTextures","passes","_getPasses","_execute","clear","length","dispose","_dispose"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FrameGraph/frameGraph.js"],"sourcesContent":["import { FrameGraphPass } from \"./Passes/pass.js\";\nimport { FrameGraphRenderPass } from \"./Passes/renderPass.js\";\nimport { FrameGraphCullPass } from \"./Passes/cullPass.js\";\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext.js\";\nimport { FrameGraphContext } from \"./frameGraphContext.js\";\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager.js\";\nimport { Observable } from \"../Misc/observable.js\";\nvar FrameGraphPassType;\n(function (FrameGraphPassType) {\n FrameGraphPassType[FrameGraphPassType[\"Render\"] = 0] = \"Render\";\n FrameGraphPassType[FrameGraphPassType[\"Cull\"] = 1] = \"Cull\";\n FrameGraphPassType[FrameGraphPassType[\"Compute\"] = 2] = \"Compute\";\n})(FrameGraphPassType || (FrameGraphPassType = {}));\n/**\n * Class used to implement a frame graph\n * @experimental\n */\nexport class FrameGraph {\n /**\n * Gets the engine used by the frame graph\n */\n get engine() {\n return this._engine;\n }\n /**\n * Constructs the frame graph\n * @param engine defines the hosting engine\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector\n * @param scene defines the scene the frame graph is associated with\n */\n constructor(engine, debugTextures = false, scene) {\n this._tasks = [];\n this._currentProcessedTask = null;\n /**\n * Observable raised when the node render graph is built\n */\n this.onBuildObservable = new Observable();\n this._engine = engine;\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\n this._passContext = new FrameGraphContext();\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\n }\n /**\n * Gets a task by name\n * @param name Name of the task to get\n * @returns The task or undefined if not found\n */\n getTaskByName(name) {\n return this._tasks.find((t) => t.name === name);\n }\n /**\n * Adds a task to the frame graph\n * @param task Task to add\n */\n addTask(task) {\n if (this._currentProcessedTask !== null) {\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\n }\n this._tasks.push(task);\n }\n /**\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\n * @param name The name of the pass\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\n * @returns The render pass created\n */\n addRenderPass(name, whenTaskDisabled = false) {\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled);\n }\n /**\n * Adds a cull pass to a task. This method can only be called during a Task.record execution.\n * @param name The name of the pass\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\n * @returns The cull pass created\n */\n addCullPass(name, whenTaskDisabled = false) {\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled);\n }\n _addPass(name, passType, whenTaskDisabled = false) {\n if (!this._currentProcessedTask) {\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\n }\n let pass;\n switch (passType) {\n case FrameGraphPassType.Render:\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\n break;\n case FrameGraphPassType.Cull:\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\n break;\n default:\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\n break;\n }\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\n return pass;\n }\n /**\n * Builds the frame graph.\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\n */\n build() {\n this.textureManager._releaseTextures(false);\n for (const task of this._tasks) {\n task._reset();\n this._currentProcessedTask = task;\n this.textureManager._isRecordingTask = true;\n task.record();\n this.textureManager._isRecordingTask = false;\n this._currentProcessedTask = null;\n }\n this.textureManager._allocateTextures();\n for (const task of this._tasks) {\n task._checkTask();\n }\n this.onBuildObservable.notifyObservers(this);\n }\n /**\n * Returns a promise that resolves when the frame graph is ready to be executed\n * This method must be called after the graph has been built (FrameGraph.build called)!\n * @param timeout Timeout in ms between retries (default is 16)\n * @returns The promise that resolves when the graph is ready\n */\n whenReadyAsync(timeout = 16) {\n return new Promise((resolve) => {\n const checkReady = () => {\n let ready = this._renderContext._isReady();\n for (const task of this._tasks) {\n ready = task.isReady() && ready;\n }\n if (ready) {\n resolve();\n }\n else {\n setTimeout(checkReady, timeout);\n }\n };\n checkReady();\n });\n }\n /**\n * Executes the frame graph.\n */\n execute() {\n this._renderContext.bindRenderTarget();\n this.textureManager._updateHistoryTextures();\n for (const task of this._tasks) {\n const passes = task._getPasses();\n for (const pass of passes) {\n pass._execute();\n }\n }\n }\n /**\n * Clears the frame graph (remove the tasks and release the textures).\n * The frame graph can be built again after this method is called.\n */\n clear() {\n for (const task of this._tasks) {\n task._reset();\n }\n this._tasks.length = 0;\n this.textureManager._releaseTextures();\n this._currentProcessedTask = null;\n }\n /**\n * Disposes the frame graph\n */\n dispose() {\n this.clear();\n this.textureManager._dispose();\n this._renderContext._dispose();\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,kBAAkB;AACjD,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,SAASC,UAAU,QAAQ,uBAAuB;AAClD,IAAIC,kBAAkB;AACtB,CAAC,UAAUA,kBAAkB,EAAE;EAC3BA,kBAAkB,CAACA,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;EAC/DA,kBAAkB,CAACA,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;EAC3DA,kBAAkB,CAACA,kBAAkB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;AACrE,CAAC,EAAEA,kBAAkB,KAAKA,kBAAkB,GAAG,CAAC,CAAC,CAAC,CAAC;AACnD;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,CAAC;EACpB;AACJ;AACA;EACI,IAAIC,MAAMA,CAAA,EAAG;IACT,OAAO,IAAI,CAACC,OAAO;EACvB;EACA;AACJ;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAACF,MAAM,EAAEG,aAAa,GAAG,KAAK,EAAEC,KAAK,EAAE;IAC9C,IAAI,CAACC,MAAM,GAAG,EAAE;IAChB,IAAI,CAACC,qBAAqB,GAAG,IAAI;IACjC;AACR;AACA;IACQ,IAAI,CAACC,iBAAiB,GAAG,IAAIV,UAAU,CAAC,CAA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