09888bb6d352f0c2a52d1a38f7dd92df45e2cb475ade935ff6aa1f3759beaeb8.json 15 KB

1
  1. {"ast":null,"code":"import { FrameGraphCullPass } from \"./Passes/cullPass.js\";\nimport { FrameGraphRenderPass } from \"./Passes/renderPass.js\";\n/**\n * Represents a task in a frame graph.\n * @experimental\n */\nexport class FrameGraphTask {\n /**\n * The name of the task.\n */\n get name() {\n return this._name;\n }\n set name(value) {\n this._name = value;\n }\n /**\n * Whether the task is disabled.\n */\n get disabled() {\n return this._disabled;\n }\n set disabled(value) {\n this._disabled = value;\n }\n /**\n * Checks if the task is ready to be executed.\n * @returns True if the task is ready to be executed, else false.\n */\n isReady() {\n return true;\n }\n /**\n * Disposes of the task.\n */\n dispose() {\n this._reset();\n }\n /**\n * Constructs a new frame graph task.\n * @param name The name of the task.\n * @param frameGraph The frame graph this task is associated with.\n */\n constructor(name, frameGraph) {\n this._passes = [];\n this._passesDisabled = [];\n this._disabled = false;\n this.name = name;\n this._frameGraph = frameGraph;\n this._reset();\n }\n /** @internal */\n _reset() {\n this._passes.length = 0;\n this._passesDisabled.length = 0;\n }\n /** @internal */\n _addPass(pass, disabled) {\n if (disabled) {\n this._passesDisabled.push(pass);\n } else {\n this._passes.push(pass);\n }\n }\n /** @internal */\n _checkTask() {\n let outputTexture = null;\n let outputDepthTexture = null;\n let outputObjectList;\n for (const pass of this._passes) {\n const errMsg = pass._isValid();\n if (errMsg) {\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\n }\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\n outputTexture = [];\n for (const handle of handles) {\n if (handle !== undefined) {\n outputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\n }\n }\n outputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\n } else if (FrameGraphCullPass.IsCullPass(pass)) {\n outputObjectList = pass.objectList;\n }\n }\n let disabledOutputTexture = null;\n let disabledOutputTextureHandle = [];\n let disabledOutputDepthTexture = null;\n let disabledOutputObjectList;\n for (const pass of this._passesDisabled) {\n const errMsg = pass._isValid();\n if (errMsg) {\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\n }\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\n disabledOutputTexture = [];\n for (const handle of handles) {\n if (handle !== undefined) {\n disabledOutputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\n }\n }\n disabledOutputTextureHandle = handles;\n disabledOutputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\n } else if (FrameGraphCullPass.IsCullPass(pass)) {\n disabledOutputObjectList = pass.objectList;\n }\n }\n if (this._passesDisabled.length > 0) {\n if (!this._checkSameRenderTarget(outputTexture, disabledOutputTexture)) {\n let ok = true;\n for (const handle of disabledOutputTextureHandle) {\n if (handle !== undefined && !this._frameGraph.textureManager.isHistoryTexture(handle)) {\n ok = false;\n break;\n }\n }\n if (!ok) {\n throw new Error(`The output texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\n }\n }\n if (outputDepthTexture !== disabledOutputDepthTexture) {\n throw new Error(`The output depth texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\n }\n if (outputObjectList !== disabledOutputObjectList) {\n throw new Error(`The output object list of the task \"${this.name}\" is different when it is enabled or disabled.`);\n }\n }\n }\n /** @internal */\n _getPasses() {\n return this.disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;\n }\n _checkSameRenderTarget(src, dst) {\n if (src === null || dst === null) {\n return src === dst;\n }\n if (src.length !== dst.length) {\n return false;\n }\n for (let i = 0; i < src.length; i++) {\n if (src[i] !== dst[i]) {\n return false;\n }\n }\n return true;\n }\n}","map":{"version":3,"names":["FrameGraphCullPass","FrameGraphRenderPass","FrameGraphTask","name","_name","value","disabled","_disabled","isReady","dispose","_reset","constructor","frameGraph","_passes","_passesDisabled","_frameGraph","length","_addPass","pass","push","_checkTask","outputTexture","outputDepthTexture","outputObjectList","errMsg","_isValid","Error","IsRenderPass","handles","Array","isArray","renderTarget","handle","undefined","textureManager","getTextureFromHandle","renderTargetDepth","IsCullPass","objectList","disabledOutputTexture","disabledOutputTextureHandle","disabledOutputDepthTexture","disabledOutputObjectList","_checkSameRenderTarget","ok","isHistoryTexture","_getPasses","src","dst","i"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FrameGraph/frameGraphTask.js"],"sourcesContent":["import { FrameGraphCullPass } from \"./Passes/cullPass.js\";\nimport { FrameGraphRenderPass } from \"./Passes/renderPass.js\";\n/**\n * Represents a task in a frame graph.\n * @experimental\n */\nexport class FrameGraphTask {\n /**\n * The name of the task.\n */\n get name() {\n return this._name;\n }\n set name(value) {\n this._name = value;\n }\n /**\n * Whether the task is disabled.\n */\n get disabled() {\n return this._disabled;\n }\n set disabled(value) {\n this._disabled = value;\n }\n /**\n * Checks if the task is ready to be executed.\n * @returns True if the task is ready to be executed, else false.\n */\n isReady() {\n return true;\n }\n /**\n * Disposes of the task.\n */\n dispose() {\n this._reset();\n }\n /**\n * Constructs a new frame graph task.\n * @param name The name of the task.\n * @param frameGraph The frame graph this task is associated with.\n */\n constructor(name, frameGraph) {\n this._passes = [];\n this._passesDisabled = [];\n this._disabled = false;\n this.name = name;\n this._frameGraph = frameGraph;\n this._reset();\n }\n /** @internal */\n _reset() {\n this._passes.length = 0;\n this._passesDisabled.length = 0;\n }\n /** @internal */\n _addPass(pass, disabled) {\n if (disabled) {\n this._passesDisabled.push(pass);\n }\n else {\n this._passes.push(pass);\n }\n }\n /** @internal */\n _checkTask() {\n let outputTexture = null;\n let outputDepthTexture = null;\n let outputObjectList;\n for (const pass of this._passes) {\n const errMsg = pass._isValid();\n if (errMsg) {\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\n }\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\n outputTexture = [];\n for (const handle of handles) {\n if (handle !== undefined) {\n outputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\n }\n }\n outputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\n }\n else if (FrameGraphCullPass.IsCullPass(pass)) {\n outputObjectList = pass.objectList;\n }\n }\n let disabledOutputTexture = null;\n let disabledOutputTextureHandle = [];\n let disabledOutputDepthTexture = null;\n let disabledOutputObjectList;\n for (const pass of this._passesDisabled) {\n const errMsg = pass._isValid();\n if (errMsg) {\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\n }\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\n disabledOutputTexture = [];\n for (const handle of handles) {\n if (handle !== undefined) {\n disabledOutputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\n }\n }\n disabledOutputTextureHandle = handles;\n disabledOutputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\n }\n else if (FrameGraphCullPass.IsCullPass(pass)) {\n disabledOutputObjectList = pass.objectList;\n }\n }\n if (this._passesDisabled.length > 0) {\n if (!this._checkSameRenderTarget(outputTexture, disabledOutputTexture)) {\n let ok = true;\n for (const handle of disabledOutputTextureHandle) {\n if (handle !== undefined && !this._frameGraph.textureManager.isHistoryTexture(handle)) {\n ok = false;\n break;\n }\n }\n if (!ok) {\n throw new Error(`The output texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\n }\n }\n if (outputDepthTexture !== disabledOutputDepthTexture) {\n throw new Error(`The output depth texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\n }\n if (outputObjectList !== disabledOutputObjectList) {\n throw new Error(`The output object list of the task \"${this.name}\" is different when it is enabled or disabled.`);\n }\n }\n }\n /** @internal */\n _getPasses() {\n return this.disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;\n }\n _checkSameRenderTarget(src, dst) {\n if (src === null || dst === null) {\n return src === dst;\n }\n if (src.length !== dst.length) {\n return false;\n }\n for (let i = 0; i < src.length; i++) {\n if (src[i] !== dst[i]) {\n return false;\n }\n }\n return true;\n }\n}\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,CAAC;EACxB;AACJ;AACA;EACI,IAAIC,IAAIA,CAAA,EAAG;IACP,OAAO,IAAI,CAACC,KAAK;EACrB;EACA,IAAID,IAAIA,CAACE,KAAK,EAAE;IACZ,IAAI,CAACD,KAAK,GAAGC,KAAK;EACtB;EACA;AACJ;AACA;EACI,IAAIC,QAAQA,CAAA,EAAG;IACX,OAAO,IAAI,CAACC,SAAS;EACzB;EACA,IAAID,QAAQA,CAACD,KAAK,EAAE;IAChB,IAAI,CAACE,SAAS,GAAGF,KAAK;EAC1B;EACA;AACJ;AACA;AACA;EACIG,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACIC,OAAOA,CAAA,EAAG;IACN,IAAI,CAACC,MAAM,CAAC,CAAC;EACjB;EACA;AACJ;AACA;AACA;AACA;EACIC,WAAWA,CAACR,IAAI,EAAES,UAAU,EAAE;IAC1B,IAAI,CAACC,OAAO,GAAG,EAAE;IACjB,IAAI,CAACC,eAAe,GAAG,EAAE;IACzB,IAAI,CAACP,SAAS,GAAG,KAAK;IACtB,IAAI,CAACJ,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACY,WAAW,GAAGH,UAAU;IAC7B,IAAI,CAACF,MAAM,CAAC,CAAC;EACjB;EACA;EACAA,MAAMA,CAAA,EAAG;IACL,IAAI,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