@onerjs/core 8.32.6 → 8.32.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/AudioV2/abstractAudio/abstractSoundSource.js +12 -4
  2. package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
  3. package/Engines/abstractEngine.js +2 -2
  4. package/Engines/abstractEngine.js.map +1 -1
  5. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
  6. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
  7. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +18 -0
  8. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +105 -15
  9. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  10. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +7 -7
  11. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  12. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +1 -1
  13. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
  14. package/FrameGraph/Node/nodeRenderGraphBlock.js +4 -0
  15. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  16. package/FrameGraph/Passes/pass.d.ts +11 -2
  17. package/FrameGraph/Passes/pass.js +14 -2
  18. package/FrameGraph/Passes/pass.js.map +1 -1
  19. package/FrameGraph/Passes/renderPass.d.ts +4 -2
  20. package/FrameGraph/Passes/renderPass.js +5 -2
  21. package/FrameGraph/Passes/renderPass.js.map +1 -1
  22. package/FrameGraph/Tasks/Layers/baseLayerTask.js +27 -31
  23. package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
  24. package/FrameGraph/Tasks/Misc/lightingVolumeTask.d.ts +1 -0
  25. package/FrameGraph/Tasks/Misc/lightingVolumeTask.js.map +1 -1
  26. package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.d.ts +1 -2
  27. package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js +10 -2
  28. package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js.map +1 -1
  29. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +1 -4
  30. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js +7 -4
  31. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -1
  32. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +41 -1
  33. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +122 -0
  34. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  35. package/FrameGraph/Tasks/Texture/clearTextureTask.js +6 -4
  36. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  37. package/FrameGraph/frameGraph.d.ts +1 -2
  38. package/FrameGraph/frameGraph.js +5 -2
  39. package/FrameGraph/frameGraph.js.map +1 -1
  40. package/FrameGraph/frameGraphRenderTarget.js +1 -0
  41. package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
  42. package/FrameGraph/frameGraphTask.d.ts +3 -1
  43. package/FrameGraph/frameGraphTask.js +11 -0
  44. package/FrameGraph/frameGraphTask.js.map +1 -1
  45. package/FrameGraph/frameGraphTypes.d.ts +8 -0
  46. package/FrameGraph/frameGraphTypes.js.map +1 -1
  47. package/Lights/lightingVolume.d.ts +1 -0
  48. package/Lights/lightingVolume.js +14 -13
  49. package/Lights/lightingVolume.js.map +1 -1
  50. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +9 -0
  51. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +66 -22
  52. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  53. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +3 -6
  54. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
  55. package/Materials/Node/Blocks/triPlanarBlock.d.ts +1 -0
  56. package/Materials/Node/Blocks/triPlanarBlock.js +33 -4
  57. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  58. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +10 -5
  59. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +17 -16
  60. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  61. package/Rendering/depthPeelingRenderer.d.ts +7 -78
  62. package/Rendering/depthPeelingRenderer.js +12 -398
  63. package/Rendering/depthPeelingRenderer.js.map +1 -1
  64. package/Rendering/depthPeelingSceneComponent.d.ts +3 -3
  65. package/Rendering/depthPeelingSceneComponent.js.map +1 -1
  66. package/Rendering/depthRenderer.js +9 -1
  67. package/Rendering/depthRenderer.js.map +1 -1
  68. package/Rendering/index.d.ts +1 -0
  69. package/Rendering/index.js +1 -0
  70. package/Rendering/index.js.map +1 -1
  71. package/Rendering/objectRenderer.d.ts +20 -0
  72. package/Rendering/objectRenderer.js +17 -1
  73. package/Rendering/objectRenderer.js.map +1 -1
  74. package/Rendering/renderingGroup.d.ts +10 -3
  75. package/Rendering/renderingGroup.js +24 -13
  76. package/Rendering/renderingGroup.js.map +1 -1
  77. package/Rendering/renderingManager.d.ts +6 -2
  78. package/Rendering/renderingManager.js +8 -2
  79. package/Rendering/renderingManager.js.map +1 -1
  80. package/Rendering/thinDepthPeelingRenderer.d.ts +120 -0
  81. package/Rendering/thinDepthPeelingRenderer.js +469 -0
  82. package/Rendering/thinDepthPeelingRenderer.js.map +1 -0
  83. package/Shaders/ShadersInclude/gaussianSplatting.js +1 -1
  84. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  85. package/Shaders/gaussianSplatting.vertex.js +2 -2
  86. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  87. package/Shaders/gaussianSplattingDepth.fragment.js +9 -2
  88. package/Shaders/gaussianSplattingDepth.fragment.js.map +1 -1
  89. package/Shaders/gaussianSplattingDepth.vertex.js +13 -2
  90. package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
  91. package/Shaders/oitFinalSimpleBlend.fragment.d.ts +5 -0
  92. package/Shaders/oitFinalSimpleBlend.fragment.js +12 -0
  93. package/Shaders/oitFinalSimpleBlend.fragment.js.map +1 -0
  94. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +1 -5
  95. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  96. package/ShadersWGSL/gaussianSplatting.vertex.js +2 -2
  97. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  98. package/ShadersWGSL/gaussianSplattingDepth.fragment.js +12 -3
  99. package/ShadersWGSL/gaussianSplattingDepth.fragment.js.map +1 -1
  100. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +13 -2
  101. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  102. package/ShadersWGSL/oitFinalSimpleBlend.fragment.d.ts +5 -0
  103. package/ShadersWGSL/oitFinalSimpleBlend.fragment.js +13 -0
  104. package/ShadersWGSL/oitFinalSimpleBlend.fragment.js.map +1 -0
  105. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAClD,OAAO,EAAE,kBAAkB,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CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene, AbstractEngine, FrameGraphTask, Nullable, NodeRenderGraph, IDisposable } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphObjectListPass } from \"./Passes/objectListPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { _RetryWithInterval } from \"core/Misc/timingTools\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { UniqueIdGenerator } from \"core/Misc/uniqueIdGenerator\";\r\n\r\nimport \"core/Engines/Extensions/engine.multiRender\";\r\nimport \"core/Engines/WebGPU/Extensions/engine.multiRender\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n ObjectList = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph implements IDisposable {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private readonly _initAsyncPromises: Promise<void>[] = [];\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\r\n\r\n /**\r\n * Name of the frame graph\r\n */\r\n public name = \"Frame Graph\";\r\n\r\n /**\r\n * Gets the unique id of the frame graph\r\n */\r\n public readonly uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)\r\n */\r\n public optimizeTextureAllocation = true;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the scene used by the frame graph\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the list of tasks in the frame graph\r\n */\r\n public get tasks() {\r\n return this._tasks;\r\n }\r\n\r\n /**\r\n * Indicates whether the execution of the frame graph is paused (default is false)\r\n */\r\n public pausedExecution = false;\r\n\r\n /**\r\n * Gets the node render graph linked to the frame graph (if any)\r\n * @returns the linked node render graph or null if none\r\n */\r\n public getLinkedNodeRenderGraph(): Nullable<NodeRenderGraph> {\r\n return this._linkedNodeRenderGraph;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param scene defines the scene the frame graph is associated with\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector (default is false)\r\n * @param _linkedNodeRenderGraph defines the linked node render graph (if any)\r\n */\r\n constructor(\r\n scene: Scene,\r\n debugTextures = false,\r\n private readonly _linkedNodeRenderGraph: Nullable<NodeRenderGraph> = null\r\n ) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n\r\n this._scene.addFrameGraph(this);\r\n }\r\n\r\n /**\r\n * Gets the class name of the frame graph\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FrameGraph\";\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Gets all tasks of a specific type\r\n * @param taskType Type of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[] {\r\n return this._tasks.filter((t) => t instanceof taskType) as T[];\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n this._initAsyncPromises.push(task.initAsync());\r\n }\r\n\r\n /**\r\n * Adds a pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\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)\r\n * @returns The render pass created\r\n */\r\n public addPass(name: string, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> {\r\n return this._addPass(name, FrameGraphPassType.Normal, whenTaskDisabled) as FrameGraphPass<FrameGraphContext>;\r\n }\r\n\r\n /**\r\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\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)\r\n * @returns The render pass created\r\n */\r\n public addRenderPass(name: string, whenTaskDisabled = false): FrameGraphRenderPass {\r\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled) as FrameGraphRenderPass;\r\n }\r\n\r\n /**\r\n * Adds an object list pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\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)\r\n * @returns The object list pass created\r\n */\r\n public addObjectListPass(name: string, whenTaskDisabled = false): FrameGraphObjectListPass {\r\n return this._addPass(name, FrameGraphPassType.ObjectList, whenTaskDisabled) as FrameGraphObjectListPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.ObjectList:\r\n pass = new FrameGraphObjectListPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /** @internal */\r\n public async _whenAsynchronousInitializationDoneAsync(): Promise<void> {\r\n if (this._initAsyncPromises.length > 0) {\r\n await Promise.all(this._initAsyncPromises);\r\n this._initAsyncPromises.length = 0;\r\n }\r\n }\r\n\r\n /**\r\n * @deprecated Use buildAsync instead\r\n */\r\n public build(): void {\r\n void this.buildAsync(false);\r\n }\r\n\r\n private _built = false; // TODO: to be removed when build() is removed\r\n\r\n /**\r\n * Builds the frame graph.\r\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).\r\n * @param waitForReadiness If true, the method will wait for the frame graph to be ready before returning (default is true)\r\n */\r\n public async buildAsync(waitForReadiness = true): Promise<void> {\r\n this.textureManager._releaseTextures(false);\r\n\r\n this.pausedExecution = true;\r\n this._built = false;\r\n\r\n try {\r\n await this._whenAsynchronousInitializationDoneAsync();\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures(this.optimizeTextureAllocation ? this._tasks : undefined);\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task.onTexturesAllocatedObservable.notifyObservers(this._renderContext);\r\n }\r\n\r\n this._built = true;\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n\r\n if (waitForReadiness) {\r\n await this.whenReadyAsync();\r\n }\r\n } catch (e) {\r\n this._tasks.length = 0;\r\n this._currentProcessedTask = null;\r\n this.textureManager._isRecordingTask = false;\r\n throw e;\r\n } finally {\r\n this.pausedExecution = false;\r\n this._built = true;\r\n }\r\n }\r\n\r\n /**\r\n * Checks if the frame graph is ready to be executed.\r\n * Note that you can use the whenReadyAsync method to wait for the frame graph to be ready.\r\n * @returns True if the frame graph is ready to be executed, else false\r\n */\r\n public isReady(): boolean {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n ready &&= task.isReady();\r\n }\r\n return ready;\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed.\r\n * In general, calling “await buildAsync()” should suffice, as this function also waits for readiness by default.\r\n * @param timeStep Time step in ms between retries (default is 16)\r\n * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 10000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 10000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n\r\n // TODO: to be removed when build() is removed\r\n await new Promise((resolve) => {\r\n const checkBuilt = () => {\r\n if (this._built) {\r\n resolve(void 0);\r\n return;\r\n }\r\n setTimeout(checkBuilt, 16);\r\n };\r\n checkBuilt();\r\n });\r\n // END TODO\r\n\r\n return await new Promise((resolve, reject) => {\r\n this._whenReadyAsyncCancel = _RetryWithInterval(\r\n () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n const taskIsReady = task.isReady();\r\n if (!taskIsReady && !firstNotReadyTask) {\r\n firstNotReadyTask = task;\r\n }\r\n ready &&= taskIsReady;\r\n }\r\n return ready;\r\n },\r\n () => {\r\n this._whenReadyAsyncCancel = null;\r\n resolve();\r\n },\r\n (err, isTimeout) => {\r\n this._whenReadyAsyncCancel = null;\r\n if (!isTimeout) {\r\n Logger.Error(\"FrameGraph: An unexpected error occurred while waiting for the frame graph to be ready.\");\r\n if (err) {\r\n Logger.Error(err);\r\n if (err.stack) {\r\n Logger.Error(err.stack);\r\n }\r\n }\r\n } else {\r\n Logger.Error(\r\n `FrameGraph: Timeout while waiting for the frame graph to be ready.${firstNotReadyTask ? ` First task not ready: ${firstNotReadyTask.name}` : \"\"}`\r\n );\r\n if (err) {\r\n Logger.Error(err);\r\n }\r\n }\r\n reject(new Error(err));\r\n },\r\n timeStep,\r\n maxTimeout\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n if (this.pausedExecution) {\r\n return;\r\n }\r\n\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n task._execute();\r\n }\r\n\r\n this._renderContext.bindRenderTarget(undefined, undefined, true); // restore default framebuffer\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n }\r\n\r\n this._tasks.length = 0;\r\n this.textureManager._releaseTextures();\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n /**\r\n * Disposes the frame graph\r\n */\r\n public dispose(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n this.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n\r\n this._scene.removeFrameGraph(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAClD,OAAO,EAAE,kBAAkB,EAAE,+BAA8B;AAC3D,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,iBAAiB,EAAE,qCAAoC;AAEhE,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACnB,+DAAU,CAAA;IACV,+DAAU,CAAA;IACV,uEAAc,CAAA;AAClB,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AAED;;;GAGG;AACH,MAAM,OAAO,UAAU;IAoCnB;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,I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;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene, AbstractEngine, FrameGraphTask, Nullable, NodeRenderGraph, IDisposable } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphObjectListPass } from \"./Passes/objectListPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { _RetryWithInterval } from \"core/Misc/timingTools\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { UniqueIdGenerator } from \"core/Misc/uniqueIdGenerator\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n ObjectList = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph implements IDisposable {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private readonly _initAsyncPromises: Promise<unknown>[] = [];\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\r\n private _importPromise: Promise<any>;\r\n\r\n /**\r\n * Name of the frame graph\r\n */\r\n public name = \"Frame Graph\";\r\n\r\n /**\r\n * Gets the unique id of the frame graph\r\n */\r\n public readonly uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)\r\n */\r\n public optimizeTextureAllocation = true;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the scene used by the frame graph\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the list of tasks in the frame graph\r\n */\r\n public get tasks() {\r\n return this._tasks;\r\n }\r\n\r\n /**\r\n * Indicates whether the execution of the frame graph is paused (default is false)\r\n */\r\n public pausedExecution = false;\r\n\r\n /**\r\n * Gets the node render graph linked to the frame graph (if any)\r\n * @returns the linked node render graph or null if none\r\n */\r\n public getLinkedNodeRenderGraph(): Nullable<NodeRenderGraph> {\r\n return this._linkedNodeRenderGraph;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param scene defines the scene the frame graph is associated with\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector (default is false)\r\n * @param _linkedNodeRenderGraph defines the linked node render graph (if any)\r\n */\r\n constructor(\r\n scene: Scene,\r\n debugTextures = false,\r\n private readonly _linkedNodeRenderGraph: Nullable<NodeRenderGraph> = null\r\n ) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._importPromise = this._engine.isWebGPU ? import(\"../Engines/WebGPU/Extensions/engine.multiRender\") : import(\"../Engines/Extensions/engine.multiRender\");\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n\r\n this._scene.addFrameGraph(this);\r\n }\r\n\r\n /**\r\n * Gets the class name of the frame graph\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FrameGraph\";\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Gets all tasks of a specific type\r\n * @param taskType Type of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[] {\r\n return this._tasks.filter((t) => t instanceof taskType) as T[];\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n this._initAsyncPromises.push(task.initAsync());\r\n }\r\n\r\n /**\r\n * Adds a pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\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)\r\n * @returns The render pass created\r\n */\r\n public addPass(name: string, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> {\r\n return this._addPass(name, FrameGraphPassType.Normal, whenTaskDisabled) as FrameGraphPass<FrameGraphContext>;\r\n }\r\n\r\n /**\r\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\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)\r\n * @returns The render pass created\r\n */\r\n public addRenderPass(name: string, whenTaskDisabled = false): FrameGraphRenderPass {\r\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled) as FrameGraphRenderPass;\r\n }\r\n\r\n /**\r\n * Adds an object list pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\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)\r\n * @returns The object list pass created\r\n */\r\n public addObjectListPass(name: string, whenTaskDisabled = false): FrameGraphObjectListPass {\r\n return this._addPass(name, FrameGraphPassType.ObjectList, whenTaskDisabled) as FrameGraphObjectListPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.ObjectList:\r\n pass = new FrameGraphObjectListPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /** @internal */\r\n public async _whenAsynchronousInitializationDoneAsync(): Promise<void> {\r\n if (this._initAsyncPromises.length > 0) {\r\n await Promise.all(this._initAsyncPromises);\r\n this._initAsyncPromises.length = 0;\r\n }\r\n }\r\n\r\n /**\r\n * @deprecated Use buildAsync instead\r\n */\r\n public build(): void {\r\n void this.buildAsync(false);\r\n }\r\n\r\n private _built = false; // TODO: to be removed when build() is removed\r\n\r\n /**\r\n * Builds the frame graph.\r\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).\r\n * @param waitForReadiness If true, the method will wait for the frame graph to be ready before returning (default is true)\r\n */\r\n public async buildAsync(waitForReadiness = true): Promise<void> {\r\n this.textureManager._releaseTextures(false);\r\n\r\n this.pausedExecution = true;\r\n this._built = false;\r\n\r\n try {\r\n await this._importPromise;\r\n\r\n await this._whenAsynchronousInitializationDoneAsync();\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures(this.optimizeTextureAllocation ? this._tasks : undefined);\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task.onTexturesAllocatedObservable.notifyObservers(this._renderContext);\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task._initializePasses();\r\n }\r\n\r\n this._built = true;\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n\r\n if (waitForReadiness) {\r\n await this.whenReadyAsync();\r\n }\r\n } catch (e) {\r\n this._tasks.length = 0;\r\n this._currentProcessedTask = null;\r\n this.textureManager._isRecordingTask = false;\r\n throw e;\r\n } finally {\r\n this.pausedExecution = false;\r\n this._built = true;\r\n }\r\n }\r\n\r\n /**\r\n * Checks if the frame graph is ready to be executed.\r\n * Note that you can use the whenReadyAsync method to wait for the frame graph to be ready.\r\n * @returns True if the frame graph is ready to be executed, else false\r\n */\r\n public isReady(): boolean {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n ready &&= task.isReady();\r\n }\r\n return ready;\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed.\r\n * In general, calling “await buildAsync()” should suffice, as this function also waits for readiness by default.\r\n * @param timeStep Time step in ms between retries (default is 16)\r\n * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 10000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 10000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n\r\n // TODO: to be removed when build() is removed\r\n await new Promise((resolve) => {\r\n const checkBuilt = () => {\r\n if (this._built) {\r\n resolve(void 0);\r\n return;\r\n }\r\n setTimeout(checkBuilt, 16);\r\n };\r\n checkBuilt();\r\n });\r\n // END TODO\r\n\r\n return await new Promise((resolve, reject) => {\r\n this._whenReadyAsyncCancel = _RetryWithInterval(\r\n () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n const taskIsReady = task.isReady();\r\n if (!taskIsReady && !firstNotReadyTask) {\r\n firstNotReadyTask = task;\r\n }\r\n ready &&= taskIsReady;\r\n }\r\n return ready;\r\n },\r\n () => {\r\n this._whenReadyAsyncCancel = null;\r\n resolve();\r\n },\r\n (err, isTimeout) => {\r\n this._whenReadyAsyncCancel = null;\r\n if (!isTimeout) {\r\n Logger.Error(\"FrameGraph: An unexpected error occurred while waiting for the frame graph to be ready.\");\r\n if (err) {\r\n Logger.Error(err);\r\n if (err.stack) {\r\n Logger.Error(err.stack);\r\n }\r\n }\r\n } else {\r\n Logger.Error(\r\n `FrameGraph: Timeout while waiting for the frame graph to be ready.${firstNotReadyTask ? ` First task not ready: ${firstNotReadyTask.name}` : \"\"}`\r\n );\r\n if (err) {\r\n Logger.Error(err);\r\n }\r\n }\r\n reject(new Error(err));\r\n },\r\n timeStep,\r\n maxTimeout\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n if (this.pausedExecution) {\r\n return;\r\n }\r\n\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n task._execute();\r\n }\r\n\r\n this._renderContext.bindRenderTarget(undefined, undefined, true); // restore default framebuffer\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n }\r\n\r\n this._tasks.length = 0;\r\n this.textureManager._releaseTextures();\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n /**\r\n * Disposes the frame graph\r\n */\r\n public dispose(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n this.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n\r\n this._scene.removeFrameGraph(this);\r\n }\r\n}\r\n"]}
