@babylonjs/core 8.42.0 → 8.44.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 (171) hide show
  1. package/AudioV2/webAudio/components/webAudioParameterComponent.js +17 -5
  2. package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
  3. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +2 -2
  4. package/Cameras/Inputs/geospatialCameraPointersInput.js +3 -12
  5. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  6. package/Cameras/cameraMovement.d.ts +4 -4
  7. package/Cameras/cameraMovement.js +13 -14
  8. package/Cameras/cameraMovement.js.map +1 -1
  9. package/Cameras/geospatialCamera.d.ts +1 -2
  10. package/Cameras/geospatialCamera.js +22 -19
  11. package/Cameras/geospatialCamera.js.map +1 -1
  12. package/Cameras/geospatialCameraMovement.d.ts +0 -5
  13. package/Cameras/geospatialCameraMovement.js.map +1 -1
  14. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -10
  15. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  16. package/Engines/WebGPU/Extensions/engine.renderTarget.js +4 -2
  17. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  18. package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
  19. package/Engines/WebGPU/webgpuDrawContext.js +8 -0
  20. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  21. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +4 -3
  22. package/Engines/WebGPU/webgpuHardwareTexture.js +27 -21
  23. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  24. package/Engines/WebGPU/webgpuTextureManager.d.ts +5 -4
  25. package/Engines/WebGPU/webgpuTextureManager.js +20 -30
  26. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  27. package/Engines/abstractEngine.js +2 -2
  28. package/Engines/abstractEngine.js.map +1 -1
  29. package/Engines/engine.d.ts +1 -0
  30. package/Engines/thinEngine.js +9 -1
  31. package/Engines/thinEngine.js.map +1 -1
  32. package/Engines/thinWebGPUEngine.js +2 -3
  33. package/Engines/thinWebGPUEngine.js.map +1 -1
  34. package/Engines/webgpuEngine.js +28 -13
  35. package/Engines/webgpuEngine.js.map +1 -1
  36. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +2 -2
  37. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  38. package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +1 -1
  39. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +2 -2
  40. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  41. package/FrameGraph/Node/Blocks/inputBlock.js +4 -0
  42. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  43. package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +1 -0
  44. package/FrameGraph/Node/nodeRenderGraphBlock.js +19 -0
  45. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  46. package/FrameGraph/Passes/renderPass.d.ts +16 -0
  47. package/FrameGraph/Passes/renderPass.js +12 -0
  48. package/FrameGraph/Passes/renderPass.js.map +1 -1
  49. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +3 -3
  50. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +4 -4
  51. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  52. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +2 -2
  53. package/FrameGraph/Tasks/Texture/clearTextureTask.js +3 -2
  54. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  55. package/FrameGraph/frameGraph.d.ts +6 -0
  56. package/FrameGraph/frameGraph.js +10 -0
  57. package/FrameGraph/frameGraph.js.map +1 -1
  58. package/FrameGraph/frameGraphRenderContext.js +4 -15
  59. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  60. package/FrameGraph/frameGraphTask.d.ts +2 -2
  61. package/FrameGraph/frameGraphTask.js +6 -6
  62. package/FrameGraph/frameGraphTask.js.map +1 -1
  63. package/FrameGraph/frameGraphTaskMultiRenderTarget.d.ts +15 -0
  64. package/FrameGraph/frameGraphTaskMultiRenderTarget.js +25 -0
  65. package/FrameGraph/frameGraphTaskMultiRenderTarget.js.map +1 -0
  66. package/FrameGraph/frameGraphTextureManager.js +13 -2
  67. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  68. package/FrameGraph/frameGraphTypes.d.ts +9 -1
  69. package/FrameGraph/frameGraphTypes.js.map +1 -1
  70. package/Layers/glowLayer.d.ts +8 -0
  71. package/Layers/glowLayer.js +11 -0
  72. package/Layers/glowLayer.js.map +1 -1
  73. package/Layers/thinGlowLayer.d.ts +17 -0
  74. package/Layers/thinGlowLayer.js +18 -0
  75. package/Layers/thinGlowLayer.js.map +1 -1
  76. package/Lights/Clustered/clusteredLightContainer.js +7 -2
  77. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  78. package/Materials/Node/Blocks/Dual/lightBlock.js +2 -1
  79. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  80. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -1
  81. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  82. package/Materials/Node/nodeMaterial.js +2 -2
  83. package/Materials/Node/nodeMaterial.js.map +1 -1
  84. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
  85. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  86. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  87. package/Materials/Textures/envCubeTexture.js +4 -0
  88. package/Materials/Textures/envCubeTexture.js.map +1 -1
  89. package/Materials/Textures/textureCreationOptions.d.ts +2 -0
  90. package/Materials/Textures/textureCreationOptions.js +0 -1
  91. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  92. package/Materials/index.d.ts +1 -0
  93. package/Materials/index.js +1 -0
  94. package/Materials/index.js.map +1 -1
  95. package/Materials/materialHelper.functions.js +1 -0
  96. package/Materials/materialHelper.functions.js.map +1 -1
  97. package/Materials/shaderMaterial.d.ts +1 -0
  98. package/Materials/shaderMaterial.js +22 -7
  99. package/Materials/shaderMaterial.js.map +1 -1
  100. package/Materials/standardMaterial.d.ts +1 -0
  101. package/Materials/standardMaterial.js +1 -0
  102. package/Materials/standardMaterial.js.map +1 -1
  103. package/Materials/vertexPullingHelper.functions.d.ts +32 -0
  104. package/Materials/vertexPullingHelper.functions.js +60 -0
  105. package/Materials/vertexPullingHelper.functions.js.map +1 -0
  106. package/Meshes/abstractMesh.js +1 -1
  107. package/Meshes/abstractMesh.js.map +1 -1
  108. package/Meshes/geometry.js +1 -0
  109. package/Meshes/geometry.js.map +1 -1
  110. package/Particles/solidParticleSystem.d.ts +2 -1
  111. package/Particles/solidParticleSystem.js.map +1 -1
  112. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -0
  113. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  114. package/Rendering/depthPeelingRenderer.d.ts +1 -0
  115. package/Rendering/depthPeelingRenderer.js +7 -0
  116. package/Rendering/depthPeelingRenderer.js.map +1 -1
  117. package/Rendering/thinDepthPeelingRenderer.d.ts +1 -0
  118. package/Rendering/thinDepthPeelingRenderer.js +2 -0
  119. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  120. package/Shaders/ShadersInclude/lightFragment.js +7 -5
  121. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  122. package/Shaders/ShadersInclude/lightUboDeclaration.js +1 -1
  123. package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
  124. package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js +1 -1
  125. package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
  126. package/Shaders/ShadersInclude/lightVxUboDeclaration.js +1 -1
  127. package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
  128. package/Shaders/ShadersInclude/openpbrDirectLighting.js +4 -4
  129. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  130. package/Shaders/ShadersInclude/openpbrDirectLightingInit.js +4 -2
  131. package/Shaders/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
  132. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +4 -12
  133. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  134. package/Shaders/default.vertex.js +4 -0
  135. package/Shaders/default.vertex.js.map +1 -1
  136. package/Shaders/lightProxy.vertex.js +7 -1
  137. package/Shaders/lightProxy.vertex.js.map +1 -1
  138. package/Shaders/pbr.vertex.js +4 -0
  139. package/Shaders/pbr.vertex.js.map +1 -1
  140. package/Shaders/picking.vertex.js +2 -2
  141. package/Shaders/picking.vertex.js.map +1 -1
  142. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
  143. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
  144. package/ShadersWGSL/ShadersInclude/lightFragment.js +6 -4
  145. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
  146. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +1 -1
  147. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
  148. package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js +1 -1
  149. package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
  150. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +1 -1
  151. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
  152. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +4 -4
  153. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  154. package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js +4 -2
  155. package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
  156. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +8 -14
  157. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  158. package/ShadersWGSL/default.vertex.js +4 -0
  159. package/ShadersWGSL/default.vertex.js.map +1 -1
  160. package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +2 -0
  161. package/ShadersWGSL/iblVoxelGrid.vertex.js +78 -8
  162. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  163. package/ShadersWGSL/lightProxy.vertex.js +7 -1
  164. package/ShadersWGSL/lightProxy.vertex.js.map +1 -1
  165. package/ShadersWGSL/pbr.vertex.js +4 -0
  166. package/ShadersWGSL/pbr.vertex.js.map +1 -1
  167. package/ShadersWGSL/picking.vertex.js +2 -2
  168. package/ShadersWGSL/picking.vertex.js.map +1 -1
  169. package/package.json +1 -1
  170. package/scene.js +2 -3
  171. package/scene.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IAmD1D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAxD5B;;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,8BAAyB,GAAG,KAAK,CAAC;QAEzC;;WAEG;QACI,eAAU,GAAG,KAAK,CAAC;QAE1B;;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AAC,YAAY,CAAC,CAAC;YACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureHandle, FrameGraphRenderPass } from \"core/index\";\r\nimport { Color4, TmpColors } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { backbufferColorTextureHandle } from \"../../frameGraphTypes\";\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 color should be converted to linear space (default: false).\r\n */\r\n public convertColorToLinearSpace = false;\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 value to use to clear the stencil buffer (default: 0).\r\n */\r\n public stencilValue = 0;\r\n\r\n /**\r\n * The color texture to clear.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle | 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 targetTexture, 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 override getClassName(): string {\r\n return \"FrameGraphClearTextureTask\";\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n if (this.targetTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n const targetTextures = this.targetTexture !== undefined ? (Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture]) : undefined;\r\n\r\n if (this.targetTexture !== undefined) {\r\n textureManager.resolveDanglingHandle(this.outputTexture, targetTextures![0]);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n if (this.targetTexture !== undefined && this.depthTexture !== undefined) {\r\n const targetDescription = textureManager.getTextureDescription(targetTextures![0]);\r\n const depthDescription = textureManager.getTextureDescription(this.depthTexture);\r\n\r\n if (targetDescription.size.width !== depthDescription.size.width || targetDescription.size.height !== depthDescription.size.height) {\r\n throw new Error(\r\n `FrameGraphClearTextureTask ${this.name}: the depth texture (size: ${depthDescription.size.width}x${depthDescription.size.height}) and the target texture (size: ${targetDescription.size.width}x${targetDescription.size.height}) must have the same dimensions.`\r\n );\r\n }\r\n\r\n const textureSamples = targetDescription.options.samples || 1;\r\n const depthSamples = depthDescription.options.samples || 1;\r\n\r\n if (textureSamples !== depthSamples && textureSamples !== 0 && depthSamples !== 0) {\r\n throw new Error(\r\n `FrameGraphClearTextureTask ${this.name}: the depth texture (${depthSamples} samples) and the target texture (${textureSamples} samples) must have the same number of samples.`\r\n );\r\n }\r\n }\r\n\r\n const attachments = this._frameGraph.engine.buildTextureLayout(\r\n targetTextures ? Array(targetTextures.length).fill(true) : [],\r\n this.targetTexture === backbufferColorTextureHandle && !this._frameGraph.textureManager.backBufferTextureOverriden\r\n );\r\n\r\n const color = TmpColors.Color4[0];\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(targetTextures);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setInitializeFunc(() => {\r\n const renderTargetWrapper = pass.frameGraphRenderTarget.renderTargetWrapper;\r\n if (renderTargetWrapper) {\r\n renderTargetWrapper.disableAutomaticMSAAResolve = true;\r\n }\r\n });\r\n pass.setExecuteFunc((context) => {\r\n color.copyFrom(this.color);\r\n if (this.convertColorToLinearSpace) {\r\n color.toLinearSpaceToRef(color);\r\n }\r\n\r\n context.clearAttachments(color, attachments, !!this.clearColor, !!this.clearDepth, !!this.clearStencil, this.stencilValue);\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(targetTextures);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,+BAA+B;IAmD3E;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAxD5B;;WAEG;QACI,UAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAE5C;;WAEG;QACI,e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AC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAEnF,YAAY,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YAC7C,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureHandle, FrameGraphRenderPass } from \"core/index\";\r\nimport { Color4, TmpColors } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTaskMultiRenderTarget } from \"../../frameGraphTaskMultiRenderTarget\";\r\nimport { backbufferColorTextureHandle } from \"../../frameGraphTypes\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTaskMultiRenderTarget {\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 color should be converted to linear space (default: false).\r\n */\r\n public convertColorToLinearSpace = false;\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 value to use to clear the stencil buffer (default: 0).\r\n */\r\n public stencilValue = 0;\r\n\r\n /**\r\n * The color texture to clear.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle | 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 targetTexture, 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 override getClassName(): string {\r\n return \"FrameGraphClearTextureTask\";\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n if (this.targetTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n const targetTextures = this.targetTexture !== undefined ? (Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture]) : undefined;\r\n\r\n if (this.targetTexture !== undefined) {\r\n textureManager.resolveDanglingHandle(this.outputTexture, targetTextures![0]);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n if (this.targetTexture !== undefined && this.depthTexture !== undefined) {\r\n const targetDescription = textureManager.getTextureDescription(targetTextures![0]);\r\n const depthDescription = textureManager.getTextureDescription(this.depthTexture);\r\n\r\n if (targetDescription.size.width !== depthDescription.size.width || targetDescription.size.height !== depthDescription.size.height) {\r\n throw new Error(\r\n `FrameGraphClearTextureTask ${this.name}: the depth texture (size: ${depthDescription.size.width}x${depthDescription.size.height}) and the target texture (size: ${targetDescription.size.width}x${targetDescription.size.height}) must have the same dimensions.`\r\n );\r\n }\r\n\r\n const textureSamples = targetDescription.options.samples || 1;\r\n const depthSamples = depthDescription.options.samples || 1;\r\n\r\n if (textureSamples !== depthSamples && textureSamples !== 0 && depthSamples !== 0) {\r\n throw new Error(\r\n `FrameGraphClearTextureTask ${this.name}: the depth texture (${depthSamples} samples) and the target texture (${textureSamples} samples) must have the same number of samples.`\r\n );\r\n }\r\n }\r\n\r\n const attachments = this._frameGraph.engine.buildTextureLayout(\r\n targetTextures ? Array(targetTextures.length).fill(true) : [],\r\n this.targetTexture === backbufferColorTextureHandle && !this._frameGraph.textureManager.backBufferTextureOverriden\r\n );\r\n\r\n const color = TmpColors.Color4[0];\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(targetTextures);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setInitializeFunc(() => {\r\n const renderTargetWrapper = pass.frameGraphRenderTarget.renderTargetWrapper;\r\n if (renderTargetWrapper) {\r\n renderTargetWrapper.disableAutomaticMSAAResolve = true;\r\n }\r\n });\r\n pass.setExecuteFunc((context) => {\r\n this._updateLayerAndFaceIndices(pass);\r\n\r\n color.copyFrom(this.color);\r\n if (this.convertColorToLinearSpace) {\r\n color.toLinearSpaceToRef(color);\r\n }\r\n\r\n context.clearAttachments(color, attachments, !!this.clearColor, !!this.clearDepth, !!this.clearStencil, this.stencilValue);\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(targetTextures);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
