@babylonjs/core 7.35.1 → 7.36.0

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 (180) hide show
  1. package/Engines/Extensions/engine.multiRender.d.ts +11 -0
  2. package/Engines/Extensions/engine.multiRender.js +71 -32
  3. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  4. package/Engines/Extensions/engine.prefilteredCubeTexture.js +3 -2
  5. package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
  6. package/Engines/Extensions/engine.renderTarget.js +1 -13
  7. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  8. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +2 -0
  9. package/Engines/WebGL/webGLRenderTargetWrapper.js +37 -7
  10. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  11. package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +11 -0
  12. package/Engines/WebGPU/Extensions/engine.multiRender.js +30 -11
  13. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  14. package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -5
  15. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  16. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +3 -2
  17. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  18. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +3 -1
  19. package/Engines/WebGPU/webgpuHardwareTexture.js +5 -4
  20. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  21. package/Engines/WebGPU/webgpuTextureManager.js +2 -2
  22. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  23. package/Engines/abstractEngine.d.ts +11 -0
  24. package/Engines/abstractEngine.js +2 -2
  25. package/Engines/abstractEngine.js.map +1 -1
  26. package/Engines/renderTargetWrapper.d.ts +33 -1
  27. package/Engines/renderTargetWrapper.js +64 -4
  28. package/Engines/renderTargetWrapper.js.map +1 -1
  29. package/Engines/thinEngine.d.ts +13 -1
  30. package/Engines/thinEngine.js +115 -24
  31. package/Engines/thinEngine.js.map +1 -1
  32. package/Engines/thinWebGPUEngine.d.ts +2 -0
  33. package/Engines/thinWebGPUEngine.js +7 -0
  34. package/Engines/thinWebGPUEngine.js.map +1 -1
  35. package/Engines/webgpuEngine.d.ts +12 -3
  36. package/Engines/webgpuEngine.js +39 -9
  37. package/Engines/webgpuEngine.js.map +1 -1
  38. package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +8 -0
  39. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +22 -1
  40. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  41. package/FrameGraph/Node/Blocks/inputBlock.d.ts +4 -9
  42. package/FrameGraph/Node/Blocks/inputBlock.js +15 -25
  43. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  44. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +10 -2
  45. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
  46. package/FrameGraph/Passes/renderPass.d.ts +10 -10
  47. package/FrameGraph/Passes/renderPass.js +10 -10
  48. package/FrameGraph/Passes/renderPass.js.map +1 -1
  49. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +10 -5
  50. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +29 -14
  51. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  52. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +4 -0
  53. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
  54. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +11 -6
  55. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +30 -13
  56. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  57. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +4 -6
  58. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  59. package/FrameGraph/Tasks/Rendering/cullObjectsTask.d.ts +1 -1
  60. package/FrameGraph/Tasks/Rendering/cullObjectsTask.js.map +1 -1
  61. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +3 -3
  62. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +33 -32
  63. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  64. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -2
  65. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +8 -12
  66. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  67. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +13 -18
  68. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
  69. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +15 -2
  70. package/FrameGraph/Tasks/Texture/clearTextureTask.js +17 -4
  71. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  72. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +2 -2
  73. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  74. package/FrameGraph/Tasks/Texture/generateMipMapsTask.js +3 -3
  75. package/FrameGraph/Tasks/Texture/generateMipMapsTask.js.map +1 -1
  76. package/FrameGraph/frameGraph.d.ts +11 -74
  77. package/FrameGraph/frameGraph.js +12 -126
  78. package/FrameGraph/frameGraph.js.map +1 -1
  79. package/FrameGraph/frameGraphRenderContext.d.ts +17 -8
  80. package/FrameGraph/frameGraphRenderContext.js +55 -43
  81. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  82. package/FrameGraph/frameGraphRenderTarget.d.ts +16 -0
  83. package/FrameGraph/frameGraphRenderTarget.js +67 -0
  84. package/FrameGraph/frameGraphRenderTarget.js.map +1 -0
  85. package/FrameGraph/frameGraphTask.d.ts +4 -3
  86. package/FrameGraph/frameGraphTask.js +41 -8
  87. package/FrameGraph/frameGraphTask.js.map +1 -1
  88. package/FrameGraph/frameGraphTextureManager.d.ts +130 -22
  89. package/FrameGraph/frameGraphTextureManager.js +312 -130
  90. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  91. package/FrameGraph/frameGraphTypes.d.ts +28 -13
  92. package/FrameGraph/frameGraphTypes.js.map +1 -1
  93. package/FrameGraph/index.d.ts +1 -0
  94. package/FrameGraph/index.js +1 -0
  95. package/FrameGraph/index.js.map +1 -1
  96. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +3 -2
  97. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  98. package/Materials/Node/Blocks/conditionalBlock.d.ts +2 -0
  99. package/Materials/Node/Blocks/conditionalBlock.js +13 -0
  100. package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
  101. package/Materials/Node/nodeMaterialBlock.js +4 -1
  102. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  103. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +12 -4
  104. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  105. package/Materials/Textures/equiRectangularCubeTexture.js +14 -4
  106. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  107. package/Materials/Textures/internalTexture.d.ts +20 -0
  108. package/Materials/Textures/internalTexture.js +48 -0
  109. package/Materials/Textures/internalTexture.js.map +1 -1
  110. package/Materials/Textures/multiRenderTarget.d.ts +5 -0
  111. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  112. package/Materials/Textures/textureCreationOptions.d.ts +6 -6
  113. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  114. package/Materials/drawWrapper.js +4 -0
  115. package/Materials/drawWrapper.js.map +1 -1
  116. package/Materials/effect.js +2 -2
  117. package/Materials/effect.js.map +1 -1
  118. package/Materials/material.d.ts +2 -2
  119. package/Materials/material.js +5 -5
  120. package/Materials/material.js.map +1 -1
  121. package/Maths/math.color.d.ts +16 -0
  122. package/Maths/math.color.js +16 -0
  123. package/Maths/math.color.js.map +1 -1
  124. package/Maths/math.vector.d.ts +32 -0
  125. package/Maths/math.vector.js +32 -0
  126. package/Maths/math.vector.js.map +1 -1
  127. package/Meshes/Compression/dracoCompression.d.ts +3 -1
  128. package/Meshes/Compression/dracoCompression.js +5 -2
  129. package/Meshes/Compression/dracoCompression.js.map +1 -1
  130. package/Meshes/Node/Blocks/Matrices/rotationXBlock.d.ts +0 -1
  131. package/Meshes/Node/Blocks/Matrices/rotationXBlock.js +1 -9
  132. package/Meshes/Node/Blocks/Matrices/rotationXBlock.js.map +1 -1
  133. package/Meshes/Node/Blocks/Matrices/rotationYBlock.d.ts +0 -1
  134. package/Meshes/Node/Blocks/Matrices/rotationYBlock.js +1 -9
  135. package/Meshes/Node/Blocks/Matrices/rotationYBlock.js.map +1 -1
  136. package/Meshes/Node/Blocks/Matrices/rotationZBlock.d.ts +0 -1
  137. package/Meshes/Node/Blocks/Matrices/rotationZBlock.js +1 -9
  138. package/Meshes/Node/Blocks/Matrices/rotationZBlock.js.map +1 -1
  139. package/Meshes/Node/Blocks/Set/latticeBlock.js +3 -1
  140. package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -1
  141. package/Meshes/Node/Blocks/conditionBlock.d.ts +2 -0
  142. package/Meshes/Node/Blocks/conditionBlock.js +15 -0
  143. package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
  144. package/Meshes/Node/Blocks/geometryClampBlock.d.ts +4 -4
  145. package/Meshes/Node/Blocks/geometryClampBlock.js +16 -25
  146. package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
  147. package/Meshes/Node/Blocks/geometryLerpBlock.js +2 -2
  148. package/Meshes/Node/Blocks/geometryLerpBlock.js.map +1 -1
  149. package/Meshes/Node/Blocks/geometryNLerpBlock.js +2 -2
  150. package/Meshes/Node/Blocks/geometryNLerpBlock.js.map +1 -1
  151. package/Meshes/Node/Blocks/geometryReplaceColorBlock.js +2 -2
  152. package/Meshes/Node/Blocks/geometryReplaceColorBlock.js.map +1 -1
  153. package/Meshes/Node/Blocks/geometryRotate2dBlock.js +2 -2
  154. package/Meshes/Node/Blocks/geometryRotate2dBlock.js.map +1 -1
  155. package/Meshes/Node/Blocks/geometrySmoothStepBlock.js +3 -3
  156. package/Meshes/Node/Blocks/geometrySmoothStepBlock.js.map +1 -1
  157. package/Meshes/Node/Blocks/geometryStepBlock.js +2 -2
  158. package/Meshes/Node/Blocks/geometryStepBlock.js.map +1 -1
  159. package/Meshes/Node/nodeGeometry.js +1 -1
  160. package/Meshes/Node/nodeGeometry.js.map +1 -1
  161. package/Meshes/Node/nodeGeometryBlock.d.ts +3 -1
  162. package/Meshes/Node/nodeGeometryBlock.js +2 -1
  163. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  164. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +10 -2
  165. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  166. package/Meshes/abstractMesh.js +1 -1
  167. package/Meshes/abstractMesh.js.map +1 -1
  168. package/Meshes/lattice.material.d.ts +1 -1
  169. package/Meshes/lattice.material.js +3 -3
  170. package/Meshes/lattice.material.js.map +1 -1
  171. package/Misc/observable.d.ts +3 -1
  172. package/Misc/observable.js +7 -2
  173. package/Misc/observable.js.map +1 -1
  174. package/ShadersWGSL/glowMapGeneration.fragment.js +4 -3
  175. package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -1
  176. package/ShadersWGSL/pbr.fragment.js +4 -3
  177. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  178. package/package.json +1 -1
  179. package/scene.js +6 -6
  180. package/scene.js.map +1 -1