@@ -37,6 +37,7 @@ export class FrameGraphRenderTarget {
37
37
  if (!texture) {
38
38
  throw new Error(`FrameGraphRenderTarget.renderTargetWrapper: Failed to get texture from handle. handle: ${handle}, name: ${this.name}, index: ${i}, renderTargets: ${this._renderTargets}`);
39
39
  }
40
+ texture.incrementReferences();
40
41
  this._renderTargetWrapper.setTexture(texture, i, false);
41
42
  }
42
43
  if (this._renderTargetDepth !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraphRenderTarget.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderTarget.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAS/B,YACI,IAAY,EACZ,cAAwC,EACxC,aAAmE,EACnE,iBAA2C;QARrC,kBAAa,GAAG,KAAK,CAAC;QAU5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;QAC/H,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAChD,CAAC;IAED,IAAW,mBAAmB;QAC1B,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CA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C;IAChE,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { FrameGraphTextureHandle, FrameGraphTextureManager, IMultiRenderTargetOptions, RenderTargetWrapper } from \"core/index\";\r\n\r\n/**\r\n * @internal\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderTarget {\r\n protected readonly _textureManager: FrameGraphTextureManager;\r\n protected readonly _renderTargets: FrameGraphTextureHandle[] | undefined;\r\n protected readonly _renderTargetDepth: FrameGraphTextureHandle | undefined;\r\n protected _renderTargetWrapper: RenderTargetWrapper | undefined;\r\n protected _isBackBuffer = false;\r\n\r\n public readonly name: string;\r\n\r\n constructor(\r\n name: string,\r\n textureManager: FrameGraphTextureManager,\r\n renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[],\r\n renderTargetDepth?: FrameGraphTextureHandle\r\n ) {\r\n this.name = name;\r\n this._textureManager = textureManager;\r\n this._renderTargets = renderTargets === undefined ? undefined : Array.isArray(renderTargets) ? renderTargets : [renderTargets];\r\n this._renderTargetDepth = renderTargetDepth;\r\n }\r\n\r\n public get renderTargetWrapper() {\r\n if (this._isBackBuffer) {\r\n return undefined;\r\n }\r\n\r\n if (!this._renderTargetWrapper) {\r\n const engine = this._textureManager.engine;\r\n\r\n // _renderTargets and _renderTargetDepth cannot both be undefined\r\n const textureHandle = this._renderTargets === undefined || this._renderTargets.length === 0 ? this._renderTargetDepth! : this._renderTargets[0];\r\n\r\n if (this._textureManager.isBackbuffer(textureHandle)) {\r\n this._isBackBuffer = true;\r\n return undefined;\r\n }\r\n\r\n const textureDescription = this._textureManager.getTextureDescription(textureHandle);\r\n\r\n const creationOptionsForTexture: IMultiRenderTargetOptions = {\r\n textureCount: this._renderTargets?.length ?? 0,\r\n generateDepthBuffer: false,\r\n label: this.name,\r\n samples: textureDescription.options.samples ?? 1,\r\n dontCreateTextures: true,\r\n };\r\n\r\n this._renderTargetWrapper = engine.createMultipleRenderTarget(textureDescription.size, creationOptionsForTexture, true);\r\n\r\n for (let i = 0; i < creationOptionsForTexture.textureCount!; i++) {\r\n const handle = this._renderTargets![i];\r\n const texture = this._textureManager.getTextureFromHandle(handle);\r\n\r\n if (!texture) {\r\n throw new Error(\r\n `FrameGraphRenderTarget.renderTargetWrapper: Failed to get texture from handle. handle: ${handle}, name: ${this.name}, index: ${i}, renderTargets: ${this._renderTargets}`\r\n );\r\n }\r\n\r\n this._renderTargetWrapper.setTexture(texture, i, false);\r\n }\r\n\r\n if (this._renderTargetDepth !== undefined) {\r\n this._renderTargetWrapper.setDepthStencilTexture(this._textureManager.getTextureFromHandle(this._renderTargetDepth), false);\r\n }\r\n }\r\n\r\n return this._renderTargetWrapper;\r\n }\r\n\r\n public equals(other: FrameGraphRenderTarget): boolean {\r\n const src = this._renderTargets;\r\n const dst = other._renderTargets;\r\n\r\n if (src !== undefined && dst !== undefined) {\r\n if (src.length !== dst.length) {\r\n return false;\r\n }\r\n\r\n for (let i = 0; i < src.length; i++) {\r\n if (src[i] !== dst[i]) {\r\n return false;\r\n }\r\n }\r\n } else if ((src === undefined && dst !== undefined) || (src !== undefined && dst === undefined)) {\r\n return false;\r\n }\r\n\r\n return this._renderTargetDepth === other._renderTargetDepth;\r\n }\r\n\r\n public dispose() {\r\n this._renderTargetWrapper?.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"frameGraphRenderTarget.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderTarget.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAS/B,YACI,IAAY,EACZ,cAAwC,EACxC,aAAmE,EACnE,iBAA2C;QARrC,kBAAa,GAAG,KAAK,CAAC;QAU5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,aAAa,KAAK,SAAS,CAAC,CAAC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C;gBAClC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;oBACpB,OAAO,KAAK,CAAC;gBACjB,CAAC;YACL,CAAC;QACL,CAAC;aAAM,IAAI,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,CAAC,EAAE,CAAC;YAC9F,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC,kBAAkB,KAAK,KAAK,CAAC,kBAAkB,CAAC;IAChE,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { FrameGraphTextureHandle, FrameGraphTextureManager, IMultiRenderTargetOptions, RenderTargetWrapper } from \"core/index\";\r\n\r\n/**\r\n * @internal\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderTarget {\r\n protected readonly _textureManager: FrameGraphTextureManager;\r\n protected readonly _renderTargets: FrameGraphTextureHandle[] | undefined;\r\n protected readonly _renderTargetDepth: FrameGraphTextureHandle | undefined;\r\n protected _renderTargetWrapper: RenderTargetWrapper | undefined;\r\n protected _isBackBuffer = false;\r\n\r\n public readonly name: string;\r\n\r\n constructor(\r\n name: string,\r\n textureManager: FrameGraphTextureManager,\r\n renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[],\r\n renderTargetDepth?: FrameGraphTextureHandle\r\n ) {\r\n this.name = name;\r\n this._textureManager = textureManager;\r\n this._renderTargets = renderTargets === undefined ? undefined : Array.isArray(renderTargets) ? renderTargets : [renderTargets];\r\n this._renderTargetDepth = renderTargetDepth;\r\n }\r\n\r\n public get renderTargetWrapper() {\r\n if (this._isBackBuffer) {\r\n return undefined;\r\n }\r\n\r\n if (!this._renderTargetWrapper) {\r\n const engine = this._textureManager.engine;\r\n\r\n // _renderTargets and _renderTargetDepth cannot both be undefined\r\n const textureHandle = this._renderTargets === undefined || this._renderTargets.length === 0 ? this._renderTargetDepth! : this._renderTargets[0];\r\n\r\n if (this._textureManager.isBackbuffer(textureHandle)) {\r\n this._isBackBuffer = true;\r\n return undefined;\r\n }\r\n\r\n const textureDescription = this._textureManager.getTextureDescription(textureHandle);\r\n\r\n const creationOptionsForTexture: IMultiRenderTargetOptions = {\r\n textureCount: this._renderTargets?.length ?? 0,\r\n generateDepthBuffer: false,\r\n label: this.name,\r\n samples: textureDescription.options.samples ?? 1,\r\n dontCreateTextures: true,\r\n };\r\n\r\n this._renderTargetWrapper = engine.createMultipleRenderTarget(textureDescription.size, creationOptionsForTexture, true);\r\n\r\n for (let i = 0; i < creationOptionsForTexture.textureCount!; i++) {\r\n const handle = this._renderTargets![i];\r\n const texture = this._textureManager.getTextureFromHandle(handle);\r\n\r\n if (!texture) {\r\n throw new Error(\r\n `FrameGraphRenderTarget.renderTargetWrapper: Failed to get texture from handle. handle: ${handle}, name: ${this.name}, index: ${i}, renderTargets: ${this._renderTargets}`\r\n );\r\n }\r\n\r\n texture.incrementReferences();\r\n\r\n this._renderTargetWrapper.setTexture(texture, i, false);\r\n }\r\n\r\n if (this._renderTargetDepth !== undefined) {\r\n this._renderTargetWrapper.setDepthStencilTexture(this._textureManager.getTextureFromHandle(this._renderTargetDepth), false);\r\n }\r\n }\r\n\r\n return this._renderTargetWrapper;\r\n }\r\n\r\n public equals(other: FrameGraphRenderTarget): boolean {\r\n const src = this._renderTargets;\r\n const dst = other._renderTargets;\r\n\r\n if (src !== undefined && dst !== undefined) {\r\n if (src.length !== dst.length) {\r\n return false;\r\n }\r\n\r\n for (let i = 0; i < src.length; i++) {\r\n if (src[i] !== dst[i]) {\r\n return false;\r\n }\r\n }\r\n } else if ((src === undefined && dst !== undefined) || (src !== undefined && dst === undefined)) {\r\n return false;\r\n }\r\n\r\n return this._renderTargetDepth === other._renderTargetDepth;\r\n }\r\n\r\n public dispose() {\r\n this._renderTargetWrapper?.dispose();\r\n }\r\n}\r\n"]}