@@ -85,6 +85,12 @@ export declare class FrameGraph implements IDisposable {
85
85
  * @returns The list of tasks of the specified type
86
86
  */
87
87
  getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[];
88
+ /**
89
+ * Gets all tasks of a specific type, based on their class name
90
+ * @param taskClassName Class name(s) of the task(s) to get
91
+ * @returns The list of tasks of the specified type
92
+ */
93
+ getTasksByClassName<T extends FrameGraphTask>(taskClassName: string | string[]): T[];
88
94
  /**
89
95
  * Adds a task to the frame graph
90
96
  * @param task Task to add
@@ -108,6 +108,16 @@ export class FrameGraph {
108
108
  getTasksByType(taskType) {
109
109
  return this._tasks.filter((t) => t instanceof taskType);
110
110
  }
111
+ /**
112
+ * Gets all tasks of a specific type, based on their class name
113
+ * @param taskClassName Class name(s) of the task(s) to get
114
+ * @returns The list of tasks of the specified type
115
+ */
116
+ getTasksByClassName(taskClassName) {
117
+ return Array.isArray(taskClassName)
118
+ ? this._tasks.filter((t) => taskClassName.includes(t.getClassName()))
119
+ : this._tasks.filter((t) => t.getClassName() === taskClassName);
120
+ }
111
121
  /**
112
122
  * Adds a task to the frame graph
113
123
  * @param task Task to add
@@ -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,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,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G;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\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"]}
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;I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AAC,qBAAqB,GAAG,IAAI,CAAC;QAElC,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,cAAc,CAAC,gBAAgB,EAAE,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\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 * Gets all tasks of a specific type, based on their class name\r\n * @param taskClassName Class name(s) of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByClassName<T extends FrameGraphTask>(taskClassName: string | string[]): T[] {\r\n return Array.isArray(taskClassName)\r\n ? (this._tasks.filter((t) => taskClassName.includes(t.getClassName())) as T[])\r\n : (this._tasks.filter((t) => t.getClassName() === taskClassName) 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"]}
@@ -273,19 +273,6 @@ export class FrameGraphRenderContext extends FrameGraphContext {
273
273
  * @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).
274
274
  */
275
275
  bindRenderTarget(renderTarget, debugMessage, applyImmediately = false) {
276
- if ((renderTarget?.renderTargetWrapper === undefined && this._currentRenderTarget === undefined) ||
277
- (renderTarget && this._currentRenderTarget && renderTarget.equals(this._currentRenderTarget))) {
278
- this._flushDebugMessages();
279
- if (debugMessage !== undefined) {
280
- this.pushDebugGroup(debugMessage);
281
- this._debugMessageWhenTargetBound = undefined;
282
- this._debugMessageHasBeenPushed = true;
283
- }
284
- if (applyImmediately) {
285
- this._applyRenderTarget();
286
- }
287
- return;
288
- }
289
276
  this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;
290
277
  this._debugMessageWhenTargetBound = debugMessage;
291
278
  this._renderTargetIsBound = false;
@@ -308,9 +295,11 @@ export class FrameGraphRenderContext extends FrameGraphContext {
308
295
  this._flushDebugMessages();
309
296
  const renderTargetWrapper = this._currentRenderTarget?.renderTargetWrapper;
310
297
  if (renderTargetWrapper === undefined) {
311
- this._engine.restoreDefaultFramebuffer();
298
+ if (this._engine._currentRenderTarget) {
299
+ this._engine.restoreDefaultFramebuffer();
300
+ }
312
301
  }
313
- else {
302
+ else if (this._engine._currentRenderTarget !== renderTargetWrapper) {
314
303
  if (this._engine._currentRenderTarget) {
315
304
  this._engine.unBindFramebuffer(this._engine._currentRenderTarget);
316
305
  }
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraphRenderContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderContext.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAE/E,MAAM,8BAA8B,GAAG;IACnC,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,yDAAyD;IAChE,KAAK,EAAE,wDAAwD;IAC/D,IAAI,EAAE,mEAAmE;IACzE,IAAI,EAAE,qCAAqC;IAC3C,IAAI,EAAE,oCAAoC;IAC1C,IAAI,EAAE,mCAAmC;IACzC,KAAK,EA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IAED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type {\r\n Nullable,\r\n AbstractEngine,\r\n DrawWrapper,\r\n IColor4Like,\r\n Layer,\r\n FrameGraphTextureHandle,\r\n Effect,\r\n FrameGraphTextureManager,\r\n ObjectRenderer,\r\n Scene,\r\n FrameGraphRenderTarget,\r\n InternalTexture,\r\n UtilityLayerRenderer,\r\n IStencilState,\r\n IStencilStateProperties,\r\n} from \"core/index\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer } from \"../Materials/effectRenderer\";\r\nimport { CopyTextureToTexture } from \"../Misc/copyTextureToTexture\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { IsDepthTexture } from \"../Materials/Textures/textureHelper.functions\";\r\n\r\nconst SamplingModeHasMipMapFiltering = [\r\n false, // not used\r\n false, // TEXTURE_NEAREST_SAMPLINGMODE / TEXTURE_NEAREST_NEAREST\r\n false, // TEXTURE_BILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR\r\n true, // TEXTURE_TRILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR_MIPLINEAR\r\n true, // TEXTURE_NEAREST_NEAREST_MIPNEAREST\r\n true, // TEXTURE_NEAREST_LINEAR_MIPNEAREST\r\n true, // TEXTURE_NEAREST_LINEAR_MIPLINEAR\r\n false, // TEXTURE_NEAREST_LINEAR\r\n true, // TEXTURE_NEAREST_NEAREST_MIPLINEAR\r\n true, // TEXTURE_LINEAR_NEAREST_MIPNEAREST\r\n true, // TEXTURE_LINEAR_NEAREST_MIPLINEAR\r\n true, // TEXTURE_LINEAR_LINEAR_MIPNEAREST\r\n false, // TEXTURE_LINEAR_NEAREST\r\n];\r\n\r\n/**\r\n * Frame graph context used render passes.\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderContext extends FrameGraphContext {\r\n private readonly _effectRenderer: EffectRenderer;\r\n private readonly _effectRendererBack: EffectRenderer;\r\n private _currentRenderTarget: FrameGraphRenderTarget | undefined;\r\n private _debugMessageWhenTargetBound: string | undefined;\r\n private _debugMessageHasBeenPushed = false;\r\n private _renderTargetIsBound = true;\r\n private readonly _copyTexture: CopyTextureToTexture;\r\n private readonly _copyDepthTexture: CopyTextureToTexture;\r\n\r\n private static _IsObjectRenderer(value: Layer | ObjectRenderer | UtilityLayerRenderer): value is ObjectRenderer {\r\n return (value as ObjectRenderer).initRender !== undefined;\r\n }\r\n\r\n /** @internal */\r\n constructor(engine: AbstractEngine, textureManager: FrameGraphTextureManager, scene: Scene) {\r\n super(engine, textureManager, scene);\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._effectRendererBack = new EffectRenderer(this._engine, {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 2, 1, 0, 3, 2],\r\n });\r\n this._copyTexture = new CopyTextureToTexture(this._engine);\r\n this._copyDepthTexture = new CopyTextureToTexture(this._engine, true);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color or depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color or depth texture, otherwise false\r\n */\r\n public isBackbuffer(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager._isBackbuffer(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color texture, otherwise false\r\n */\r\n public isBackbufferColor(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferColor(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's depth texture, otherwise false\r\n */\r\n public isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferDepthStencil(handle);\r\n }\r\n\r\n /**\r\n * Creates a (frame graph) render target wrapper\r\n * Note that renderTargets or renderTargetDepth can be undefined, but not both at the same time!\r\n * @param name Name of the render target wrapper\r\n * @param renderTargets Render target handles (textures) to use\r\n * @param renderTargetDepth Render target depth handle (texture) to use\r\n * @param depthReadOnly If true, the depth buffer will be read-only\r\n * @param stencilReadOnly If true, the stencil buffer will be read-only\r\n * @returns The created render target wrapper\r\n */\r\n public createRenderTarget(\r\n name: string,\r\n renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[],\r\n renderTargetDepth?: FrameGraphTextureHandle,\r\n depthReadOnly?: boolean,\r\n stencilReadOnly?: boolean\r\n ): FrameGraphRenderTarget {\r\n return this._textureManager.createRenderTarget(name, renderTargets, renderTargetDepth, depthReadOnly, stencilReadOnly);\r\n }\r\n\r\n /**\r\n * Clears the current render buffer or the current render target (if any is set up)\r\n * @param color Defines the color to use\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Clears the color attachments of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n */\r\n public clearColorAttachments(color: Nullable<IColor4Like>, attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, true, false, false);\r\n }\r\n\r\n /**\r\n * Clears all attachments (color(s) + depth/stencil) of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clearAttachments(color: Nullable<IColor4Like>, attachments: number[], backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Binds the attachments to the current render target\r\n * @param attachments The attachments to bind\r\n */\r\n public bindAttachments(attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n }\r\n\r\n /**\r\n * Generates mipmaps for the current render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._currentRenderTarget?.renderTargetWrapper === undefined) {\r\n return;\r\n }\r\n\r\n if (this._engine._currentRenderTarget && (!this._engine.isWebGPU || this._renderTargetIsBound)) {\r\n // we can't generate the mipmaps if the render target (which is the texture we want to generate mipmaps for) is bound\r\n // Also, for some reasons, on WebGL2, generating mipmaps doesn't work if a render target is bound, even if it's not the texture we want to generate mipmaps for...\r\n this._flushDebugMessages();\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n const textures = this._currentRenderTarget.renderTargetWrapper.textures;\r\n if (textures) {\r\n for (const texture of textures) {\r\n this._engine.generateMipmaps(texture);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the texture sampling mode for a given texture handle\r\n * @param handle Handle of the texture to set the sampling mode for\r\n * @param samplingMode Sampling mode to set\r\n */\r\n public setTextureSamplingMode(handle: FrameGraphTextureHandle, samplingMode: number): void {\r\n const internalTexture = this._textureManager.getTextureFromHandle(handle);\r\n if (internalTexture && internalTexture.samplingMode !== samplingMode) {\r\n internalTexture.useMipMaps = SamplingModeHasMipMapFiltering[samplingMode];\r\n this._engine.updateTextureSamplingMode(samplingMode, internalTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Binds a texture handle to a given effect (resolves the handle to a texture and binds it to the effect)\r\n * @param effect The effect to bind the texture to\r\n * @param name The name of the texture in the effect\r\n * @param handle The handle of the texture to bind\r\n */\r\n public bindTextureHandle(effect: Effect, name: string, handle: FrameGraphTextureHandle): void {\r\n let texture: Nullable<InternalTexture>;\r\n\r\n const historyEntry = this._textureManager._historyTextures.get(handle);\r\n if (historyEntry) {\r\n texture = historyEntry.textures[historyEntry.index]; // texture we write to in this frame\r\n if (\r\n this._currentRenderTarget !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper.textures!.includes(texture!)\r\n ) {\r\n // If the current render target renders to the history write texture, we bind the read texture instead\r\n texture = historyEntry.textures[historyEntry.index ^ 1];\r\n }\r\n } else {\r\n texture = this._textureManager._textures.get(handle)!.texture;\r\n }\r\n\r\n effect._bindTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Applies a full-screen effect to the current render target\r\n * @param drawWrapper The draw wrapper containing the effect to apply\r\n * @param customBindings The custom bindings to use when applying the effect (optional)\r\n * @param stencilState The stencil state to use when applying the effect (optional)\r\n * @param disableColorWrite If true, color write will be disabled when applying the effect (optional)\r\n * @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)\r\n * @param depthTest If true, depth testing will be enabled when applying the effect (default is false)\r\n * @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.\r\n * @returns True if the effect was applied, otherwise false (effect not ready)\r\n */\r\n public applyFullScreenEffect(\r\n drawWrapper: DrawWrapper,\r\n customBindings?: () => void,\r\n stencilState?: IStencilState | IStencilStateProperties,\r\n disableColorWrite?: boolean,\r\n drawBackFace?: boolean,\r\n depthTest?: boolean,\r\n noViewport?: boolean\r\n ): boolean {\r\n if (!drawWrapper.effect?.isReady()) {\r\n return false;\r\n }\r\n\r\n this._applyRenderTarget();\r\n\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n\r\n const effectRenderer = drawBackFace ? this._effectRendererBack : this._effectRenderer;\r\n\r\n effectRenderer.saveStates();\r\n if (!noViewport) {\r\n effectRenderer.setViewport();\r\n }\r\n\r\n this._engine.enableEffect(drawWrapper);\r\n this._engine.setState(false, undefined, undefined, undefined, undefined, stencilState);\r\n this._engine.setDepthBuffer(!!depthTest);\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(false);\r\n }\r\n this._engine.setDepthWrite(false);\r\n\r\n effectRenderer.bindBuffers(drawWrapper.effect);\r\n customBindings?.();\r\n effectRenderer.draw();\r\n effectRenderer.restoreStates();\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(true);\r\n }\r\n this._engine.setDepthWrite(engineDepthMask);\r\n if (engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Copies a texture to the current render target\r\n * @param sourceTexture The source texture to copy from\r\n * @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target\r\n * @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.\r\n * @param lodLevel The LOD level to use when copying the texture (default: 0).\r\n */\r\n public copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer = false, noViewport?: boolean, lodLevel = 0): void {\r\n if (forceCopyToBackbuffer) {\r\n this.bindRenderTarget();\r\n }\r\n\r\n const texture = this._textureManager.getTextureFromHandle(sourceTexture, true)!;\r\n const copyTexture = IsDepthTexture(texture.format) ? this._copyDepthTexture : this._copyTexture;\r\n\r\n copyTexture.source = texture;\r\n copyTexture.lodLevel = lodLevel;\r\n\r\n this.applyFullScreenEffect(\r\n copyTexture.effectWrapper.drawWrapper,\r\n () => {\r\n copyTexture.effectWrapper.onApplyObservable.notifyObservers({});\r\n },\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n noViewport\r\n );\r\n }\r\n\r\n /**\r\n * Renders a RenderTargetTexture or a layer\r\n * @param object The RenderTargetTexture/Layer to render\r\n * @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n * @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n */\r\n public render(object: Layer | ObjectRenderer | UtilityLayerRenderer, viewportWidth?: number, viewportHeight?: number): void {\r\n if (FrameGraphRenderContext._IsObjectRenderer(object)) {\r\n this._scene._intermediateRendering = true;\r\n if (object.shouldRender()) {\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this._applyRenderTarget();\r\n\r\n object.prepareRenderList();\r\n\r\n object.initRender(viewportWidth!, viewportHeight!);\r\n\r\n object.render();\r\n\r\n object.finishRender();\r\n }\r\n this._scene._intermediateRendering = false;\r\n } else {\r\n this._applyRenderTarget();\r\n object.render();\r\n }\r\n }\r\n\r\n /**\r\n * Binds a render target texture so that upcoming draw calls will render to it\r\n * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call\r\n * this method several times with different render targets without incurring the cost of binding if no draw calls are made\r\n * @param renderTarget The handle of the render target texture to bind (default: undefined, meaning \"back buffer\"). Pass an array for MRT rendering.\r\n * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)\r\n * @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).\r\n */\r\n public bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string, applyImmediately = false): void {\r\n if (\r\n (renderTarget?.renderTargetWrapper === undefined && this._currentRenderTarget === undefined) ||\r\n (renderTarget && this._currentRenderTarget && renderTarget.equals(this._currentRenderTarget))\r\n ) {\r\n this._flushDebugMessages();\r\n if (debugMessage !== undefined) {\r\n this.pushDebugGroup(debugMessage);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n if (applyImmediately) {\r\n this._applyRenderTarget();\r\n }\r\n return;\r\n }\r\n this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;\r\n this._debugMessageWhenTargetBound = debugMessage;\r\n this._renderTargetIsBound = false;\r\n if (applyImmediately) {\r\n this._applyRenderTarget();\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _flushDebugMessages() {\r\n if (this._debugMessageHasBeenPushed) {\r\n this.popDebugGroup();\r\n this._debugMessageHasBeenPushed = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _applyRenderTarget() {\r\n if (this._renderTargetIsBound) {\r\n return;\r\n }\r\n\r\n this._flushDebugMessages();\r\n\r\n const renderTargetWrapper = this._currentRenderTarget?.renderTargetWrapper;\r\n\r\n if (renderTargetWrapper === undefined) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n }\r\n this._engine.bindFramebuffer(renderTargetWrapper);\r\n }\r\n\r\n if (this._debugMessageWhenTargetBound !== undefined) {\r\n this.pushDebugGroup(this._debugMessageWhenTargetBound);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n\r\n this._renderTargetIsBound = true;\r\n }\r\n\r\n /** @internal */\r\n public _isReady(): boolean {\r\n return this._copyTexture.isReady() && this._copyDepthTexture.isReady();\r\n }\r\n\r\n /** @internal */\r\n public _dispose() {\r\n this._effectRenderer.dispose();\r\n this._effectRendererBack.dispose();\r\n this._copyTexture.dispose();\r\n this._copyDepthTexture.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"frameGraphRenderContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderContext.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,MAAM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AE,CAAC;IAC3E,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type {\r\n Nullable,\r\n AbstractEngine,\r\n DrawWrapper,\r\n IColor4Like,\r\n Layer,\r\n FrameGraphTextureHandle,\r\n Effect,\r\n FrameGraphTextureManager,\r\n ObjectRenderer,\r\n Scene,\r\n FrameGraphRenderTarget,\r\n InternalTexture,\r\n UtilityLayerRenderer,\r\n IStencilState,\r\n IStencilStateProperties,\r\n} from \"core/index\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer } from \"../Materials/effectRenderer\";\r\nimport { CopyTextureToTexture } from \"../Misc/copyTextureToTexture\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { IsDepthTexture } from \"../Materials/Textures/textureHelper.functions\";\r\n\r\nconst SamplingModeHasMipMapFiltering = [\r\n false, // not used\r\n false, // TEXTURE_NEAREST_SAMPLINGMODE / TEXTURE_NEAREST_NEAREST\r\n false, // TEXTURE_BILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR\r\n true, // TEXTURE_TRILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR_MIPLINEAR\r\n true, // TEXTURE_NEAREST_NEAREST_MIPNEAREST\r\n true, // TEXTURE_NEAREST_LINEAR_MIPNEAREST\r\n true, // TEXTURE_NEAREST_LINEAR_MIPLINEAR\r\n false, // TEXTURE_NEAREST_LINEAR\r\n true, // TEXTURE_NEAREST_NEAREST_MIPLINEAR\r\n true, // TEXTURE_LINEAR_NEAREST_MIPNEAREST\r\n true, // TEXTURE_LINEAR_NEAREST_MIPLINEAR\r\n true, // TEXTURE_LINEAR_LINEAR_MIPNEAREST\r\n false, // TEXTURE_LINEAR_NEAREST\r\n];\r\n\r\n/**\r\n * Frame graph context used render passes.\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderContext extends FrameGraphContext {\r\n private readonly _effectRenderer: EffectRenderer;\r\n private readonly _effectRendererBack: EffectRenderer;\r\n private _currentRenderTarget: FrameGraphRenderTarget | undefined;\r\n private _debugMessageWhenTargetBound: string | undefined;\r\n private _debugMessageHasBeenPushed = false;\r\n private _renderTargetIsBound = true;\r\n private readonly _copyTexture: CopyTextureToTexture;\r\n private readonly _copyDepthTexture: CopyTextureToTexture;\r\n\r\n private static _IsObjectRenderer(value: Layer | ObjectRenderer | UtilityLayerRenderer): value is ObjectRenderer {\r\n return (value as ObjectRenderer).initRender !== undefined;\r\n }\r\n\r\n /** @internal */\r\n constructor(engine: AbstractEngine, textureManager: FrameGraphTextureManager, scene: Scene) {\r\n super(engine, textureManager, scene);\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._effectRendererBack = new EffectRenderer(this._engine, {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 2, 1, 0, 3, 2],\r\n });\r\n this._copyTexture = new CopyTextureToTexture(this._engine);\r\n this._copyDepthTexture = new CopyTextureToTexture(this._engine, true);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color or depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color or depth texture, otherwise false\r\n */\r\n public isBackbuffer(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager._isBackbuffer(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color texture, otherwise false\r\n */\r\n public isBackbufferColor(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferColor(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's depth texture, otherwise false\r\n */\r\n public isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferDepthStencil(handle);\r\n }\r\n\r\n /**\r\n * Creates a (frame graph) render target wrapper\r\n * Note that renderTargets or renderTargetDepth can be undefined, but not both at the same time!\r\n * @param name Name of the render target wrapper\r\n * @param renderTargets Render target handles (textures) to use\r\n * @param renderTargetDepth Render target depth handle (texture) to use\r\n * @param depthReadOnly If true, the depth buffer will be read-only\r\n * @param stencilReadOnly If true, the stencil buffer will be read-only\r\n * @returns The created render target wrapper\r\n */\r\n public createRenderTarget(\r\n name: string,\r\n renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[],\r\n renderTargetDepth?: FrameGraphTextureHandle,\r\n depthReadOnly?: boolean,\r\n stencilReadOnly?: boolean\r\n ): FrameGraphRenderTarget {\r\n return this._textureManager.createRenderTarget(name, renderTargets, renderTargetDepth, depthReadOnly, stencilReadOnly);\r\n }\r\n\r\n /**\r\n * Clears the current render buffer or the current render target (if any is set up)\r\n * @param color Defines the color to use\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Clears the color attachments of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n */\r\n public clearColorAttachments(color: Nullable<IColor4Like>, attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, true, false, false);\r\n }\r\n\r\n /**\r\n * Clears all attachments (color(s) + depth/stencil) of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clearAttachments(color: Nullable<IColor4Like>, attachments: number[], backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Binds the attachments to the current render target\r\n * @param attachments The attachments to bind\r\n */\r\n public bindAttachments(attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n }\r\n\r\n /**\r\n * Generates mipmaps for the current render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._currentRenderTarget?.renderTargetWrapper === undefined) {\r\n return;\r\n }\r\n\r\n if (this._engine._currentRenderTarget && (!this._engine.isWebGPU || this._renderTargetIsBound)) {\r\n // we can't generate the mipmaps if the render target (which is the texture we want to generate mipmaps for) is bound\r\n // Also, for some reasons, on WebGL2, generating mipmaps doesn't work if a render target is bound, even if it's not the texture we want to generate mipmaps for...\r\n this._flushDebugMessages();\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n const textures = this._currentRenderTarget.renderTargetWrapper.textures;\r\n if (textures) {\r\n for (const texture of textures) {\r\n this._engine.generateMipmaps(texture);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the texture sampling mode for a given texture handle\r\n * @param handle Handle of the texture to set the sampling mode for\r\n * @param samplingMode Sampling mode to set\r\n */\r\n public setTextureSamplingMode(handle: FrameGraphTextureHandle, samplingMode: number): void {\r\n const internalTexture = this._textureManager.getTextureFromHandle(handle);\r\n if (internalTexture && internalTexture.samplingMode !== samplingMode) {\r\n internalTexture.useMipMaps = SamplingModeHasMipMapFiltering[samplingMode];\r\n this._engine.updateTextureSamplingMode(samplingMode, internalTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Binds a texture handle to a given effect (resolves the handle to a texture and binds it to the effect)\r\n * @param effect The effect to bind the texture to\r\n * @param name The name of the texture in the effect\r\n * @param handle The handle of the texture to bind\r\n */\r\n public bindTextureHandle(effect: Effect, name: string, handle: FrameGraphTextureHandle): void {\r\n let texture: Nullable<InternalTexture>;\r\n\r\n const historyEntry = this._textureManager._historyTextures.get(handle);\r\n if (historyEntry) {\r\n texture = historyEntry.textures[historyEntry.index]; // texture we write to in this frame\r\n if (\r\n this._currentRenderTarget !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper.textures!.includes(texture!)\r\n ) {\r\n // If the current render target renders to the history write texture, we bind the read texture instead\r\n texture = historyEntry.textures[historyEntry.index ^ 1];\r\n }\r\n } else {\r\n texture = this._textureManager._textures.get(handle)!.texture;\r\n }\r\n\r\n effect._bindTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Applies a full-screen effect to the current render target\r\n * @param drawWrapper The draw wrapper containing the effect to apply\r\n * @param customBindings The custom bindings to use when applying the effect (optional)\r\n * @param stencilState The stencil state to use when applying the effect (optional)\r\n * @param disableColorWrite If true, color write will be disabled when applying the effect (optional)\r\n * @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)\r\n * @param depthTest If true, depth testing will be enabled when applying the effect (default is false)\r\n * @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.\r\n * @returns True if the effect was applied, otherwise false (effect not ready)\r\n */\r\n public applyFullScreenEffect(\r\n drawWrapper: DrawWrapper,\r\n customBindings?: () => void,\r\n stencilState?: IStencilState | IStencilStateProperties,\r\n disableColorWrite?: boolean,\r\n drawBackFace?: boolean,\r\n depthTest?: boolean,\r\n noViewport?: boolean\r\n ): boolean {\r\n if (!drawWrapper.effect?.isReady()) {\r\n return false;\r\n }\r\n\r\n this._applyRenderTarget();\r\n\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n\r\n const effectRenderer = drawBackFace ? this._effectRendererBack : this._effectRenderer;\r\n\r\n effectRenderer.saveStates();\r\n if (!noViewport) {\r\n effectRenderer.setViewport();\r\n }\r\n\r\n this._engine.enableEffect(drawWrapper);\r\n this._engine.setState(false, undefined, undefined, undefined, undefined, stencilState);\r\n this._engine.setDepthBuffer(!!depthTest);\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(false);\r\n }\r\n this._engine.setDepthWrite(false);\r\n\r\n effectRenderer.bindBuffers(drawWrapper.effect);\r\n customBindings?.();\r\n effectRenderer.draw();\r\n effectRenderer.restoreStates();\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(true);\r\n }\r\n this._engine.setDepthWrite(engineDepthMask);\r\n if (engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Copies a texture to the current render target\r\n * @param sourceTexture The source texture to copy from\r\n * @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target\r\n * @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.\r\n * @param lodLevel The LOD level to use when copying the texture (default: 0).\r\n */\r\n public copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer = false, noViewport?: boolean, lodLevel = 0): void {\r\n if (forceCopyToBackbuffer) {\r\n this.bindRenderTarget();\r\n }\r\n\r\n const texture = this._textureManager.getTextureFromHandle(sourceTexture, true)!;\r\n const copyTexture = IsDepthTexture(texture.format) ? this._copyDepthTexture : this._copyTexture;\r\n\r\n copyTexture.source = texture;\r\n copyTexture.lodLevel = lodLevel;\r\n\r\n this.applyFullScreenEffect(\r\n copyTexture.effectWrapper.drawWrapper,\r\n () => {\r\n copyTexture.effectWrapper.onApplyObservable.notifyObservers({});\r\n },\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n noViewport\r\n );\r\n }\r\n\r\n /**\r\n * Renders a RenderTargetTexture or a layer\r\n * @param object The RenderTargetTexture/Layer to render\r\n * @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n * @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n */\r\n public render(object: Layer | ObjectRenderer | UtilityLayerRenderer, viewportWidth?: number, viewportHeight?: number): void {\r\n if (FrameGraphRenderContext._IsObjectRenderer(object)) {\r\n this._scene._intermediateRendering = true;\r\n if (object.shouldRender()) {\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this._applyRenderTarget();\r\n\r\n object.prepareRenderList();\r\n\r\n object.initRender(viewportWidth!, viewportHeight!);\r\n\r\n object.render();\r\n\r\n object.finishRender();\r\n }\r\n this._scene._intermediateRendering = false;\r\n } else {\r\n this._applyRenderTarget();\r\n object.render();\r\n }\r\n }\r\n\r\n /**\r\n * Binds a render target texture so that upcoming draw calls will render to it\r\n * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call\r\n * this method several times with different render targets without incurring the cost of binding if no draw calls are made\r\n * @param renderTarget The handle of the render target texture to bind (default: undefined, meaning \"back buffer\"). Pass an array for MRT rendering.\r\n * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)\r\n * @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).\r\n */\r\n public bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string, applyImmediately = false): void {\r\n this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;\r\n this._debugMessageWhenTargetBound = debugMessage;\r\n this._renderTargetIsBound = false;\r\n if (applyImmediately) {\r\n this._applyRenderTarget();\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _flushDebugMessages() {\r\n if (this._debugMessageHasBeenPushed) {\r\n this.popDebugGroup();\r\n this._debugMessageHasBeenPushed = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _applyRenderTarget() {\r\n if (this._renderTargetIsBound) {\r\n return;\r\n }\r\n\r\n this._flushDebugMessages();\r\n\r\n const renderTargetWrapper = this._currentRenderTarget?.renderTargetWrapper;\r\n\r\n if (renderTargetWrapper === undefined) {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.restoreDefaultFramebuffer();\r\n }\r\n } else if (this._engine._currentRenderTarget !== renderTargetWrapper) {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n }\r\n this._engine.bindFramebuffer(renderTargetWrapper);\r\n }\r\n\r\n if (this._debugMessageWhenTargetBound !== undefined) {\r\n this.pushDebugGroup(this._debugMessageWhenTargetBound);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n\r\n this._renderTargetIsBound = true;\r\n }\r\n\r\n /** @internal */\r\n public _isReady(): boolean {\r\n return this._copyTexture.isReady() && this._copyDepthTexture.isReady();\r\n }\r\n\r\n /** @internal */\r\n public _dispose() {\r\n this._effectRenderer.dispose();\r\n this._effectRendererBack.dispose();\r\n this._copyTexture.dispose();\r\n this._copyDepthTexture.dispose();\r\n }\r\n}\r\n"]}
@@ -21,11 +21,11 @@ export declare abstract class FrameGraphTask {
21
21
  get disabled(): boolean;
22
22
  set disabled(value: boolean);
23
23
  /**
24
- * Gets the render passes of the task.
24
+ * Gets the passes of the task.
25
25
  */
26
26
  get passes(): IFrameGraphPass[];
27
27
  /**
28
- * Gets the disabled render passes of the task.
28
+ * Gets the disabled passes of the task.
29
29
  */
30
30
  get passesDisabled(): IFrameGraphPass[];
31
31
  /**
@@ -25,13 +25,13 @@ export class FrameGraphTask {
25
25
  this._disabled = value;
26
26
  }
27
27
  /**
28
- * Gets the render passes of the task.
28
+ * Gets the passes of the task.
29
29
  */
30
30
  get passes() {
31
31
  return this._passes;
32
32
  }
33
33
  /**
34
- * Gets the disabled render passes of the task.
34
+ * Gets the disabled passes of the task.
35
35
  */
36
36
  get passesDisabled() {
37
37
  return this._passesDisabled;
@@ -186,23 +186,23 @@ export class FrameGraphTask {
186
186
  _execute() {
187
187
  const passes = this._disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;
188
188
  this.onBeforeTaskExecute.notifyObservers(this);
189
- this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 2);
189
+ this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 1);
190
190
  for (const pass of passes) {
191
191
  pass._execute();
192
192
  }
193
- this._frameGraph.engine._debugPopGroup?.(2);
193
+ this._frameGraph.engine._debugPopGroup?.(1);
194
194
  this.onAfterTaskExecute.notifyObservers(this);
195
195
  }
196
196
  /** @internal */
197
197
  _initializePasses() {
198
- this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 2);
198
+ this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 1);
199
199
  for (const pass of this._passes) {
200
200
  pass._initialize();
201
201
  }
202
202
  for (const pass of this._passesDisabled) {
203
203
  pass._initialize();
204
204
  }
205
- this._frameGraph.engine._debugPopGroup?.(2);
205
+ this._frameGraph.engine._debugPopGroup?.(1);
206
206
  }
207
207
  _checkSameRenderTarget(src, dst) {
208
208
  if (src === null || dst === null) {
@@ -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;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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"]}
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,GA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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 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 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})`, 1);\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n\r\n this._frameGraph.engine._debugPopGroup?.(1);\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})`, 1);\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?.(1);\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"]}
@@ -0,0 +1,15 @@
1
+ import type { FrameGraphRenderPass, LayerAndFaceIndex } from "../index.js";
2
+ import { FrameGraphTask } from "./frameGraphTask.js";
3
+ /**
4
+ * Base class for frame graph tasks that involve multi-target rendering.
5
+ */
6
+ export declare abstract class FrameGraphTaskMultiRenderTarget extends FrameGraphTask {
7
+ private _outputLayerAndFaceIndices;
8
+ private _layerAndFaceIndicesUpdated;
9
+ /**
10
+ * Sets the output layer and face indices for multi-target rendering.
11
+ * @param indices The array of layer and face indices.
12
+ */
13
+ setOutputLayerAndFaceIndices(indices: LayerAndFaceIndex[]): void;
14
+ protected _updateLayerAndFaceIndices(pass: FrameGraphRenderPass): void;
15
+ }
@@ -0,0 +1,25 @@
1
+ import { FrameGraphTask } from "./frameGraphTask.js";
2
+ /**
3
+ * Base class for frame graph tasks that involve multi-target rendering.
4
+ */
5
+ export class FrameGraphTaskMultiRenderTarget extends FrameGraphTask {
6
+ constructor() {
7
+ super(...arguments);
8
+ this._layerAndFaceIndicesUpdated = false;
9
+ }
10
+ /**
11
+ * Sets the output layer and face indices for multi-target rendering.
12
+ * @param indices The array of layer and face indices.
13
+ */
14
+ setOutputLayerAndFaceIndices(indices) {
15
+ this._outputLayerAndFaceIndices = indices;
16
+ this._layerAndFaceIndicesUpdated = indices.length > 0;
17
+ }
18
+ _updateLayerAndFaceIndices(pass) {
19
+ if (this._layerAndFaceIndicesUpdated) {
20
+ pass.setOutputLayerAndFaceIndices(this._outputLayerAndFaceIndices);
21
+ this._layerAndFaceIndicesUpdated = false;
22
+ }
23
+ }
24
+ }
25
+ //# sourceMappingURL=frameGraphTaskMultiRenderTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frameGraphTaskMultiRenderTarget.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphTaskMultiRenderTarget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAgB,+BAAgC,SAAQ,cAAc;IAA5E;;QAEY,gCAA2B,GAAG,KAAK,CAAC;IAiBhD,CAAC;IAfG;;;OAGG;IACI,4BAA4B,CAAC,OAA4B;QAC5D,IAAI,CAAC,0BAA0B,GAAG,OAAO,CAAC;QAC1C,IAAI,CAAC,2BAA2B,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1D,CAAC;IAES,0BAA0B,CAAC,IAA0B;QAC3D,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACnC,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACnE,IAAI,CAAC,2BAA2B,GAAG,KAAK,CAAC;QAC7C,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { FrameGraphRenderPass, LayerAndFaceIndex } from \"core/index\";\r\nimport { FrameGraphTask } from \"./frameGraphTask\";\r\n\r\n/**\r\n * Base class for frame graph tasks that involve multi-target rendering.\r\n */\r\nexport abstract class FrameGraphTaskMultiRenderTarget extends FrameGraphTask {\r\n private _outputLayerAndFaceIndices: LayerAndFaceIndex[];\r\n private _layerAndFaceIndicesUpdated = false;\r\n\r\n /**\r\n * Sets the output layer and face indices for multi-target rendering.\r\n * @param indices The array of layer and face indices.\r\n */\r\n public setOutputLayerAndFaceIndices(indices: LayerAndFaceIndex[]) {\r\n this._outputLayerAndFaceIndices = indices;\r\n this._layerAndFaceIndicesUpdated = indices.length > 0;\r\n }\r\n\r\n protected _updateLayerAndFaceIndices(pass: FrameGraphRenderPass) {\r\n if (this._layerAndFaceIndicesUpdated) {\r\n pass.setOutputLayerAndFaceIndices(this._outputLayerAndFaceIndices);\r\n this._layerAndFaceIndicesUpdated = false;\r\n }\r\n }\r\n}\r\n"]}