@@ -4,6 +4,11 @@ import { FrameGraphTask } from "../../frameGraphTask.js";
4
4
  * Task used to clear a texture.
5
5
  */
6
6
  export class FrameGraphClearTextureTask extends FrameGraphTask {
7
+ /**
8
+ * Constructs a new clear task.
9
+ * @param name The name of the task.
10
+ * @param frameGraph The frame graph the task belongs to.
11
+ */
7
12
  constructor(name, frameGraph) {
8
13
  super(name, frameGraph);
9
14
  /**
@@ -22,20 +27,28 @@ export class FrameGraphClearTextureTask extends FrameGraphTask {
22
27
  * If the stencil should be cleared.
23
28
  */
24
29
  this.clearStencil = false;
25
- this.outputTexture = this._frameGraph.createDanglingHandle();
30
+ this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
31
+ this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
26
32
  }
27
33
  record() {
28
- if (this.destinationTexture === undefined) {
29
- throw new Error(`FrameGraphClearTextureTask ${this.name}: destinationTexture is required`);
34
+ if (this.destinationTexture === undefined && this.depthTexture === undefined) {
35
+ throw new Error(`FrameGraphClearTextureTask ${this.name}: destinationTexture and depthTexture can't both be undefined.`);
36
+ }
37
+ if (this.destinationTexture !== undefined) {
38
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
39
+ }
40
+ if (this.depthTexture !== undefined) {
41
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
30
42
  }
31
- this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
32
43
  const pass = this._frameGraph.addRenderPass(this.name);
33
44
  pass.setRenderTarget(this.destinationTexture);
45
+ pass.setRenderTargetDepth(this.depthTexture);
34
46
  pass.setExecuteFunc((context) => {
35
47
  context.clear(this.color, !!this.clearColor, !!this.clearDepth, !!this.clearStencil);
36
48
  });
37
49
  const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
38
50
  passDisabled.setRenderTarget(this.destinationTexture);
51
+ passDisabled.setRenderTargetDepth(this.depthTexture);
39
52
  passDisabled.setExecuteFunc((_context) => { });
40
53
  }
41
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OA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C,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACtD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Color4 } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTask {\r\n /**\r\n * The color to clear the texture with.\r\n */\r\n public color = new Color4(0.2, 0.2, 0.3, 1);\r\n\r\n /**\r\n * If the color should be cleared.\r\n */\r\n public clearColor = true;\r\n\r\n /**\r\n * If the depth should be cleared.\r\n */\r\n public clearDepth = false;\r\n\r\n /**\r\n * If the stencil should be cleared.\r\n */\r\n public clearStencil = false;\r\n\r\n /**\r\n * The texture to clear.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as destinationTexture, but the handle may be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.destinationTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: destinationTexture is required`);\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.clear(this.color, !!this.clearColor, !!this.clearDepth, !!this.clearStencil);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IAyC1D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QA9C5B;;WAEG;QACI,UAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAE5C;;WAEG;QACI,eAAU,GAAG,IAAI,CAAC;QAEzB;;WAEG;QACI,eAAU,GAAG,KAAK,CAAC;QAE1B;;WAEG;QACI,iBAAY,GAAG,KAAK,CAAC;QA8BxB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;QAC5E,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IACrF,CAAC;IAEM,MAAM;QACT,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAC3E,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,IAAI,gEAAgE,CAAC,CAAC;QAC7H,CAAC;QAED,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACvG,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAClC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACtG,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9C,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACtD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Color4 } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTask {\r\n /**\r\n * The color to clear the texture with.\r\n */\r\n public color = new Color4(0.2, 0.2, 0.3, 1);\r\n\r\n /**\r\n * If the color should be cleared.\r\n */\r\n public clearColor = true;\r\n\r\n /**\r\n * If the depth should be cleared.\r\n */\r\n public clearDepth = false;\r\n\r\n /**\r\n * If the stencil should be cleared.\r\n */\r\n public clearStencil = false;\r\n\r\n /**\r\n * The texture to clear.\r\n */\r\n public destinationTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture to clear.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as destinationTexture, but the handle will be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth texture (same as depthTexture, but the handle will be different).\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new clear task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.destinationTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: destinationTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n if (this.destinationTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.clear(this.color, !!this.clearColor, !!this.clearDepth, !!this.clearStencil);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
@@ -10,13 +10,13 @@ export class FrameGraphCopyToTextureTask extends FrameGraphTask {
10
10
  */
11
11
  constructor(name, frameGraph) {
12
12
  super(name, frameGraph);
13
- this.outputTexture = this._frameGraph.createDanglingHandle();
13
+ this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
14
14
  }
15
15
  record() {
16
16
  if (this.sourceTexture === undefined || this.destinationTexture === undefined) {
17
17
  throw new Error(`FrameGraphCopyToTextureTask "${this.name}": sourceTexture and destinationTexture are required`);
18
18
  }
19
- this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
19
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
20
20
  const pass = this._frameGraph.addRenderPass(this.name);
21
21
  pass.useTexture(this.sourceTexture);
22
22
  pass.setRenderTarget(this.outputTexture);
@@ -1 +1 @@
1
- {"version":3,"file":"copyToTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/copyToTextureTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,cAAc;IAgB3D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAExB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC;IACjE,CAAC;IAEM,MAAM;QACT,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,IAAI,sDAAsD,CAAC,CAAC;QACrH,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEpF,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to copy a texture to another texture.\r\n */\r\nexport class FrameGraphCopyToTextureTask extends FrameGraphTask {\r\n /**\r\n * The source texture to copy from.\r\n */\r\n public sourceTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The destination texture to copy to.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as destinationTexture, but the handle may be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new FrameGraphCopyToTextureTask.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.sourceTexture === undefined || this.destinationTexture === undefined) {\r\n throw new Error(`FrameGraphCopyToTextureTask \"${this.name}\": sourceTexture and destinationTexture are required`);\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.useTexture(this.sourceTexture);\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"copyToTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/copyToTextureTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,cAAc;IAgB3D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAExB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IAChF,CAAC;IAEM,MAAM;QACT,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,IAAI,sDAAsD,CAAC,CAAC;QACrH,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEnG,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to copy a texture to another texture.\r\n */\r\nexport class FrameGraphCopyToTextureTask extends FrameGraphTask {\r\n /**\r\n * The source texture to copy from.\r\n */\r\n public sourceTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The destination texture to copy to.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as destinationTexture, but the handle may be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new FrameGraphCopyToTextureTask.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.sourceTexture === undefined || this.destinationTexture === undefined) {\r\n throw new Error(`FrameGraphCopyToTextureTask \"${this.name}\": sourceTexture and destinationTexture are required`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.useTexture(this.sourceTexture);\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
@@ -10,14 +10,14 @@ export class FrameGraphGenerateMipMapsTask extends FrameGraphTask {
10
10
  */
11
11
  constructor(name, frameGraph) {
12
12
  super(name, frameGraph);
13
- this.outputTexture = this._frameGraph.createDanglingHandle();
13
+ this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
14
14
  }
15
15
  record() {
16
16
  if (this.destinationTexture === undefined) {
17
17
  throw new Error(`FrameGraphGenerateMipMapsTask ${this.name}: destinationTexture is required`);
18
18
  }
19
- this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
20
- const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);
19
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
20
+ const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);
21
21
  if (!outputTextureDescription.options.createMipMaps) {
22
22
  throw new Error(`FrameGraphGenerateMipMapsTask ${this.name}: destinationTexture must have createMipMaps set to true`);
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generateMipMapsTask.js","sourceRoot":"","sources":["../../../../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AAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task which generates mipmaps for a texture.\r\n */\r\nexport class FrameGraphGenerateMipMapsTask extends FrameGraphTask {\r\n /**\r\n * The texture to generate mipmaps for.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as destinationTexture, but the handle may be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new FrameGraphGenerateMipMapsTask.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.destinationTexture === undefined) {\r\n throw new Error(`FrameGraphGenerateMipMapsTask ${this.name}: destinationTexture is required`);\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);\r\n\r\n if (!outputTextureDescription.options.createMipMaps) {\r\n throw new Error(`FrameGraphGenerateMipMapsTask ${this.name}: destinationTexture must have createMipMaps set to true`);\r\n }\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.generateMipMaps();\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"generateMipMapsTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/generateMipMapsTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,cAAc;IAW7D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAExB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IAChF,CAAC;IAEM,MAAM;QACT,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,IAAI,kCAAkC,CAAC,CAAC;QAClG,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEnG,MAAM,wBAAwB,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEhH,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,IAAI,0DAA0D,CAAC,CAAC;QAC1H,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,OAAO,CAAC,eAAe,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task which generates mipmaps for a texture.\r\n */\r\nexport class FrameGraphGenerateMipMapsTask extends FrameGraphTask {\r\n /**\r\n * The texture to generate mipmaps for.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as destinationTexture, but the handle may be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new FrameGraphGenerateMipMapsTask.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.destinationTexture === undefined) {\r\n throw new Error(`FrameGraphGenerateMipMapsTask ${this.name}: destinationTexture is required`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n if (!outputTextureDescription.options.createMipMaps) {\r\n throw new Error(`FrameGraphGenerateMipMapsTask ${this.name}: destinationTexture must have createMipMaps set to true`);\r\n }\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.generateMipMaps();\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
@@ -1,21 +1,21 @@
1
- import type { Scene, AbstractEngine, RenderTargetWrapper, FrameGraphTextureCreationOptions, FrameGraphTextureHandle, FrameGraphTextureDescription, Nullable, FrameGraphTask } from "../index.js";
1
+ import type { Scene, AbstractEngine, FrameGraphTask } from "../index.js";
2
2
  import { FrameGraphRenderPass } from "./Passes/renderPass";
3
3
  import { FrameGraphCullPass } from "./Passes/cullPass";
4
- import { FrameGraphRenderContext } from "./frameGraphRenderContext";
5
- import { FrameGraphContext } from "./frameGraphContext";
4
+ import { FrameGraphTextureManager } from "./frameGraphTextureManager";
6
5
  import { Observable } from "../Misc/observable.js";
7
6
  /**
8
7
  * Class used to implement a frame graph
9
8
  * @experimental
10
9
  */
11
10
  export declare class FrameGraph {
12
- /** @internal */
13
- readonly _passContext: FrameGraphContext;
14
- /** @internal */
15
- readonly _renderContext: FrameGraphRenderContext;
11
+ /**
12
+ * Gets the texture manager used by the frame graph
13
+ */
14
+ readonly textureManager: FrameGraphTextureManager;
16
15
  private readonly _engine;
17
- private readonly _textureManager;
18
- private _tasks;
16
+ private readonly _tasks;
17
+ private readonly _passContext;
18
+ private readonly _renderContext;
19
19
  private _currentProcessedTask;
20
20
  /**
21
21
  * Observable raised when the node render graph is built
@@ -29,9 +29,9 @@ export declare class FrameGraph {
29
29
  * Constructs the frame graph
30
30
  * @param engine defines the hosting engine
31
31
  * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector
32
- * @param scene defines the scene in which debugging textures are to be created
32
+ * @param scene defines the scene the frame graph is associated with
33
33
  */
34
- constructor(engine: AbstractEngine, debugTextures?: boolean, scene?: Scene);
34
+ constructor(engine: AbstractEngine, debugTextures: boolean | undefined, scene: Scene);
35
35
  /**
36
36
  * Gets a task by name
37
37
  * @param name Name of the task to get
@@ -74,69 +74,6 @@ export declare class FrameGraph {
74
74
  * Executes the frame graph.
75
75
  */
76
76
  execute(): void;
77
- /**
78
- * Imports a texture into the frame graph
79
- * @param name Name of the texture
80
- * @param texture Texture to import
81
- * @param handle Existing handle to use for the texture. If not provided (default), a new handle will be created.
82
- * @returns The handle to the texture
83
- */
84
- importTexture(name: string, texture: RenderTargetWrapper, handle?: FrameGraphTextureHandle): FrameGraphTextureHandle;
85
- /**
86
- * Gets the creation options of a texture
87
- * @param handle Handle of the texture
88
- * @param cloneOptions If true, the options will be cloned before being returned (default is false)
89
- * @returns The creation options of the texture
90
- */
91
- getTextureCreationOptions(handle: FrameGraphTextureHandle, cloneOptions?: boolean): FrameGraphTextureCreationOptions;
92
- /**
93
- * Gets the description of a texture
94
- * @param handle Handle of the texture
95
- * @returns The description of the texture
96
- */
97
- getTextureDescription(handle: FrameGraphTextureHandle): FrameGraphTextureDescription;
98
- /**
99
- * Gets a texture handle or creates a new texture if the handle is not provided.
100
- * @param handle If provided, will simply return the handle
101
- * @param newTextureName Name of the new texture to create
102
- * @param creationOptions Options to use when creating the new texture
103
- * @returns The handle to the texture. If handle is not provided, newTextureName and creationOptions must be provided.
104
- */
105
- getTextureHandleOrCreateTexture(handle?: FrameGraphTextureHandle, newTextureName?: string, creationOptions?: FrameGraphTextureCreationOptions): FrameGraphTextureHandle;
106
- /**
107
- * Gets a texture from a handle
108
- * @param handle The handle of the texture
109
- * @returns The texture or null if not found
110
- */
111
- getTexture(handle: FrameGraphTextureHandle): Nullable<RenderTargetWrapper>;
112
- /**
113
- * Creates a new render target texture
114
- * @param name Name of the texture
115
- * @param creationOptions Options to use when creating the texture
116
- * @param multiTargetMode If true, the texture will be created in multi target mode (default is false). In this mode, a handle is created for each target separately, in addition to the handle created for the main render target texture itself.
117
- * @returns The handle to the texture
118
- */
119
- createRenderTargetTexture(name: string, creationOptions: FrameGraphTextureCreationOptions, multiTargetMode?: boolean): FrameGraphTextureHandle;
120
- /**
121
- * Creates a handle which is not associated with any texture.
122
- * Call resolveDanglingHandle to associate the handle with a valid texture handle.
123
- * @returns The dangling handle
124
- */
125
- createDanglingHandle(): FrameGraphTextureHandle;
126
- /**
127
- * Associates a texture with a dangling handle
128
- * @param danglingHandle The dangling handle
129
- * @param handle The handle to associate with the dangling handle (if not provided, a new texture handle will be created)
130
- * @param newTextureName The name of the new texture to create (if handle is not provided)
131
- * @param creationOptions The options to use when creating the new texture (if handle is not provided)
132
- */
133
- resolveDanglingHandle(danglingHandle: FrameGraphTextureHandle, handle?: FrameGraphTextureHandle, newTextureName?: string, creationOptions?: FrameGraphTextureCreationOptions): void;
134
- /**
135
- * Checks if a handle is a history texture (or points to a history texture, for a dangling handle)
136
- * @param handle The handle to check
137
- * @returns True if the handle is a history texture, otherwise false
138
- */
139
- isHistoryTexture(handle: FrameGraphTextureHandle): boolean;
140
77
  /**
141
78
  * Clears the frame graph (remove the tasks and release the textures).
142
79
  * The frame graph can be built again after this method is called.
@@ -5,7 +5,6 @@ import { FrameGraphRenderContext } from "./frameGraphRenderContext.js";
5
5
  import { FrameGraphContext } from "./frameGraphContext.js";
6
6
  import { FrameGraphTextureManager } from "./frameGraphTextureManager.js";
7
7
  import { Observable } from "../Misc/observable.js";
8
- import { getDimensionsFromTextureSize, textureSizeIsObject } from "../Materials/Textures/textureCreationOptions.js";
9
8
  var FrameGraphPassType;
10
9
  (function (FrameGraphPassType) {
11
10
  FrameGraphPassType[FrameGraphPassType["Render"] = 0] = "Render";
@@ -27,7 +26,7 @@ export class FrameGraph {
27
26
  * Constructs the frame graph
28
27
  * @param engine defines the hosting engine
29
28
  * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector
30
- * @param scene defines the scene in which debugging textures are to be created
29
+ * @param scene defines the scene the frame graph is associated with
31
30
  */
32
31
  constructor(engine, debugTextures = false, scene) {
33
32
  this._tasks = [];
@@ -37,9 +36,9 @@ export class FrameGraph {
37
36
  */
38
37
  this.onBuildObservable = new Observable();
39
38
  this._engine = engine;
40
- this._textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);
39
+ this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);
41
40
  this._passContext = new FrameGraphContext();
42
- this._renderContext = new FrameGraphRenderContext(this._engine, this._textureManager);
41
+ this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);
43
42
  }
44
43
  /**
45
44
  * Gets a task by name
@@ -101,14 +100,16 @@ export class FrameGraph {
101
100
  * 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).
102
101
  */
103
102
  build() {
104
- this._textureManager.releaseTextures(false);
103
+ this.textureManager._releaseTextures(false);
105
104
  for (const task of this._tasks) {
106
105
  task._reset();
107
106
  this._currentProcessedTask = task;
107
+ this.textureManager._isRecordingTask = true;
108
108
  task.record();
109
+ this.textureManager._isRecordingTask = false;
109
110
  this._currentProcessedTask = null;
110
111
  }
111
- this._textureManager.allocateTextures();
112
+ this.textureManager._allocateTextures();
112
113
  for (const task of this._tasks) {
113
114
  task._checkTask();
114
115
  }
@@ -123,9 +124,9 @@ export class FrameGraph {
123
124
  whenReadyAsync(timeout = 16) {
124
125
  return new Promise((resolve) => {
125
126
  const checkReady = () => {
126
- let ready = true;
127
+ let ready = this._renderContext._isReady();
127
128
  for (const task of this._tasks) {
128
- ready && (ready = task.isReady());
129
+ ready = task.isReady() && ready;
129
130
  }
130
131
  if (ready) {
131
132
  resolve();
@@ -142,7 +143,7 @@ export class FrameGraph {
142
143
  */
143
144
  execute() {
144
145
  this._renderContext.bindRenderTarget();
145
- this._textureManager.updateHistoryTextures();
146
+ this.textureManager._updateHistoryTextures();
146
147
  for (const task of this._tasks) {
147
148
  const passes = task._getPasses();
148
149
  for (const pass of passes) {
@@ -150,121 +151,6 @@ export class FrameGraph {
150
151
  }
151
152
  }
152
153
  }
153
- /**
154
- * Imports a texture into the frame graph
155
- * @param name Name of the texture
156
- * @param texture Texture to import
157
- * @param handle Existing handle to use for the texture. If not provided (default), a new handle will be created.
158
- * @returns The handle to the texture
159
- */
160
- importTexture(name, texture, handle) {
161
- return this._textureManager.importTexture(name, texture, handle);
162
- }
163
- /**
164
- * Gets the creation options of a texture
165
- * @param handle Handle of the texture
166
- * @param cloneOptions If true, the options will be cloned before being returned (default is false)
167
- * @returns The creation options of the texture
168
- */
169
- getTextureCreationOptions(handle, cloneOptions = false) {
170
- const creationOptions = this._textureManager.getTextureCreationOptions(handle);
171
- return cloneOptions
172
- ? {
173
- size: getDimensionsFromTextureSize(creationOptions.size),
174
- options: { ...creationOptions.options },
175
- sizeIsPercentage: creationOptions.sizeIsPercentage,
176
- }
177
- : creationOptions;
178
- }
179
- /**
180
- * Gets the description of a texture
181
- * @param handle Handle of the texture
182
- * @returns The description of the texture
183
- */
184
- getTextureDescription(handle) {
185
- const creationOptions = this.getTextureCreationOptions(handle);
186
- const size = !creationOptions.sizeIsPercentage
187
- ? textureSizeIsObject(creationOptions.size)
188
- ? { width: creationOptions.size.width, height: creationOptions.size.height }
189
- : { width: creationOptions.size, height: creationOptions.size }
190
- : this._textureManager.getAbsoluteDimensions(creationOptions.size);
191
- return {
192
- size,
193
- options: { ...creationOptions.options },
194
- };
195
- }
196
- /**
197
- * Gets a texture handle or creates a new texture if the handle is not provided.
198
- * @param handle If provided, will simply return the handle
199
- * @param newTextureName Name of the new texture to create
200
- * @param creationOptions Options to use when creating the new texture
201
- * @returns The handle to the texture. If handle is not provided, newTextureName and creationOptions must be provided.
202
- */
203
- getTextureHandleOrCreateTexture(handle, newTextureName, creationOptions) {
204
- if (handle === undefined) {
205
- if (newTextureName === undefined || creationOptions === undefined) {
206
- throw new Error("getTextureHandleOrCreateTexture: Either handle or newTextureName and creationOptions must be provided.");
207
- }
208
- return this.createRenderTargetTexture(newTextureName, creationOptions);
209
- }
210
- return handle;
211
- }
212
- /**
213
- * Gets a texture from a handle
214
- * @param handle The handle of the texture
215
- * @returns The texture or null if not found
216
- */
217
- getTexture(handle) {
218
- return this._textureManager.getTextureFromHandle(handle);
219
- }
220
- /**
221
- * Creates a new render target texture
222
- * @param name Name of the texture
223
- * @param creationOptions Options to use when creating the texture
224
- * @param multiTargetMode If true, the texture will be created in multi target mode (default is false). In this mode, a handle is created for each target separately, in addition to the handle created for the main render target texture itself.
225
- * @returns The handle to the texture
226
- */
227
- createRenderTargetTexture(name, creationOptions, multiTargetMode = false) {
228
- return this._textureManager.createRenderTargetTexture(name, !!this._currentProcessedTask, creationOptions, multiTargetMode);
229
- }
230
- /**
231
- * Creates a handle which is not associated with any texture.
232
- * Call resolveDanglingHandle to associate the handle with a valid texture handle.
233
- * @returns The dangling handle
234
- */
235
- createDanglingHandle() {
236
- return this._textureManager.createDanglingHandle();
237
- }
238
- /**
239
- * Associates a texture with a dangling handle
240
- * @param danglingHandle The dangling handle
241
- * @param handle The handle to associate with the dangling handle (if not provided, a new texture handle will be created)
242
- * @param newTextureName The name of the new texture to create (if handle is not provided)
243
- * @param creationOptions The options to use when creating the new texture (if handle is not provided)
244
- */
245
- resolveDanglingHandle(danglingHandle, handle, newTextureName, creationOptions) {
246
- if (handle === undefined) {
247
- if (newTextureName === undefined || creationOptions === undefined) {
248
- throw new Error("resolveDanglingHandle: Either handle or newTextureName and creationOptions must be provided.");
249
- }
250
- this._textureManager.createRenderTargetTexture(newTextureName, !!this._currentProcessedTask, creationOptions, false, danglingHandle);
251
- return;
252
- }
253
- this._textureManager.resolveDanglingHandle(danglingHandle, handle);
254
- }
255
- /**
256
- * Checks if a handle is a history texture (or points to a history texture, for a dangling handle)
257
- * @param handle The handle to check
258
- * @returns True if the handle is a history texture, otherwise false
259
- */
260
- isHistoryTexture(handle) {
261
- const entry = this._textureManager._textures.get(handle);
262
- if (!entry) {
263
- return false;
264
- }
265
- handle = entry.refHandle ?? handle;
266
- return this._textureManager._historyTextures.has(handle);
267
- }
268
154
  /**
269
155
  * Clears the frame graph (remove the tasks and release the textures).
270
156
  * The frame graph can be built again after this method is called.
@@ -274,7 +160,7 @@ export class FrameGraph {
274
160
  task._reset();
275
161
  }
276
162
  this._tasks.length = 0;
277
- this._textureManager.releaseTextures();
163
+ this.textureManager._releaseTextures();
278
164
  this._currentProcessedTask = null;
279
165
  }
280
166
  /**
@@ -282,7 +168,7 @@ export class FrameGraph {
282
168
  */
283
169
  dispose() {
284
170
  this.clear();
285
- this._textureManager.dispose();
171
+ this.textureManager._dispose();
286
172
  this._renderContext._dispose();
287
173
  }
288
174
  }
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,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,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAEjH,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACnB,+DAAU,CAAA;IACV,2DAAQ,CAAA;IACR,iEAAW,CAAA;AACf,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AAED;;;GAGG;AACH,MAAM,OAAO,UAAU;IAgBnB;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,YAAY,MAAsB,EAAE,aAAa,GAAG,KAAK,EAAE,KAAa;QArBhE,WAAM,GAAqB,EAAE,CAAC;QAC9B,0BAAqB,GAA0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AO,KAAK,CAAC;QACjB,CAAC;QAED,MAAM,GAAG,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC;QAEnC,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;CACJ","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport type {\r\n Scene,\r\n AbstractEngine,\r\n RenderTargetWrapper,\r\n FrameGraphTextureCreationOptions,\r\n FrameGraphTextureHandle,\r\n FrameGraphTextureDescription,\r\n Nullable,\r\n FrameGraphTask,\r\n} from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { getDimensionsFromTextureSize, textureSizeIsObject } from \"../Materials/Textures/textureCreationOptions\";\r\n\r\nenum FrameGraphPassType {\r\n Render = 0,\r\n Cull = 1,\r\n Compute = 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 {\r\n /** @internal */\r\n public readonly _passContext: FrameGraphContext;\r\n /** @internal */\r\n public readonly _renderContext: FrameGraphRenderContext;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _textureManager: FrameGraphTextureManager;\r\n private _tasks: FrameGraphTask[] = [];\r\n private _currentProcessedTask: FrameGraphTask | null = null;\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 * Constructs the frame graph\r\n * @param engine defines the hosting engine\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector\r\n * @param scene defines the scene in which debugging textures are to be created\r\n */\r\n constructor(engine: AbstractEngine, debugTextures = false, scene?: Scene) {\r\n this._engine = engine;\r\n this._textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext();\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this._textureManager);\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 * 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 }\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 a cull 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 cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\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.Cull:\r\n pass = new FrameGraphCullPass(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 /**\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 */\r\n public build(): void {\r\n this._textureManager.releaseTextures(false);\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n\r\n task.record();\r\n\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this._textureManager.allocateTextures();\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param timeout Timeout in ms between retries (default is 16)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public whenReadyAsync(timeout = 16): Promise<void> {\r\n return new Promise((resolve) => {\r\n const checkReady = () => {\r\n let ready = true;\r\n for (const task of this._tasks) {\r\n ready &&= task.isReady();\r\n }\r\n if (ready) {\r\n resolve();\r\n } else {\r\n setTimeout(checkReady, timeout);\r\n }\r\n };\r\n\r\n checkReady();\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n this._renderContext.bindRenderTarget();\r\n\r\n this._textureManager.updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Imports a texture into the frame graph\r\n * @param name Name of the texture\r\n * @param texture Texture to import\r\n * @param handle Existing handle to use for the texture. If not provided (default), a new handle will be created.\r\n * @returns The handle to the texture\r\n */\r\n public importTexture(name: string, texture: RenderTargetWrapper, handle?: FrameGraphTextureHandle): FrameGraphTextureHandle {\r\n return this._textureManager.importTexture(name, texture, handle);\r\n }\r\n\r\n /**\r\n * Gets the creation options of a texture\r\n * @param handle Handle of the texture\r\n * @param cloneOptions If true, the options will be cloned before being returned (default is false)\r\n * @returns The creation options of the texture\r\n */\r\n public getTextureCreationOptions(handle: FrameGraphTextureHandle, cloneOptions = false): FrameGraphTextureCreationOptions {\r\n const creationOptions = this._textureManager.getTextureCreationOptions(handle);\r\n\r\n return cloneOptions\r\n ? {\r\n size: getDimensionsFromTextureSize(creationOptions.size),\r\n options: { ...creationOptions.options },\r\n sizeIsPercentage: creationOptions.sizeIsPercentage,\r\n }\r\n : creationOptions;\r\n }\r\n\r\n /**\r\n * Gets the description of a texture\r\n * @param handle Handle of the texture\r\n * @returns The description of the texture\r\n */\r\n public getTextureDescription(handle: FrameGraphTextureHandle): FrameGraphTextureDescription {\r\n const creationOptions = this.getTextureCreationOptions(handle);\r\n\r\n const size = !creationOptions.sizeIsPercentage\r\n ? textureSizeIsObject(creationOptions.size)\r\n ? { width: creationOptions.size.width, height: creationOptions.size.height }\r\n : { width: creationOptions.size, height: creationOptions.size }\r\n : this._textureManager.getAbsoluteDimensions(creationOptions.size);\r\n\r\n return {\r\n size,\r\n options: { ...creationOptions.options },\r\n };\r\n }\r\n\r\n /**\r\n * Gets a texture handle or creates a new texture if the handle is not provided.\r\n * @param handle If provided, will simply return the handle\r\n * @param newTextureName Name of the new texture to create\r\n * @param creationOptions Options to use when creating the new texture\r\n * @returns The handle to the texture. If handle is not provided, newTextureName and creationOptions must be provided.\r\n */\r\n public getTextureHandleOrCreateTexture(handle?: FrameGraphTextureHandle, newTextureName?: string, creationOptions?: FrameGraphTextureCreationOptions): FrameGraphTextureHandle {\r\n if (handle === undefined) {\r\n if (newTextureName === undefined || creationOptions === undefined) {\r\n throw new Error(\"getTextureHandleOrCreateTexture: Either handle or newTextureName and creationOptions must be provided.\");\r\n }\r\n return this.createRenderTargetTexture(newTextureName, creationOptions);\r\n }\r\n return handle;\r\n }\r\n\r\n /**\r\n * Gets a texture from a handle\r\n * @param handle The handle of the texture\r\n * @returns The texture or null if not found\r\n */\r\n public getTexture(handle: FrameGraphTextureHandle): Nullable<RenderTargetWrapper> {\r\n return this._textureManager.getTextureFromHandle(handle);\r\n }\r\n\r\n /**\r\n * Creates a new render target texture\r\n * @param name Name of the texture\r\n * @param creationOptions Options to use when creating the texture\r\n * @param multiTargetMode If true, the texture will be created in multi target mode (default is false). In this mode, a handle is created for each target separately, in addition to the handle created for the main render target texture itself.\r\n * @returns The handle to the texture\r\n */\r\n public createRenderTargetTexture(name: string, creationOptions: FrameGraphTextureCreationOptions, multiTargetMode = false): FrameGraphTextureHandle {\r\n return this._textureManager.createRenderTargetTexture(name, !!this._currentProcessedTask, creationOptions, multiTargetMode);\r\n }\r\n\r\n /**\r\n * Creates a handle which is not associated with any texture.\r\n * Call resolveDanglingHandle to associate the handle with a valid texture handle.\r\n * @returns The dangling handle\r\n */\r\n public createDanglingHandle(): FrameGraphTextureHandle {\r\n return this._textureManager.createDanglingHandle();\r\n }\r\n\r\n /**\r\n * Associates a texture with a dangling handle\r\n * @param danglingHandle The dangling handle\r\n * @param handle The handle to associate with the dangling handle (if not provided, a new texture handle will be created)\r\n * @param newTextureName The name of the new texture to create (if handle is not provided)\r\n * @param creationOptions The options to use when creating the new texture (if handle is not provided)\r\n */\r\n public resolveDanglingHandle(\r\n danglingHandle: FrameGraphTextureHandle,\r\n handle?: FrameGraphTextureHandle,\r\n newTextureName?: string,\r\n creationOptions?: FrameGraphTextureCreationOptions\r\n ) {\r\n if (handle === undefined) {\r\n if (newTextureName === undefined || creationOptions === undefined) {\r\n throw new Error(\"resolveDanglingHandle: Either handle or newTextureName and creationOptions must be provided.\");\r\n }\r\n this._textureManager.createRenderTargetTexture(newTextureName, !!this._currentProcessedTask, creationOptions, false, danglingHandle);\r\n return;\r\n }\r\n\r\n this._textureManager.resolveDanglingHandle(danglingHandle, handle);\r\n }\r\n\r\n /**\r\n * Checks if a handle is a history texture (or points to a history texture, for a dangling handle)\r\n * @param handle The handle to check\r\n * @returns True if the handle is a history texture, otherwise false\r\n */\r\n public isHistoryTexture(handle: FrameGraphTextureHandle): boolean {\r\n const entry = this._textureManager._textures.get(handle);\r\n if (!entry) {\r\n return false;\r\n }\r\n\r\n handle = entry.refHandle ?? handle;\r\n\r\n return this._textureManager._historyTextures.has(handle);\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 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.clear();\r\n this._textureManager.dispose();\r\n this._renderContext._dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,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;AAElD,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACnB,+DAAU,CAAA;IACV,2DAAQ,CAAA;IACR,iEAAW,CAAA;AACf,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AAED;;;GAGG;AACH,MAAM,OAAO,UAAU;IAiBnB;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,YAAY,MAAsB,EAAE,aAAa,GAAG,KAAK,EAAE,KAAY;QAvBtD,WAAM,GAAqB,EAAE,CAAC;QAGvC,0BAAqB,GAA0B,IAAI,CAAC;QAE5D;;WAEG;QACI,sBAAiB,GAAG,IAAI,UAAU,EAAc,CAAC;QAgBpD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,cAAc,GAAG,IAAI,wBAAwB,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;QACvF,IAAI,CAAC,YAAY,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAuB,CAAC,IAAI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cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;CACJ","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport type { Scene, AbstractEngine, FrameGraphTask } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\nenum FrameGraphPassType {\r\n Render = 0,\r\n Cull = 1,\r\n Compute = 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 {\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 _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\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 * Constructs the frame graph\r\n * @param engine defines the hosting engine\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector\r\n * @param scene defines the scene the frame graph is associated with\r\n */\r\n constructor(engine: AbstractEngine, debugTextures = false, scene: Scene) {\r\n this._engine = engine;\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext();\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\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 * 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 }\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 a cull 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 cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\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.Cull:\r\n pass = new FrameGraphCullPass(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 /**\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 */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\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();\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param timeout Timeout in ms between retries (default is 16)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public whenReadyAsync(timeout = 16): Promise<void> {\r\n return new Promise((resolve) => {\r\n const checkReady = () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n ready = task.isReady() && ready;\r\n }\r\n if (ready) {\r\n resolve();\r\n } else {\r\n setTimeout(checkReady, timeout);\r\n }\r\n };\r\n\r\n checkReady();\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\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 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.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager, ObjectRenderer, Scene } from "../index.js";
1
+ import type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager, ObjectRenderer, Scene, FrameGraphRenderTarget } from "../index.js";
2
2
  import { FrameGraphContext } from "./frameGraphContext";
3
3
  /**
4
4
  * Frame graph context used render passes.
@@ -7,16 +7,16 @@ import { FrameGraphContext } from "./frameGraphContext";
7
7
  export declare class FrameGraphRenderContext extends FrameGraphContext {
8
8
  private readonly _engine;
9
9
  private readonly _textureManager;
10
- private readonly _scene?;
10
+ private readonly _scene;
11
11
  private readonly _effectRenderer;
12
- private _currentRenderTargetHandle;
12
+ private _currentRenderTarget;
13
13
  private _debugMessageWhenTargetBound;
14
14
  private _debugMessageHasBeenPushed;
15
15
  private _renderTargetIsBound;
16
16
  private readonly _copyTexture;
17
17
  private static _IsObjectRenderer;
18
18
  /** @internal */
19
- constructor(_engine: AbstractEngine, _textureManager: FrameGraphTextureManager, _scene?: Scene | undefined);
19
+ constructor(_engine: AbstractEngine, _textureManager: FrameGraphTextureManager, _scene: Scene);
20
20
  /**
21
21
  * Checks whether a texture handle points to the backbuffer's color or depth texture
22
22
  * @param handle The handle to check
@@ -35,6 +35,15 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
35
35
  * @returns True if the handle points to the backbuffer's depth texture, otherwise false
36
36
  */
37
37
  isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean;
38
+ /**
39
+ * Creates a (frame graph) render target wrapper
40
+ * Note that renderTargets or renderTargetDepth can be undefined, but not both at the same time!
41
+ * @param name Name of the render target wrapper
42
+ * @param renderTargets Render target handles (textures) to use
43
+ * @param renderTargetDepth Render target depth handle (texture) to use
44
+ * @returns The created render target wrapper
45
+ */
46
+ createRenderTarget(name: string, renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[], renderTargetDepth?: FrameGraphTextureHandle): FrameGraphRenderTarget;
38
47
  /**
39
48
  * Clears the current render buffer or the current render target (if any is set up)
40
49
  * @param color Defines the color to use
@@ -101,15 +110,15 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
101
110
  * Binds a render target texture so that upcoming draw calls will render to it
102
111
  * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call
103
112
  * this method several times with different render targets without incurring the cost of binding if no draw calls are made
104
- * @param renderTargetHandle The handle of the render target texture to bind (default: backbufferColorTextureHandle)
113
+ * @param renderTarget The handle of the render target texture to bind (default: undefined, meaning "back buffer"). Pass an array for MRT rendering.
105
114
  * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)
106
115
  */
107
- bindRenderTarget(renderTargetHandle?: FrameGraphTextureHandle, debugMessage?: string): void;
116
+ bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string): void;
108
117
  /** @internal */
109
118
  _flushDebugMessages(): void;
110
- /** @internal */
111
- _shareDepth(srcRenderTargetHandle: FrameGraphTextureHandle, dstRenderTargetHandle: FrameGraphTextureHandle): void;
112
119
  private _applyRenderTarget;
113
120
  /** @internal */
121
+ _isReady(): boolean;
122
+ /** @internal */
114
123
  _dispose(): void;
115
124
  }