@@ -47,7 +47,7 @@ export declare abstract class FrameGraphTask {
47
47
  * This allows you to initialize asynchronous resources, which is not possible in the constructor.
48
48
  * @returns A promise that resolves when the initialization is complete.
49
49
  */
50
- initAsync(): Promise<void>;
50
+ initAsync(): Promise<unknown>;
51
51
  /**
52
52
  * An observable that is triggered after the textures have been allocated.
53
53
  */
@@ -83,5 +83,7 @@ export declare abstract class FrameGraphTask {
83
83
  _checkTask(): void;
84
84
  /** @internal */
85
85
  _execute(): void;
86
+ /** @internal */
87
+ _initializePasses(): void;
86
88
  private _checkSameRenderTarget;
87
89
  }
@@ -193,6 +193,17 @@ export class FrameGraphTask {
193
193
  this._frameGraph.engine._debugPopGroup?.(2);
194
194
  this.onAfterTaskExecute.notifyObservers(this);
195
195
  }
196
+ /** @internal */
197
+ _initializePasses() {
198
+ this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 2);
199
+ for (const pass of this._passes) {
200
+ pass._initialize();
201
+ }
202
+ for (const pass of this._passesDisabled) {
203
+ pass._initialize();
204
+ }
205
+ this._frameGraph.engine._debugPopGroup?.(2);
206
+ }
196
207
  _checkSameRenderTarget(src, dst) {
197
208
  if (src === null || dst === null) {
198
209
  return src === dst;
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraphTask.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD;;;GAGG;AACH,MAAM,OAAgB,cAAc;IAUhC;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI,CAAC,KAAa;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAID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EAAE,CAAC;YAClC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphObjectList, IFrameGraphPass, Nullable, FrameGraphTextureHandle, InternalTexture, FrameGraphRenderContext } from \"core/index\";\r\nimport { FrameGraphObjectListPass } from \"./Passes/objectListPass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\n/**\r\n * Represents a task in a frame graph.\r\n * @experimental\r\n */\r\nexport abstract class FrameGraphTask {\r\n protected readonly _frameGraph: FrameGraph;\r\n\r\n private readonly _passes: IFrameGraphPass[] = [];\r\n private readonly _passesDisabled: IFrameGraphPass[] = [];\r\n\r\n // Note: must be a getter/setter even if there's no specific processing, otherwise inherited classes can't make it a getter/setter!\r\n // Same thing for the disabled property\r\n protected _name: string;\r\n\r\n /**\r\n * The name of the task.\r\n */\r\n public get name() {\r\n return this._name;\r\n }\r\n\r\n public set name(value: string) {\r\n this._name = value;\r\n }\r\n\r\n protected _disabled = false;\r\n\r\n /**\r\n * Whether the task is disabled.\r\n */\r\n public get disabled() {\r\n return this._disabled;\r\n }\r\n\r\n public set disabled(value: boolean) {\r\n this._disabled = value;\r\n }\r\n\r\n /**\r\n * Gets the render passes of the task.\r\n */\r\n public get passes() {\r\n return this._passes;\r\n }\r\n\r\n /**\r\n * Gets the disabled render passes of the task.\r\n */\r\n public get passesDisabled() {\r\n return this._passesDisabled;\r\n }\r\n\r\n /**\r\n * The (texture) dependencies of the task (optional).\r\n */\r\n public dependencies?: Set<FrameGraphTextureHandle>;\r\n\r\n /**\r\n * Records the task in the frame graph. Use this function to add content (render passes, ...) to the task.\r\n * @param skipCreationOfDisabledPasses If true, the disabled passe(s) won't be created.\r\n */\r\n public abstract record(skipCreationOfDisabledPasses?: boolean): void;\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"FrameGraphTask\";\r\n }\r\n\r\n /**\r\n * This function is called once after the task has been added to the frame graph and before the frame graph is built for the first time.\r\n * This allows you to initialize asynchronous resources, which is not possible in the constructor.\r\n * @returns A promise that resolves when the initialization is complete.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public initAsync(): Promise<void> {\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * An observable that is triggered after the textures have been allocated.\r\n */\r\n public onTexturesAllocatedObservable: Observable<FrameGraphRenderContext> = new Observable();\r\n\r\n /**\r\n * An observable that is triggered before the task is executed.\r\n */\r\n public onBeforeTaskExecute: Observable<FrameGraphTask> = new Observable();\r\n\r\n /**\r\n * An observable that is triggered after the task is executed.\r\n */\r\n public onAfterTaskExecute: Observable<FrameGraphTask> = new Observable();\r\n\r\n /**\r\n * Checks if the task is ready to be executed.\r\n * @returns True if the task is ready to be executed, else false.\r\n */\r\n public isReady(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes of the task.\r\n */\r\n public dispose() {\r\n this._reset();\r\n this.onTexturesAllocatedObservable.clear();\r\n this.onBeforeTaskExecute.clear();\r\n this.onAfterTaskExecute.clear();\r\n }\r\n\r\n /**\r\n * Constructs a new frame graph task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n this.name = name;\r\n this._frameGraph = frameGraph;\r\n this._reset();\r\n }\r\n\r\n /** @internal */\r\n public _reset() {\r\n for (const pass of this._passes) {\r\n pass._dispose();\r\n }\r\n for (const pass of this._passesDisabled) {\r\n pass._dispose();\r\n }\r\n this._passes.length = 0;\r\n this._passesDisabled.length = 0;\r\n }\r\n\r\n /** @internal */\r\n public _addPass(pass: IFrameGraphPass, disabled: boolean) {\r\n if (disabled) {\r\n this._passesDisabled.push(pass);\r\n } else {\r\n this._passes.push(pass);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _checkTask() {\r\n let outputTexture: Nullable<Nullable<InternalTexture>[]> = null;\r\n let outputDepthTexture: Nullable<InternalTexture> = null;\r\n let outputObjectList: FrameGraphObjectList | undefined;\r\n\r\n for (const pass of this._passes) {\r\n const errMsg = pass._isValid();\r\n if (errMsg) {\r\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\r\n }\r\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\r\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\r\n outputTexture = [];\r\n for (const handle of handles) {\r\n if (handle !== undefined) {\r\n outputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\r\n }\r\n }\r\n outputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\r\n } else if (FrameGraphObjectListPass.IsObjectListPass(pass)) {\r\n outputObjectList = pass.objectList;\r\n }\r\n }\r\n\r\n let disabledOutputTexture: Nullable<Nullable<InternalTexture>[]> = null;\r\n let disabledOutputTextureHandle: (FrameGraphTextureHandle | undefined)[] = [];\r\n let disabledOutputDepthTexture: Nullable<InternalTexture> = null;\r\n let disabledOutputObjectList: FrameGraphObjectList | undefined;\r\n\r\n for (const pass of this._passesDisabled) {\r\n const errMsg = pass._isValid();\r\n if (errMsg) {\r\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\r\n }\r\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\r\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\r\n disabledOutputTexture = [];\r\n for (const handle of handles) {\r\n if (handle !== undefined) {\r\n disabledOutputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\r\n }\r\n }\r\n disabledOutputTextureHandle = handles;\r\n disabledOutputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\r\n } else if (FrameGraphObjectListPass.IsObjectListPass(pass)) {\r\n disabledOutputObjectList = pass.objectList;\r\n }\r\n }\r\n\r\n if (this._passesDisabled.length > 0) {\r\n if (!this._checkSameRenderTarget(outputTexture, disabledOutputTexture)) {\r\n let ok = true;\r\n for (const handle of disabledOutputTextureHandle) {\r\n if (handle !== undefined && !this._frameGraph.textureManager.isHistoryTexture(handle)) {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n if (!ok) {\r\n throw new Error(`The output texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n }\r\n if (outputDepthTexture !== disabledOutputDepthTexture && disabledOutputDepthTexture !== null) {\r\n throw new Error(`The output depth texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n if (outputObjectList !== disabledOutputObjectList && disabledOutputObjectList !== null) {\r\n throw new Error(`The output object list of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _execute() {\r\n const passes = this._disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;\r\n\r\n this.onBeforeTaskExecute.notifyObservers(this);\r\n\r\n this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 2);\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n\r\n this._frameGraph.engine._debugPopGroup?.(2);\r\n\r\n this.onAfterTaskExecute.notifyObservers(this);\r\n }\r\n\r\n private _checkSameRenderTarget(src: Nullable<Nullable<InternalTexture>[]>, dst: Nullable<Nullable<InternalTexture>[]>) {\r\n if (src === null || dst === null) {\r\n return src === dst;\r\n }\r\n\r\n if (src.length !== dst.length) {\r\n return false;\r\n }\r\n\r\n for (let i = 0; i < src.length; i++) {\r\n if (src[i] !== dst[i]) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"frameGraphTask.js","sourceRoot":"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BAAkB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,gBAAgB;IACT,iBAAiB;QACpB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;QAEtF,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACtC,IAAI,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IAEO,sBAAsB,CAAC,GAA0C,EAAE,GAA0C;QACjH,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC/B,OAAO,GAAG,KAAK,GAAG,CAAC;QACvB,CAAC;QAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphObjectList, IFrameGraphPass, Nullable, FrameGraphTextureHandle, InternalTexture, FrameGraphRenderContext } from \"core/index\";\r\nimport { FrameGraphObjectListPass } from \"./Passes/objectListPass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\n/**\r\n * Represents a task in a frame graph.\r\n * @experimental\r\n */\r\nexport abstract class FrameGraphTask {\r\n protected readonly _frameGraph: FrameGraph;\r\n\r\n private readonly _passes: IFrameGraphPass[] = [];\r\n private readonly _passesDisabled: IFrameGraphPass[] = [];\r\n\r\n // Note: must be a getter/setter even if there's no specific processing, otherwise inherited classes can't make it a getter/setter!\r\n // Same thing for the disabled property\r\n protected _name: string;\r\n\r\n /**\r\n * The name of the task.\r\n */\r\n public get name() {\r\n return this._name;\r\n }\r\n\r\n public set name(value: string) {\r\n this._name = value;\r\n }\r\n\r\n protected _disabled = false;\r\n\r\n /**\r\n * Whether the task is disabled.\r\n */\r\n public get disabled() {\r\n return this._disabled;\r\n }\r\n\r\n public set disabled(value: boolean) {\r\n this._disabled = value;\r\n }\r\n\r\n /**\r\n * Gets the render passes of the task.\r\n */\r\n public get passes() {\r\n return this._passes;\r\n }\r\n\r\n /**\r\n * Gets the disabled render passes of the task.\r\n */\r\n public get passesDisabled() {\r\n return this._passesDisabled;\r\n }\r\n\r\n /**\r\n * The (texture) dependencies of the task (optional).\r\n */\r\n public dependencies?: Set<FrameGraphTextureHandle>;\r\n\r\n /**\r\n * Records the task in the frame graph. Use this function to add content (render passes, ...) to the task.\r\n * @param skipCreationOfDisabledPasses If true, the disabled passe(s) won't be created.\r\n */\r\n public abstract record(skipCreationOfDisabledPasses?: boolean): void;\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"FrameGraphTask\";\r\n }\r\n\r\n /**\r\n * This function is called once after the task has been added to the frame graph and before the frame graph is built for the first time.\r\n * This allows you to initialize asynchronous resources, which is not possible in the constructor.\r\n * @returns A promise that resolves when the initialization is complete.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public initAsync(): Promise<unknown> {\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * An observable that is triggered after the textures have been allocated.\r\n */\r\n public onTexturesAllocatedObservable: Observable<FrameGraphRenderContext> = new Observable();\r\n\r\n /**\r\n * An observable that is triggered before the task is executed.\r\n */\r\n public onBeforeTaskExecute: Observable<FrameGraphTask> = new Observable();\r\n\r\n /**\r\n * An observable that is triggered after the task is executed.\r\n */\r\n public onAfterTaskExecute: Observable<FrameGraphTask> = new Observable();\r\n\r\n /**\r\n * Checks if the task is ready to be executed.\r\n * @returns True if the task is ready to be executed, else false.\r\n */\r\n public isReady(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes of the task.\r\n */\r\n public dispose() {\r\n this._reset();\r\n this.onTexturesAllocatedObservable.clear();\r\n this.onBeforeTaskExecute.clear();\r\n this.onAfterTaskExecute.clear();\r\n }\r\n\r\n /**\r\n * Constructs a new frame graph task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n this.name = name;\r\n this._frameGraph = frameGraph;\r\n this._reset();\r\n }\r\n\r\n /** @internal */\r\n public _reset() {\r\n for (const pass of this._passes) {\r\n pass._dispose();\r\n }\r\n for (const pass of this._passesDisabled) {\r\n pass._dispose();\r\n }\r\n this._passes.length = 0;\r\n this._passesDisabled.length = 0;\r\n }\r\n\r\n /** @internal */\r\n public _addPass(pass: IFrameGraphPass, disabled: boolean) {\r\n if (disabled) {\r\n this._passesDisabled.push(pass);\r\n } else {\r\n this._passes.push(pass);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _checkTask() {\r\n let outputTexture: Nullable<Nullable<InternalTexture>[]> = null;\r\n let outputDepthTexture: Nullable<InternalTexture> = null;\r\n let outputObjectList: FrameGraphObjectList | undefined;\r\n\r\n for (const pass of this._passes) {\r\n const errMsg = pass._isValid();\r\n if (errMsg) {\r\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\r\n }\r\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\r\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\r\n outputTexture = [];\r\n for (const handle of handles) {\r\n if (handle !== undefined) {\r\n outputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\r\n }\r\n }\r\n outputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\r\n } else if (FrameGraphObjectListPass.IsObjectListPass(pass)) {\r\n outputObjectList = pass.objectList;\r\n }\r\n }\r\n\r\n let disabledOutputTexture: Nullable<Nullable<InternalTexture>[]> = null;\r\n let disabledOutputTextureHandle: (FrameGraphTextureHandle | undefined)[] = [];\r\n let disabledOutputDepthTexture: Nullable<InternalTexture> = null;\r\n let disabledOutputObjectList: FrameGraphObjectList | undefined;\r\n\r\n for (const pass of this._passesDisabled) {\r\n const errMsg = pass._isValid();\r\n if (errMsg) {\r\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\r\n }\r\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\r\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\r\n disabledOutputTexture = [];\r\n for (const handle of handles) {\r\n if (handle !== undefined) {\r\n disabledOutputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\r\n }\r\n }\r\n disabledOutputTextureHandle = handles;\r\n disabledOutputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\r\n } else if (FrameGraphObjectListPass.IsObjectListPass(pass)) {\r\n disabledOutputObjectList = pass.objectList;\r\n }\r\n }\r\n\r\n if (this._passesDisabled.length > 0) {\r\n if (!this._checkSameRenderTarget(outputTexture, disabledOutputTexture)) {\r\n let ok = true;\r\n for (const handle of disabledOutputTextureHandle) {\r\n if (handle !== undefined && !this._frameGraph.textureManager.isHistoryTexture(handle)) {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n if (!ok) {\r\n throw new Error(`The output texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n }\r\n if (outputDepthTexture !== disabledOutputDepthTexture && disabledOutputDepthTexture !== null) {\r\n throw new Error(`The output depth texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n if (outputObjectList !== disabledOutputObjectList && disabledOutputObjectList !== null) {\r\n throw new Error(`The output object list of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _execute() {\r\n const passes = this._disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;\r\n\r\n this.onBeforeTaskExecute.notifyObservers(this);\r\n\r\n this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 2);\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n\r\n this._frameGraph.engine._debugPopGroup?.(2);\r\n\r\n this.onAfterTaskExecute.notifyObservers(this);\r\n }\r\n\r\n /** @internal */\r\n public _initializePasses() {\r\n this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 2);\r\n\r\n for (const pass of this._passes) {\r\n pass._initialize();\r\n }\r\n\r\n for (const pass of this._passesDisabled) {\r\n pass._initialize();\r\n }\r\n\r\n this._frameGraph.engine._debugPopGroup?.(2);\r\n }\r\n\r\n private _checkSameRenderTarget(src: Nullable<Nullable<InternalTexture>[]>, dst: Nullable<Nullable<InternalTexture>[]>) {\r\n if (src === null || dst === null) {\r\n return src === dst;\r\n }\r\n\r\n if (src.length !== dst.length) {\r\n return false;\r\n }\r\n\r\n for (let i = 0; i < src.length; i++) {\r\n if (src[i] !== dst[i]) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
@@ -68,12 +68,20 @@ export interface IFrameGraphPass {
68
68
  * Whether the pass is disabled.
69
69
  */
70
70
  disabled: boolean;
71
+ /**
72
+ * Initializes the pass.
73
+ * This function is called once before the first execution of the pass.
74
+ * @param func The function to initialize the pass.
75
+ */
76
+ setInitializeFunc(func: (context: FrameGraphContext) => void): void;
71
77
  /**
72
78
  * Sets the function to execute when the pass is executed
73
79
  * @param func The function to execute when the pass is executed
74
80
  */
75
81
  setExecuteFunc(func: (context: FrameGraphContext) => void): void;
76
82
  /** @internal */
83
+ _initialize(): void;
84
+ /** @internal */
77
85
  _execute(): void;
78
86
  /** @internal */
79
87
  _isValid(): Nullable<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraphTypes.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphTypes.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,4BAA4B,GAA4B,CAAC,CAAC;AAEvE;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,mCAAmC,GAA4B,CAAC,CAAC","sourcesContent":["import type { Nullable, TextureSize, FrameGraphContext } from \"core/index\";\r\n\r\n/**\r\n * Represents a texture handle in the frame graph.\r\n */\r\nexport type FrameGraphTextureHandle = number;\r\n\r\n/**\r\n * Represents a texture handle for the backbuffer color texture.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const backbufferColorTextureHandle: FrameGraphTextureHandle = 0;\r\n\r\n/**\r\n * Represents a texture handle for the backbuffer depth/stencil texture.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const backbufferDepthStencilTextureHandle: FrameGraphTextureHandle = 1;\r\n\r\n/**\r\n * Options used to describe a texture to be created in the frame graph.\r\n */\r\nexport type FrameGraphTextureOptions = {\r\n /** Specifies if mipmaps must be created for the textures (default: false) */\r\n createMipMaps?: boolean;\r\n\r\n /** Defines sample count (default: 1) */\r\n samples?: number;\r\n\r\n /** Defines the types of the textures */\r\n types?: number[];\r\n\r\n /** Defines the format of the textures (RED, RG, RGB, RGBA, ALPHA...) */\r\n formats?: number[];\r\n\r\n /** Defines if sRGB format should be used for each of texture */\r\n useSRGBBuffers?: boolean[];\r\n\r\n /** Defines the creation flags of the textures (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg) */\r\n creationFlags?: number[];\r\n\r\n /** Defines the names of the textures (used for debugging purpose) */\r\n labels?: string[];\r\n};\r\n\r\n/**\r\n * Options used to create a texture / list of textures in the frame graph.\r\n */\r\nexport type FrameGraphTextureCreationOptions = {\r\n /** Size of the textures. If sizeIsPercentage is true, these are percentages relative to the screen size (100 = 100%) */\r\n size: TextureSize;\r\n\r\n /** Options used to create the textures */\r\n options: FrameGraphTextureOptions;\r\n\r\n /** If true, indicates that \"size\" is percentages relative to the screen size */\r\n sizeIsPercentage: boolean;\r\n\r\n /** Indicates that the texture is a history texture (default: false) */\r\n isHistoryTexture?: boolean;\r\n};\r\n\r\n/**\r\n * Represents a texture description in the frame graph.\r\n * This is basically the same thing than FrameGraphTextureCreationOptions, but the size is never in percentage and always in pixels.\r\n */\r\nexport type FrameGraphTextureDescription = {\r\n /** Size of the texture */\r\n size: { width: number; height: number };\r\n\r\n /** Options used to create the texture */\r\n options: FrameGraphTextureOptions;\r\n};\r\n\r\n/**\r\n * Defines a pass in the frame graph.\r\n */\r\nexport interface IFrameGraphPass {\r\n /**\r\n * The name of the pass.\r\n */\r\n name: string;\r\n\r\n /**\r\n * Whether the pass is disabled.\r\n */\r\n disabled: boolean;\r\n\r\n /**\r\n * Sets the function to execute when the pass is executed\r\n * @param func The function to execute when the pass is executed\r\n */\r\n setExecuteFunc(func: (context: FrameGraphContext) => void): void;\r\n\r\n /** @internal */\r\n _execute(): void;\r\n\r\n /** @internal */\r\n _isValid(): Nullable<string>;\r\n\r\n /** @internal */\r\n _dispose(): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"frameGraphTypes.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphTypes.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,4BAA4B,GAA4B,CAAC,CAAC;AAEvE;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,mCAAmC,GAA4B,CAAC,CAAC","sourcesContent":["import type { Nullable, TextureSize, FrameGraphContext } from \"core/index\";\r\n\r\n/**\r\n * Represents a texture handle in the frame graph.\r\n */\r\nexport type FrameGraphTextureHandle = number;\r\n\r\n/**\r\n * Represents a texture handle for the backbuffer color texture.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const backbufferColorTextureHandle: FrameGraphTextureHandle = 0;\r\n\r\n/**\r\n * Represents a texture handle for the backbuffer depth/stencil texture.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const backbufferDepthStencilTextureHandle: FrameGraphTextureHandle = 1;\r\n\r\n/**\r\n * Options used to describe a texture to be created in the frame graph.\r\n */\r\nexport type FrameGraphTextureOptions = {\r\n /** Specifies if mipmaps must be created for the textures (default: false) */\r\n createMipMaps?: boolean;\r\n\r\n /** Defines sample count (default: 1) */\r\n samples?: number;\r\n\r\n /** Defines the types of the textures */\r\n types?: number[];\r\n\r\n /** Defines the format of the textures (RED, RG, RGB, RGBA, ALPHA...) */\r\n formats?: number[];\r\n\r\n /** Defines if sRGB format should be used for each of texture */\r\n useSRGBBuffers?: boolean[];\r\n\r\n /** Defines the creation flags of the textures (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg) */\r\n creationFlags?: number[];\r\n\r\n /** Defines the names of the textures (used for debugging purpose) */\r\n labels?: string[];\r\n};\r\n\r\n/**\r\n * Options used to create a texture / list of textures in the frame graph.\r\n */\r\nexport type FrameGraphTextureCreationOptions = {\r\n /** Size of the textures. If sizeIsPercentage is true, these are percentages relative to the screen size (100 = 100%) */\r\n size: TextureSize;\r\n\r\n /** Options used to create the textures */\r\n options: FrameGraphTextureOptions;\r\n\r\n /** If true, indicates that \"size\" is percentages relative to the screen size */\r\n sizeIsPercentage: boolean;\r\n\r\n /** Indicates that the texture is a history texture (default: false) */\r\n isHistoryTexture?: boolean;\r\n};\r\n\r\n/**\r\n * Represents a texture description in the frame graph.\r\n * This is basically the same thing than FrameGraphTextureCreationOptions, but the size is never in percentage and always in pixels.\r\n */\r\nexport type FrameGraphTextureDescription = {\r\n /** Size of the texture */\r\n size: { width: number; height: number };\r\n\r\n /** Options used to create the texture */\r\n options: FrameGraphTextureOptions;\r\n};\r\n\r\n/**\r\n * Defines a pass in the frame graph.\r\n */\r\nexport interface IFrameGraphPass {\r\n /**\r\n * The name of the pass.\r\n */\r\n name: string;\r\n\r\n /**\r\n * Whether the pass is disabled.\r\n */\r\n disabled: boolean;\r\n\r\n /**\r\n * Initializes the pass.\r\n * This function is called once before the first execution of the pass.\r\n * @param func The function to initialize the pass.\r\n */\r\n setInitializeFunc(func: (context: FrameGraphContext) => void): void;\r\n\r\n /**\r\n * Sets the function to execute when the pass is executed\r\n * @param func The function to execute when the pass is executed\r\n */\r\n setExecuteFunc(func: (context: FrameGraphContext) => void): void;\r\n\r\n /** @internal */\r\n _initialize(): void;\r\n\r\n /** @internal */\r\n _execute(): void;\r\n\r\n /** @internal */\r\n _isValid(): Nullable<string>;\r\n\r\n /** @internal */\r\n _dispose(): void;\r\n}\r\n"]}
@@ -86,6 +86,7 @@ export declare class LightingVolume {
86
86
  dispose(): void;
87
87
  private _needUpdateGeometry;
88
88
  private _createComputeShader;
89
+ private _setComputeShaderInputs;
89
90
  private _createFallbackTextures;
90
91
  private _fallbackReadPixelAsync;
91
92
  private _fullUpdateUBO;
@@ -32,11 +32,7 @@ export class LightingVolume {
32
32
  if (!this._engine.isWebGPU) {
33
33
  this._createFallbackTextures();
34
34
  }
35
- const depthTexture = this._shadowGenerator.getShadowMap()?.depthStencilTexture;
36
- if (this._engine.isWebGPU && depthTexture) {
37
- this._cs.setInternalTexture("shadowMap", depthTexture);
38
- this._cs2.setInternalTexture("shadowMap", depthTexture);
39
- }
35
+ this._setComputeShaderInputs();
40
36
  }
41
37
  /**
42
38
  * The tesselation level of the lighting volume.
@@ -240,20 +236,26 @@ export class LightingVolume {
240
236
  },
241
237
  entryPoint: "updatePlaneVertices",
242
238
  });
239
+ this._setComputeShaderInputs();
240
+ }
241
+ _setComputeShaderInputs() {
242
+ if (!this._engine.isWebGPU) {
243
+ return;
244
+ }
243
245
  if (this._shadowGenerator) {
244
246
  const depthTexture = this._shadowGenerator.getShadowMap()?.depthStencilTexture;
245
247
  if (depthTexture) {
246
- this._cs.setInternalTexture("shadowMap", depthTexture);
247
- this._cs2.setInternalTexture("shadowMap", depthTexture);
248
+ this._cs?.setInternalTexture("shadowMap", depthTexture);
249
+ this._cs2?.setInternalTexture("shadowMap", depthTexture);
248
250
  }
249
251
  }
250
252
  if (this._uBuffer) {
251
- this._cs.setUniformBuffer("params", this._uBuffer);
252
- this._cs2.setUniformBuffer("params", this._uBuffer);
253
+ this._cs?.setUniformBuffer("params", this._uBuffer);
254
+ this._cs2?.setUniformBuffer("params", this._uBuffer);
253
255
  }
254
256
  if (this._storageBuffer) {
255
- this._cs.setStorageBuffer("positions", this._storageBuffer);
256
- this._cs2.setStorageBuffer("positions", this._storageBuffer);
257
+ this._cs?.setStorageBuffer("positions", this._storageBuffer);
258
+ this._cs2?.setStorageBuffer("positions", this._storageBuffer);
257
259
  }
258
260
  }
259
261
  _createFallbackTextures() {
@@ -380,8 +382,7 @@ export class LightingVolume {
380
382
  this._storageBuffer?.dispose();
381
383
  this._storageBuffer = new StorageBuffer(webGPUEngine, vertexNumber * 3 * 4, 8 | 3);
382
384
  this._mesh.setVerticesBuffer(new VertexBuffer(webGPUEngine, this._storageBuffer.getBuffer(), "position", { takeBufferOwnership: false }), true, vertexNumber);
383
- this._cs.setStorageBuffer("positions", this._storageBuffer);
384
- this._cs2.setStorageBuffer("positions", this._storageBuffer);
385
+ this._setComputeShaderInputs();
385
386
  this._cs.triggerContextRebuild = true;
386
387
  this._cs2.triggerContextRebuild = true;
387
388
  this._needFullUpdateUBO = true;