@babylonjs/core 7.49.0 → 7.51.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 (189) hide show
  1. package/Behaviors/Cameras/framingBehavior.js +3 -0
  2. package/Behaviors/Cameras/framingBehavior.js.map +1 -1
  3. package/Behaviors/Meshes/baseSixDofDragBehavior.js +10 -9
  4. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  5. package/Behaviors/Meshes/pointerDragBehavior.js +4 -1
  6. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  7. package/Buffers/bufferUtils.d.ts +9 -10
  8. package/Buffers/bufferUtils.js +16 -0
  9. package/Buffers/bufferUtils.js.map +1 -1
  10. package/Culling/Helper/transformFeedbackBoundingHelper.js +2 -1
  11. package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
  12. package/Engines/AbstractEngine/abstractEngine.cubeTexture.js +2 -3
  13. package/Engines/AbstractEngine/abstractEngine.cubeTexture.js.map +1 -1
  14. package/Engines/WebGPU/webgpuBufferManager.js +23 -22
  15. package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
  16. package/Engines/abstractEngine.js +2 -2
  17. package/Engines/abstractEngine.js.map +1 -1
  18. package/Engines/thinEngine.functions.js +5 -3
  19. package/Engines/thinEngine.functions.js.map +1 -1
  20. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.d.ts +43 -0
  21. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.js +83 -0
  22. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.js.map +1 -0
  23. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  24. package/FrameGraph/Node/Blocks/index.js +1 -0
  25. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  26. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +35 -0
  27. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +40 -0
  28. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -0
  29. package/FrameGraph/frameGraph.d.ts +4 -0
  30. package/FrameGraph/frameGraph.js +6 -0
  31. package/FrameGraph/frameGraph.js.map +1 -1
  32. package/FrameGraph/frameGraphRenderContext.d.ts +2 -2
  33. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  34. package/FrameGraph/index.d.ts +1 -0
  35. package/FrameGraph/index.js +1 -0
  36. package/FrameGraph/index.js.map +1 -1
  37. package/Layers/thinEffectLayer.js +3 -1
  38. package/Layers/thinEffectLayer.js.map +1 -1
  39. package/Lights/Shadows/shadowGenerator.js +3 -1
  40. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  41. package/Loading/loadingScreen.js +4 -1
  42. package/Loading/loadingScreen.js.map +1 -1
  43. package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +9 -20
  44. package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
  45. package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +8 -19
  46. package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
  47. package/Materials/Node/Blocks/Fragment/prePassOutputBlock.d.ts +8 -0
  48. package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js +36 -0
  49. package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js.map +1 -1
  50. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +6 -3
  51. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  52. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +8 -0
  53. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +48 -0
  54. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  55. package/Materials/Node/nodeMaterial.d.ts +2 -0
  56. package/Materials/Node/nodeMaterial.js +14 -0
  57. package/Materials/Node/nodeMaterial.js.map +1 -1
  58. package/Materials/PBR/pbrBaseMaterial.d.ts +2 -0
  59. package/Materials/PBR/pbrBaseMaterial.js +2 -0
  60. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  61. package/Materials/materialHelper.functions.d.ts +2 -1
  62. package/Materials/materialHelper.functions.js +17 -1
  63. package/Materials/materialHelper.functions.js.map +1 -1
  64. package/Materials/shaderMaterial.js +3 -1
  65. package/Materials/shaderMaterial.js.map +1 -1
  66. package/Materials/standardMaterial.d.ts +2 -0
  67. package/Materials/standardMaterial.js +2 -0
  68. package/Materials/standardMaterial.js.map +1 -1
  69. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
  70. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +4 -0
  71. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +11 -2
  72. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
  73. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +4 -0
  74. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +11 -2
  75. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
  76. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +4 -0
  77. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +11 -2
  78. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
  79. package/Meshes/Node/Blocks/Sources/boxBlock.js +4 -4
  80. package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
  81. package/Meshes/Node/Blocks/Sources/gridBlock.js +3 -3
  82. package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
  83. package/Meshes/Node/Blocks/Sources/planeBlock.js +3 -3
  84. package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
  85. package/Meshes/Node/Blocks/subdivideBlock.d.ts +45 -0
  86. package/Meshes/Node/Blocks/subdivideBlock.js +98 -0
  87. package/Meshes/Node/Blocks/subdivideBlock.js.map +1 -0
  88. package/Meshes/Node/index.d.ts +1 -0
  89. package/Meshes/Node/index.js +1 -0
  90. package/Meshes/Node/index.js.map +1 -1
  91. package/Meshes/abstractMesh.js +6 -0
  92. package/Meshes/abstractMesh.js.map +1 -1
  93. package/Meshes/csg2.js +18 -1
  94. package/Meshes/csg2.js.map +1 -1
  95. package/Meshes/geometry.js +1 -0
  96. package/Meshes/geometry.js.map +1 -1
  97. package/Meshes/index.d.ts +1 -0
  98. package/Meshes/index.js +1 -0
  99. package/Meshes/index.js.map +1 -1
  100. package/Meshes/mesh.d.ts +47 -1
  101. package/Meshes/mesh.js +28 -1
  102. package/Meshes/mesh.js.map +1 -1
  103. package/Meshes/mesh.vertexData.js +1 -1
  104. package/Meshes/mesh.vertexData.js.map +1 -1
  105. package/Meshes/mesh.vertexData.subdivide.d.ts +28 -0
  106. package/Meshes/mesh.vertexData.subdivide.js +400 -0
  107. package/Meshes/mesh.vertexData.subdivide.js.map +1 -0
  108. package/Misc/index.d.ts +1 -0
  109. package/Misc/index.js +1 -0
  110. package/Misc/index.js.map +1 -1
  111. package/Misc/screenshotTools.js +3 -0
  112. package/Misc/screenshotTools.js.map +1 -1
  113. package/Misc/urlTools.d.ts +6 -0
  114. package/Misc/urlTools.js +12 -0
  115. package/Misc/urlTools.js.map +1 -0
  116. package/Morph/morphTarget.d.ts +12 -0
  117. package/Morph/morphTarget.js +35 -1
  118. package/Morph/morphTarget.js.map +1 -1
  119. package/Morph/morphTargetManager.d.ts +13 -0
  120. package/Morph/morphTargetManager.js +30 -1
  121. package/Morph/morphTargetManager.js.map +1 -1
  122. package/PostProcesses/volumetricLightScatteringPostProcess.js +3 -1
  123. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  124. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +5 -3
  125. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  126. package/Rendering/depthRenderer.js +3 -1
  127. package/Rendering/depthRenderer.js.map +1 -1
  128. package/Rendering/geometryBufferRenderer.js +3 -1
  129. package/Rendering/geometryBufferRenderer.js.map +1 -1
  130. package/Rendering/outlineRenderer.js +3 -1
  131. package/Rendering/outlineRenderer.js.map +1 -1
  132. package/Rendering/utilityLayerRenderer.d.ts +3 -1
  133. package/Rendering/utilityLayerRenderer.js +16 -7
  134. package/Rendering/utilityLayerRenderer.js.map +1 -1
  135. package/Shaders/ShadersInclude/lightFragment.js +1 -1
  136. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  137. package/Shaders/ShadersInclude/morphTargetsVertex.js +9 -0
  138. package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
  139. package/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.js +3 -0
  140. package/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.js.map +1 -1
  141. package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js +5 -1
  142. package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
  143. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +2 -1
  144. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  145. package/Shaders/ShadersInclude/vertexColorMixing.js +2 -2
  146. package/Shaders/ShadersInclude/vertexColorMixing.js.map +1 -1
  147. package/Shaders/background.vertex.js +1 -1
  148. package/Shaders/background.vertex.js.map +1 -1
  149. package/Shaders/color.vertex.js +3 -0
  150. package/Shaders/color.vertex.js.map +1 -1
  151. package/Shaders/default.vertex.js +3 -0
  152. package/Shaders/default.vertex.js.map +1 -1
  153. package/Shaders/greasedLine.vertex.js +1 -2
  154. package/Shaders/greasedLine.vertex.js.map +1 -1
  155. package/Shaders/pbr.vertex.js +3 -0
  156. package/Shaders/pbr.vertex.js.map +1 -1
  157. package/ShadersWGSL/ShadersInclude/lightFragment.js +1 -1
  158. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
  159. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +6 -0
  160. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
  161. package/ShadersWGSL/ShadersInclude/morphTargetsVertexGlobalDeclaration.js +3 -0
  162. package/ShadersWGSL/ShadersInclude/morphTargetsVertexGlobalDeclaration.js.map +1 -1
  163. package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js +5 -1
  164. package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
  165. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +2 -1
  166. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  167. package/ShadersWGSL/boundingInfo.compute.js +3 -0
  168. package/ShadersWGSL/boundingInfo.compute.js.map +1 -1
  169. package/ShadersWGSL/color.vertex.js +3 -0
  170. package/ShadersWGSL/color.vertex.js.map +1 -1
  171. package/ShadersWGSL/default.vertex.js +3 -0
  172. package/ShadersWGSL/default.vertex.js.map +1 -1
  173. package/ShadersWGSL/greasedLine.vertex.js +2 -3
  174. package/ShadersWGSL/greasedLine.vertex.js.map +1 -1
  175. package/ShadersWGSL/pbr.fragment.js +1 -1
  176. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  177. package/ShadersWGSL/pbr.vertex.js +3 -0
  178. package/ShadersWGSL/pbr.vertex.js.map +1 -1
  179. package/XR/features/WebXRAnchorSystem.d.ts +4 -0
  180. package/XR/features/WebXRAnchorSystem.js +8 -5
  181. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  182. package/XR/features/WebXRControllerPointerSelection.js +1 -0
  183. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  184. package/package.json +1 -1
  185. package/scene.d.ts +2 -0
  186. package/scene.js +13 -9
  187. package/scene.js.map +1 -1
  188. package/types.d.ts +22 -0
  189. package/types.js.map +1 -1
@@ -127,9 +127,11 @@ export function _isRenderingStateCompiled(pipelineContext, gl, validateShaderPro
127
127
  return false;
128
128
  }
129
129
  const stateObject = getStateObject(gl);
130
- if (gl.getProgramParameter(webGLPipelineContext.program, stateObject.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
131
- _finalizePipelineContext(webGLPipelineContext, gl, validateShaderPrograms);
132
- return true;
130
+ if (stateObject && stateObject.parallelShaderCompile && stateObject.parallelShaderCompile.COMPLETION_STATUS_KHR && webGLPipelineContext.program) {
131
+ if (gl.getProgramParameter(webGLPipelineContext.program, stateObject.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
132
+ _finalizePipelineContext(webGLPipelineContext, gl, validateShaderPrograms);
133
+ return true;
134
+ }
133
135
  }
134
136
  return false;
135
137
  }
@@ -1 +1 @@
1
- {"version":3,"file":"thinEngine.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/thinEngine.functions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAkBhE;;GAEG;AACH,MAAM,YAAY,GAAkD,IAAI,OAAO,EAAE,CAAC;AAElF;;GAEG;AACH,MAAM,iBAAiB,GAA2B;IAC9C,aAAa,EAAE,CAAC;IAChB,eAAe,EAAE,EAAE;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAqB;IAChD,IAAI,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,iBAAiB,CAAC;QAC7B,CAAC;QACD,KAAK,GAAG;YACJ,sFAAsF;YACtF,aAAa,EAAG,OAAkC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7E,QAAQ,EAAE,OAAO;YACjB,6FAA6F;YAC7F,qBAAqB,EAAE,OAAO,CAAC,YAAY,CAAC,6BAA6B,CAAC,IAAI,SAAS;YACvF,eAAe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,CAAC;IAChC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAqB,EAAE,EAAgB;IAC/D,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oCAAoC,CAAC,eAAiC,EAAE,MAAoD;IACxI,MAAM,oBAAoB,GAAG,eAAuC,CAAC;IAErE,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,CAAC;QAC3C,MAAM,CAAC,eAAe,CAAC,CAAC;QACxB,OAAO;IACX,CAAC;IAED,MAAM,UAAU,GAAG,oBAAoB,CAAC,UAAU,CAAC;IAEnD,oBAAoB,CAAC,UAAU,GAAG,GAAG,EAAE;QACnC,UAAU,EAAE,EAAE,CAAC;QACf,MAAM,CAAC,eAAe,CAAC,CAAC;IAC5B,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { IPipelineContext } from \"./IPipelineContext\";\r\nimport type { ShaderProcessingContext } from \"./Processors/shaderProcessingOptions\";\r\nimport { WebGLPipelineContext } from \"./WebGL/webGLPipelineContext\";\r\nimport type { _loadFile } from \"./abstractEngine.functions\";\r\nimport { _ConcatenateShader } from \"./abstractEngine.functions\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IThinEngineStateObject {\r\n _contextWasLost?: boolean;\r\n validateShaderPrograms?: boolean;\r\n _webGLVersion: number;\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n disableParallelShaderCompile?: boolean;\r\n _context?: WebGLContext;\r\n _createShaderProgramInjection?: typeof _createShaderProgram;\r\n createRawShaderProgramInjection?: typeof createRawShaderProgram;\r\n createShaderProgramInjection?: typeof createShaderProgram;\r\n loadFileInjection?: typeof _loadFile;\r\n cachedPipelines: { [name: string]: IPipelineContext };\r\n}\r\n/**\r\n * @internal\r\n */\r\nconst _stateObject: WeakMap<WebGLContext, IThinEngineStateObject> = new WeakMap();\r\n\r\n/**\r\n * This will be used in cases where the engine doesn't have a context (like the nullengine)\r\n */\r\nconst singleStateObject: IThinEngineStateObject = {\r\n _webGLVersion: 2,\r\n cachedPipelines: {},\r\n};\r\n\r\n/**\r\n * get or create a state object for the given context\r\n * Note - Used in WebGL only at the moment.\r\n * @param context The context to get the state object from\r\n * @returns the state object\r\n * @internal\r\n */\r\nexport function getStateObject(context: WebGLContext): IThinEngineStateObject {\r\n let state = _stateObject.get(context);\r\n if (!state) {\r\n if (!context) {\r\n return singleStateObject;\r\n }\r\n state = {\r\n // use feature detection. instanceof returns false. This only exists on WebGL2 context\r\n _webGLVersion: (context as WebGL2RenderingContext).TEXTURE_BINDING_3D ? 2 : 1,\r\n _context: context,\r\n // when using the function without an engine we need to set it to enable parallel compilation\r\n parallelShaderCompile: context.getExtension(\"KHR_parallel_shader_compile\") || undefined,\r\n cachedPipelines: {},\r\n };\r\n _stateObject.set(context, state);\r\n }\r\n return state;\r\n}\r\n/**\r\n * Remove the state object that belongs to the specific context\r\n * @param context the context that is being\r\n */\r\nexport function deleteStateObject(context: WebGLContext): void {\r\n _stateObject.delete(context);\r\n}\r\n\r\nexport type WebGLContext = WebGLRenderingContext | WebGL2RenderingContext;\r\n/**\r\n * Directly creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @param _createShaderProgramInjection defines an optional injection to use to create the shader program\r\n * @returns the new webGL program\r\n */\r\nexport function createRawShaderProgram(\r\n pipelineContext: IPipelineContext,\r\n vertexCode: string,\r\n fragmentCode: string,\r\n context: WebGLContext,\r\n transformFeedbackVaryings: Nullable<string[]>,\r\n _createShaderProgramInjection?: typeof _createShaderProgram\r\n): WebGLProgram {\r\n const stateObject = getStateObject(context);\r\n if (!_createShaderProgramInjection) {\r\n _createShaderProgramInjection = stateObject._createShaderProgramInjection ?? _createShaderProgram;\r\n }\r\n\r\n const vertexShader = _compileRawShader(vertexCode, \"vertex\", context, stateObject._contextWasLost);\r\n const fragmentShader = _compileRawShader(fragmentCode, \"fragment\", context, stateObject._contextWasLost);\r\n\r\n return _createShaderProgramInjection(\r\n pipelineContext as WebGLPipelineContext,\r\n vertexShader,\r\n fragmentShader,\r\n context,\r\n transformFeedbackVaryings,\r\n stateObject.validateShaderPrograms\r\n );\r\n}\r\n\r\n/**\r\n * Creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param defines defines the string containing the defines to use to compile the shaders\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @param _createShaderProgramInjection defines an optional injection to use to create the shader program\r\n * @returns the new webGL program\r\n */\r\nexport function createShaderProgram(\r\n pipelineContext: IPipelineContext,\r\n vertexCode: string,\r\n fragmentCode: string,\r\n defines: Nullable<string>,\r\n context: WebGLContext,\r\n transformFeedbackVaryings: Nullable<string[]> = null,\r\n _createShaderProgramInjection?: typeof _createShaderProgram\r\n): WebGLProgram {\r\n const stateObject = getStateObject(context);\r\n if (!_createShaderProgramInjection) {\r\n _createShaderProgramInjection = stateObject._createShaderProgramInjection ?? _createShaderProgram;\r\n }\r\n const shaderVersion = stateObject._webGLVersion > 1 ? \"#version 300 es\\n#define WEBGL2 \\n\" : \"\";\r\n const vertexShader = _compileShader(vertexCode, \"vertex\", defines, shaderVersion, context, stateObject._contextWasLost);\r\n const fragmentShader = _compileShader(fragmentCode, \"fragment\", defines, shaderVersion, context, stateObject._contextWasLost);\r\n\r\n return _createShaderProgramInjection(\r\n pipelineContext as WebGLPipelineContext,\r\n vertexShader,\r\n fragmentShader,\r\n context,\r\n transformFeedbackVaryings,\r\n stateObject.validateShaderPrograms\r\n );\r\n}\r\n\r\n/**\r\n * Creates a new pipeline context. Note, make sure to attach an engine instance to the created context\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param _shaderProcessingContext defines the shader processing context used during the processing if available\r\n * @returns the new pipeline\r\n */\r\nexport function createPipelineContext(context: WebGLContext, _shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext {\r\n const pipelineContext = new WebGLPipelineContext();\r\n const stateObject = getStateObject(context);\r\n if (stateObject.parallelShaderCompile && !stateObject.disableParallelShaderCompile) {\r\n pipelineContext.isParallelCompiled = true;\r\n }\r\n pipelineContext.context = stateObject._context;\r\n return pipelineContext;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _createShaderProgram(\r\n pipelineContext: WebGLPipelineContext,\r\n vertexShader: WebGLShader,\r\n fragmentShader: WebGLShader,\r\n context: WebGLContext,\r\n _transformFeedbackVaryings: Nullable<string[]> = null,\r\n validateShaderPrograms?: boolean\r\n): WebGLProgram {\r\n const shaderProgram = context.createProgram();\r\n pipelineContext.program = shaderProgram;\r\n\r\n if (!shaderProgram) {\r\n throw new Error(\"Unable to create program\");\r\n }\r\n\r\n context.attachShader(shaderProgram, vertexShader);\r\n context.attachShader(shaderProgram, fragmentShader);\r\n\r\n context.linkProgram(shaderProgram);\r\n\r\n pipelineContext.context = context;\r\n pipelineContext.vertexShader = vertexShader;\r\n pipelineContext.fragmentShader = fragmentShader;\r\n\r\n if (!pipelineContext.isParallelCompiled) {\r\n _finalizePipelineContext(pipelineContext, context, validateShaderPrograms);\r\n }\r\n\r\n return shaderProgram;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _isRenderingStateCompiled(pipelineContext: IPipelineContext, gl: WebGLContext, validateShaderPrograms?: boolean): boolean {\r\n const webGLPipelineContext = pipelineContext as WebGLPipelineContext;\r\n if (webGLPipelineContext._isDisposed) {\r\n return false;\r\n }\r\n const stateObject = getStateObject(gl);\r\n if (gl.getProgramParameter(webGLPipelineContext.program!, stateObject.parallelShaderCompile!.COMPLETION_STATUS_KHR)) {\r\n _finalizePipelineContext(webGLPipelineContext, gl, validateShaderPrograms);\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _finalizePipelineContext(pipelineContext: WebGLPipelineContext, gl: WebGLContext, validateShaderPrograms?: boolean) {\r\n const context = pipelineContext.context!;\r\n const vertexShader = pipelineContext.vertexShader!;\r\n const fragmentShader = pipelineContext.fragmentShader!;\r\n const program = pipelineContext.program!;\r\n\r\n const linked = context.getProgramParameter(program, context.LINK_STATUS);\r\n if (!linked) {\r\n // Get more info\r\n // Vertex\r\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\r\n const log = gl.getShaderInfoLog(vertexShader);\r\n if (log) {\r\n pipelineContext.vertexCompilationError = log;\r\n throw new Error(\"VERTEX SHADER \" + log);\r\n }\r\n }\r\n\r\n // Fragment\r\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\r\n const log = gl.getShaderInfoLog(fragmentShader);\r\n if (log) {\r\n pipelineContext.fragmentCompilationError = log;\r\n throw new Error(\"FRAGMENT SHADER \" + log);\r\n }\r\n }\r\n\r\n const error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programLinkError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n\r\n if (/*this.*/ validateShaderPrograms) {\r\n context.validateProgram(program);\r\n const validated = context.getProgramParameter(program, context.VALIDATE_STATUS);\r\n\r\n if (!validated) {\r\n const error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programValidationError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n }\r\n\r\n context.deleteShader(vertexShader);\r\n context.deleteShader(fragmentShader);\r\n\r\n pipelineContext.vertexShader = undefined;\r\n pipelineContext.fragmentShader = undefined;\r\n\r\n if (pipelineContext.onCompiled) {\r\n pipelineContext.onCompiled();\r\n pipelineContext.onCompiled = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _preparePipelineContext(\r\n pipelineContext: IPipelineContext,\r\n vertexSourceCode: string,\r\n fragmentSourceCode: string,\r\n createAsRaw: boolean,\r\n _rawVertexSourceCode: string,\r\n _rawFragmentSourceCode: string,\r\n rebuildRebind: any,\r\n defines: Nullable<string>,\r\n transformFeedbackVaryings: Nullable<string[]>,\r\n _key: string = \"\",\r\n onReady: () => void,\r\n createRawShaderProgramInjection?: typeof createRawShaderProgram,\r\n createShaderProgramInjection?: typeof createShaderProgram\r\n) {\r\n const stateObject = getStateObject((pipelineContext as WebGLPipelineContext).context!);\r\n if (!createRawShaderProgramInjection) {\r\n createRawShaderProgramInjection = stateObject.createRawShaderProgramInjection ?? createRawShaderProgram;\r\n }\r\n if (!createShaderProgramInjection) {\r\n createShaderProgramInjection = stateObject.createShaderProgramInjection ?? createShaderProgram;\r\n }\r\n const webGLRenderingState = pipelineContext as WebGLPipelineContext;\r\n\r\n if (createAsRaw) {\r\n webGLRenderingState.program = createRawShaderProgramInjection(\r\n webGLRenderingState,\r\n vertexSourceCode,\r\n fragmentSourceCode,\r\n webGLRenderingState.context!,\r\n transformFeedbackVaryings\r\n );\r\n } else {\r\n webGLRenderingState.program = createShaderProgramInjection(\r\n webGLRenderingState,\r\n vertexSourceCode,\r\n fragmentSourceCode,\r\n defines,\r\n webGLRenderingState.context!,\r\n transformFeedbackVaryings\r\n );\r\n }\r\n webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;\r\n\r\n onReady();\r\n}\r\n\r\nfunction _compileShader(source: string, type: string, defines: Nullable<string>, shaderVersion: string, gl: WebGLContext, _contextWasLost?: boolean): WebGLShader {\r\n return _compileRawShader(_ConcatenateShader(source, defines, shaderVersion), type, gl, _contextWasLost);\r\n}\r\n\r\nfunction _compileRawShader(source: string, type: string, gl: WebGLContext, _contextWasLost?: boolean): WebGLShader {\r\n const shader = gl.createShader(type === \"vertex\" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);\r\n\r\n if (!shader) {\r\n let error: GLenum = gl.NO_ERROR;\r\n let tempError: GLenum = gl.NO_ERROR;\r\n while ((tempError = gl.getError()) !== gl.NO_ERROR) {\r\n error = tempError;\r\n }\r\n\r\n throw new Error(\r\n `Something went wrong while creating a gl ${type} shader object. gl error=${error}, gl isContextLost=${gl.isContextLost()}, _contextWasLost=${_contextWasLost}`\r\n );\r\n }\r\n\r\n gl.shaderSource(shader, source);\r\n gl.compileShader(shader);\r\n\r\n return shader;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _setProgram(program: WebGLProgram, gl: WebGLContext): void {\r\n gl.useProgram(program);\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: (pipelineContext?: IPipelineContext) => void) {\r\n const webGLPipelineContext = pipelineContext as WebGLPipelineContext;\r\n\r\n if (!webGLPipelineContext.isParallelCompiled) {\r\n action(pipelineContext);\r\n return;\r\n }\r\n\r\n const oldHandler = webGLPipelineContext.onCompiled;\r\n\r\n webGLPipelineContext.onCompiled = () => {\r\n oldHandler?.();\r\n action(pipelineContext);\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"thinEngine.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/thinEngine.functions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAkBhE;;GAEG;AACH,MAAM,YAAY,GAAkD,IAAI,OAAO,EAAE,CAAC;AAElF;;GAEG;AACH,MAAM,iBAAiB,GAA2B;IAC9C,aAAa,EAAE,CAAC;IAChB,eAAe,EAAE,EAAE;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAqB;IAChD,IAAI,KAAK,GAAG,YAAY,CAAC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AAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;IAE1F,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,IAAI,KAAK,GAAW,EAAE,CAAC,QAAQ,CAAC;QAChC,IAAI,SAAS,GAAW,EAAE,CAAC,QAAQ,CAAC;QACpC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC;YACjD,KAAK,GAAG,SAAS,CAAC;QACtB,CAAC;QAED,MAAM,IAAI,KAAK,CACX,4CAA4C,IAAI,4BAA4B,KAAK,sBAAsB,EAAE,CAAC,aAAa,EAAE,qBAAqB,eAAe,EAAE,CAClK,CAAC;IACN,CAAC;IAED,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAqB,EAAE,EAAgB;IAC/D,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oCAAoC,CAAC,eAAiC,EAAE,MAAoD;IACxI,MAAM,oBAAoB,GAAG,eAAuC,CAAC;IAErE,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,CAAC;QAC3C,MAAM,CAAC,eAAe,CAAC,CAAC;QACxB,OAAO;IACX,CAAC;IAED,MAAM,UAAU,GAAG,oBAAoB,CAAC,UAAU,CAAC;IAEnD,oBAAoB,CAAC,UAAU,GAAG,GAAG,EAAE;QACnC,UAAU,EAAE,EAAE,CAAC;QACf,MAAM,CAAC,eAAe,CAAC,CAAC;IAC5B,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { IPipelineContext } from \"./IPipelineContext\";\r\nimport type { ShaderProcessingContext } from \"./Processors/shaderProcessingOptions\";\r\nimport { WebGLPipelineContext } from \"./WebGL/webGLPipelineContext\";\r\nimport type { _loadFile } from \"./abstractEngine.functions\";\r\nimport { _ConcatenateShader } from \"./abstractEngine.functions\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IThinEngineStateObject {\r\n _contextWasLost?: boolean;\r\n validateShaderPrograms?: boolean;\r\n _webGLVersion: number;\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n disableParallelShaderCompile?: boolean;\r\n _context?: WebGLContext;\r\n _createShaderProgramInjection?: typeof _createShaderProgram;\r\n createRawShaderProgramInjection?: typeof createRawShaderProgram;\r\n createShaderProgramInjection?: typeof createShaderProgram;\r\n loadFileInjection?: typeof _loadFile;\r\n cachedPipelines: { [name: string]: IPipelineContext };\r\n}\r\n/**\r\n * @internal\r\n */\r\nconst _stateObject: WeakMap<WebGLContext, IThinEngineStateObject> = new WeakMap();\r\n\r\n/**\r\n * This will be used in cases where the engine doesn't have a context (like the nullengine)\r\n */\r\nconst singleStateObject: IThinEngineStateObject = {\r\n _webGLVersion: 2,\r\n cachedPipelines: {},\r\n};\r\n\r\n/**\r\n * get or create a state object for the given context\r\n * Note - Used in WebGL only at the moment.\r\n * @param context The context to get the state object from\r\n * @returns the state object\r\n * @internal\r\n */\r\nexport function getStateObject(context: WebGLContext): IThinEngineStateObject {\r\n let state = _stateObject.get(context);\r\n if (!state) {\r\n if (!context) {\r\n return singleStateObject;\r\n }\r\n state = {\r\n // use feature detection. instanceof returns false. This only exists on WebGL2 context\r\n _webGLVersion: (context as WebGL2RenderingContext).TEXTURE_BINDING_3D ? 2 : 1,\r\n _context: context,\r\n // when using the function without an engine we need to set it to enable parallel compilation\r\n parallelShaderCompile: context.getExtension(\"KHR_parallel_shader_compile\") || undefined,\r\n cachedPipelines: {},\r\n };\r\n _stateObject.set(context, state);\r\n }\r\n return state;\r\n}\r\n/**\r\n * Remove the state object that belongs to the specific context\r\n * @param context the context that is being\r\n */\r\nexport function deleteStateObject(context: WebGLContext): void {\r\n _stateObject.delete(context);\r\n}\r\n\r\nexport type WebGLContext = WebGLRenderingContext | WebGL2RenderingContext;\r\n/**\r\n * Directly creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @param _createShaderProgramInjection defines an optional injection to use to create the shader program\r\n * @returns the new webGL program\r\n */\r\nexport function createRawShaderProgram(\r\n pipelineContext: IPipelineContext,\r\n vertexCode: string,\r\n fragmentCode: string,\r\n context: WebGLContext,\r\n transformFeedbackVaryings: Nullable<string[]>,\r\n _createShaderProgramInjection?: typeof _createShaderProgram\r\n): WebGLProgram {\r\n const stateObject = getStateObject(context);\r\n if (!_createShaderProgramInjection) {\r\n _createShaderProgramInjection = stateObject._createShaderProgramInjection ?? _createShaderProgram;\r\n }\r\n\r\n const vertexShader = _compileRawShader(vertexCode, \"vertex\", context, stateObject._contextWasLost);\r\n const fragmentShader = _compileRawShader(fragmentCode, \"fragment\", context, stateObject._contextWasLost);\r\n\r\n return _createShaderProgramInjection(\r\n pipelineContext as WebGLPipelineContext,\r\n vertexShader,\r\n fragmentShader,\r\n context,\r\n transformFeedbackVaryings,\r\n stateObject.validateShaderPrograms\r\n );\r\n}\r\n\r\n/**\r\n * Creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param defines defines the string containing the defines to use to compile the shaders\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @param _createShaderProgramInjection defines an optional injection to use to create the shader program\r\n * @returns the new webGL program\r\n */\r\nexport function createShaderProgram(\r\n pipelineContext: IPipelineContext,\r\n vertexCode: string,\r\n fragmentCode: string,\r\n defines: Nullable<string>,\r\n context: WebGLContext,\r\n transformFeedbackVaryings: Nullable<string[]> = null,\r\n _createShaderProgramInjection?: typeof _createShaderProgram\r\n): WebGLProgram {\r\n const stateObject = getStateObject(context);\r\n if (!_createShaderProgramInjection) {\r\n _createShaderProgramInjection = stateObject._createShaderProgramInjection ?? _createShaderProgram;\r\n }\r\n const shaderVersion = stateObject._webGLVersion > 1 ? \"#version 300 es\\n#define WEBGL2 \\n\" : \"\";\r\n const vertexShader = _compileShader(vertexCode, \"vertex\", defines, shaderVersion, context, stateObject._contextWasLost);\r\n const fragmentShader = _compileShader(fragmentCode, \"fragment\", defines, shaderVersion, context, stateObject._contextWasLost);\r\n\r\n return _createShaderProgramInjection(\r\n pipelineContext as WebGLPipelineContext,\r\n vertexShader,\r\n fragmentShader,\r\n context,\r\n transformFeedbackVaryings,\r\n stateObject.validateShaderPrograms\r\n );\r\n}\r\n\r\n/**\r\n * Creates a new pipeline context. Note, make sure to attach an engine instance to the created context\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param _shaderProcessingContext defines the shader processing context used during the processing if available\r\n * @returns the new pipeline\r\n */\r\nexport function createPipelineContext(context: WebGLContext, _shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext {\r\n const pipelineContext = new WebGLPipelineContext();\r\n const stateObject = getStateObject(context);\r\n if (stateObject.parallelShaderCompile && !stateObject.disableParallelShaderCompile) {\r\n pipelineContext.isParallelCompiled = true;\r\n }\r\n pipelineContext.context = stateObject._context;\r\n return pipelineContext;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _createShaderProgram(\r\n pipelineContext: WebGLPipelineContext,\r\n vertexShader: WebGLShader,\r\n fragmentShader: WebGLShader,\r\n context: WebGLContext,\r\n _transformFeedbackVaryings: Nullable<string[]> = null,\r\n validateShaderPrograms?: boolean\r\n): WebGLProgram {\r\n const shaderProgram = context.createProgram();\r\n pipelineContext.program = shaderProgram;\r\n\r\n if (!shaderProgram) {\r\n throw new Error(\"Unable to create program\");\r\n }\r\n\r\n context.attachShader(shaderProgram, vertexShader);\r\n context.attachShader(shaderProgram, fragmentShader);\r\n\r\n context.linkProgram(shaderProgram);\r\n\r\n pipelineContext.context = context;\r\n pipelineContext.vertexShader = vertexShader;\r\n pipelineContext.fragmentShader = fragmentShader;\r\n\r\n if (!pipelineContext.isParallelCompiled) {\r\n _finalizePipelineContext(pipelineContext, context, validateShaderPrograms);\r\n }\r\n\r\n return shaderProgram;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _isRenderingStateCompiled(pipelineContext: IPipelineContext, gl: WebGLContext, validateShaderPrograms?: boolean): boolean {\r\n const webGLPipelineContext = pipelineContext as WebGLPipelineContext;\r\n if (webGLPipelineContext._isDisposed) {\r\n return false;\r\n }\r\n const stateObject = getStateObject(gl);\r\n if (stateObject && stateObject.parallelShaderCompile && stateObject.parallelShaderCompile.COMPLETION_STATUS_KHR && webGLPipelineContext.program) {\r\n if (gl.getProgramParameter(webGLPipelineContext.program, stateObject.parallelShaderCompile.COMPLETION_STATUS_KHR)) {\r\n _finalizePipelineContext(webGLPipelineContext, gl, validateShaderPrograms);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _finalizePipelineContext(pipelineContext: WebGLPipelineContext, gl: WebGLContext, validateShaderPrograms?: boolean) {\r\n const context = pipelineContext.context!;\r\n const vertexShader = pipelineContext.vertexShader!;\r\n const fragmentShader = pipelineContext.fragmentShader!;\r\n const program = pipelineContext.program!;\r\n\r\n const linked = context.getProgramParameter(program, context.LINK_STATUS);\r\n if (!linked) {\r\n // Get more info\r\n // Vertex\r\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\r\n const log = gl.getShaderInfoLog(vertexShader);\r\n if (log) {\r\n pipelineContext.vertexCompilationError = log;\r\n throw new Error(\"VERTEX SHADER \" + log);\r\n }\r\n }\r\n\r\n // Fragment\r\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\r\n const log = gl.getShaderInfoLog(fragmentShader);\r\n if (log) {\r\n pipelineContext.fragmentCompilationError = log;\r\n throw new Error(\"FRAGMENT SHADER \" + log);\r\n }\r\n }\r\n\r\n const error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programLinkError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n\r\n if (/*this.*/ validateShaderPrograms) {\r\n context.validateProgram(program);\r\n const validated = context.getProgramParameter(program, context.VALIDATE_STATUS);\r\n\r\n if (!validated) {\r\n const error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programValidationError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n }\r\n\r\n context.deleteShader(vertexShader);\r\n context.deleteShader(fragmentShader);\r\n\r\n pipelineContext.vertexShader = undefined;\r\n pipelineContext.fragmentShader = undefined;\r\n\r\n if (pipelineContext.onCompiled) {\r\n pipelineContext.onCompiled();\r\n pipelineContext.onCompiled = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _preparePipelineContext(\r\n pipelineContext: IPipelineContext,\r\n vertexSourceCode: string,\r\n fragmentSourceCode: string,\r\n createAsRaw: boolean,\r\n _rawVertexSourceCode: string,\r\n _rawFragmentSourceCode: string,\r\n rebuildRebind: any,\r\n defines: Nullable<string>,\r\n transformFeedbackVaryings: Nullable<string[]>,\r\n _key: string = \"\",\r\n onReady: () => void,\r\n createRawShaderProgramInjection?: typeof createRawShaderProgram,\r\n createShaderProgramInjection?: typeof createShaderProgram\r\n) {\r\n const stateObject = getStateObject((pipelineContext as WebGLPipelineContext).context!);\r\n if (!createRawShaderProgramInjection) {\r\n createRawShaderProgramInjection = stateObject.createRawShaderProgramInjection ?? createRawShaderProgram;\r\n }\r\n if (!createShaderProgramInjection) {\r\n createShaderProgramInjection = stateObject.createShaderProgramInjection ?? createShaderProgram;\r\n }\r\n const webGLRenderingState = pipelineContext as WebGLPipelineContext;\r\n\r\n if (createAsRaw) {\r\n webGLRenderingState.program = createRawShaderProgramInjection(\r\n webGLRenderingState,\r\n vertexSourceCode,\r\n fragmentSourceCode,\r\n webGLRenderingState.context!,\r\n transformFeedbackVaryings\r\n );\r\n } else {\r\n webGLRenderingState.program = createShaderProgramInjection(\r\n webGLRenderingState,\r\n vertexSourceCode,\r\n fragmentSourceCode,\r\n defines,\r\n webGLRenderingState.context!,\r\n transformFeedbackVaryings\r\n );\r\n }\r\n webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;\r\n\r\n onReady();\r\n}\r\n\r\nfunction _compileShader(source: string, type: string, defines: Nullable<string>, shaderVersion: string, gl: WebGLContext, _contextWasLost?: boolean): WebGLShader {\r\n return _compileRawShader(_ConcatenateShader(source, defines, shaderVersion), type, gl, _contextWasLost);\r\n}\r\n\r\nfunction _compileRawShader(source: string, type: string, gl: WebGLContext, _contextWasLost?: boolean): WebGLShader {\r\n const shader = gl.createShader(type === \"vertex\" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);\r\n\r\n if (!shader) {\r\n let error: GLenum = gl.NO_ERROR;\r\n let tempError: GLenum = gl.NO_ERROR;\r\n while ((tempError = gl.getError()) !== gl.NO_ERROR) {\r\n error = tempError;\r\n }\r\n\r\n throw new Error(\r\n `Something went wrong while creating a gl ${type} shader object. gl error=${error}, gl isContextLost=${gl.isContextLost()}, _contextWasLost=${_contextWasLost}`\r\n );\r\n }\r\n\r\n gl.shaderSource(shader, source);\r\n gl.compileShader(shader);\r\n\r\n return shader;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _setProgram(program: WebGLProgram, gl: WebGLContext): void {\r\n gl.useProgram(program);\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: (pipelineContext?: IPipelineContext) => void) {\r\n const webGLPipelineContext = pipelineContext as WebGLPipelineContext;\r\n\r\n if (!webGLPipelineContext.isParallelCompiled) {\r\n action(pipelineContext);\r\n return;\r\n }\r\n\r\n const oldHandler = webGLPipelineContext.onCompiled;\r\n\r\n webGLPipelineContext.onCompiled = () => {\r\n oldHandler?.();\r\n action(pipelineContext);\r\n };\r\n}\r\n"]}
@@ -0,0 +1,43 @@
1
+ import type { NodeRenderGraphConnectionPoint, Scene, FrameGraph, NodeRenderGraphBuildState } from "../../../../index.js";
2
+ import { NodeRenderGraphBlock } from "../../nodeRenderGraphBlock";
3
+ import { FrameGraphUtilityLayerRendererTask } from "../../../Tasks/Rendering/utilityLayerRendererTask";
4
+ /**
5
+ * Block used to render an utility layer in the frame graph
6
+ */
7
+ export declare class NodeRenderGraphUtilityLayerRendererBlock extends NodeRenderGraphBlock {
8
+ protected _frameGraphTask: FrameGraphUtilityLayerRendererTask;
9
+ /**
10
+ * Gets the frame graph task associated with this block
11
+ */
12
+ get task(): FrameGraphUtilityLayerRendererTask;
13
+ /**
14
+ * Creates a new NodeRenderGraphUtilityLayerRendererBlock
15
+ * @param name defines the block name
16
+ * @param frameGraph defines the hosting frame graph
17
+ * @param scene defines the hosting scene
18
+ * @param handleEvents If the utility layer should handle events.
19
+ */
20
+ constructor(name: string, frameGraph: FrameGraph, scene: Scene, handleEvents?: boolean);
21
+ private _createTask;
22
+ /** If the utility layer should handle events */
23
+ get handleEvents(): boolean;
24
+ set handleEvents(value: boolean);
25
+ /**
26
+ * Gets the current class name
27
+ * @returns the class name
28
+ */
29
+ getClassName(): string;
30
+ /**
31
+ * Gets the destination input component
32
+ */
33
+ get destination(): NodeRenderGraphConnectionPoint;
34
+ /**
35
+ * Gets the camera input component
36
+ */
37
+ get camera(): NodeRenderGraphConnectionPoint;
38
+ /**
39
+ * Gets the output component
40
+ */
41
+ get output(): NodeRenderGraphConnectionPoint;
42
+ protected _buildBlock(state: NodeRenderGraphBuildState): void;
43
+ }
@@ -0,0 +1,83 @@
1
+ import { __decorate } from "../../../../tslib.es6.js";
2
+ import { RegisterClass } from "../../../../Misc/typeStore.js";
3
+ import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
4
+ import { NodeRenderGraphBlockConnectionPointTypes } from "../../Types/nodeRenderGraphTypes.js";
5
+ import { NodeRenderGraphBlock } from "../../nodeRenderGraphBlock.js";
6
+ import { FrameGraphUtilityLayerRendererTask } from "../../../Tasks/Rendering/utilityLayerRendererTask.js";
7
+ /**
8
+ * Block used to render an utility layer in the frame graph
9
+ */
10
+ export class NodeRenderGraphUtilityLayerRendererBlock extends NodeRenderGraphBlock {
11
+ /**
12
+ * Gets the frame graph task associated with this block
13
+ */
14
+ get task() {
15
+ return this._frameGraphTask;
16
+ }
17
+ /**
18
+ * Creates a new NodeRenderGraphUtilityLayerRendererBlock
19
+ * @param name defines the block name
20
+ * @param frameGraph defines the hosting frame graph
21
+ * @param scene defines the hosting scene
22
+ * @param handleEvents If the utility layer should handle events.
23
+ */
24
+ constructor(name, frameGraph, scene, handleEvents = true) {
25
+ super(name, frameGraph, scene);
26
+ this._additionalConstructionParameters = [handleEvents];
27
+ this.registerInput("destination", NodeRenderGraphBlockConnectionPointTypes.Texture);
28
+ this.registerInput("camera", NodeRenderGraphBlockConnectionPointTypes.Camera);
29
+ this._addDependenciesInput();
30
+ this.registerOutput("output", NodeRenderGraphBlockConnectionPointTypes.BasedOnInput);
31
+ this.destination.addAcceptedConnectionPointTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAll);
32
+ this.output._typeConnectionSource = this.destination;
33
+ this._frameGraphTask = new FrameGraphUtilityLayerRendererTask(name, frameGraph, scene, handleEvents);
34
+ }
35
+ _createTask(handleEvents) {
36
+ this._frameGraphTask.dispose();
37
+ this._frameGraphTask = new FrameGraphUtilityLayerRendererTask(this.name, this._frameGraph, this._scene, handleEvents);
38
+ this._additionalConstructionParameters = [handleEvents];
39
+ }
40
+ /** If the utility layer should handle events */
41
+ get handleEvents() {
42
+ return this._frameGraphTask.layer.handleEvents;
43
+ }
44
+ set handleEvents(value) {
45
+ this._createTask(value);
46
+ }
47
+ /**
48
+ * Gets the current class name
49
+ * @returns the class name
50
+ */
51
+ getClassName() {
52
+ return "NodeRenderGraphUtilityLayerRendererBlock";
53
+ }
54
+ /**
55
+ * Gets the destination input component
56
+ */
57
+ get destination() {
58
+ return this._inputs[0];
59
+ }
60
+ /**
61
+ * Gets the camera input component
62
+ */
63
+ get camera() {
64
+ return this._inputs[1];
65
+ }
66
+ /**
67
+ * Gets the output component
68
+ */
69
+ get output() {
70
+ return this._outputs[0];
71
+ }
72
+ _buildBlock(state) {
73
+ super._buildBlock(state);
74
+ this.output.value = this._frameGraphTask.outputTexture;
75
+ this._frameGraphTask.destinationTexture = this.destination.connectedPoint?.value;
76
+ this._frameGraphTask.camera = this.camera.connectedPoint?.value;
77
+ }
78
+ }
79
+ __decorate([
80
+ editableInPropertyPage("Handle events", 0 /* PropertyTypeForEdition.Boolean */, "PROPERTIES")
81
+ ], NodeRenderGraphUtilityLayerRendererBlock.prototype, "handleEvents", null);
82
+ RegisterClass("BABYLON.NodeRenderGraphUtilityLayerRendererBlock", NodeRenderGraphUtilityLayerRendererBlock);
83
+ //# sourceMappingURL=utilityLayerRendererBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilityLayerRendererBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,wCAAwC,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,kCAAkC,EAAE,MAAM,mDAAmD,CAAC;AAEvG;;GAEG;AACH,MAAM,OAAO,wCAAyC,SAAQ,oBAAoB;IAG9E;;OAEG;IACH,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,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AAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,0CAA0C,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAEkB,WAAW,CAAC,KAAgC;QAC3D,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEzB,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAEvD,IAAI,CAAC,eAAe,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,KAAgC,CAAC;QAC5G,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,KAAe,CAAC;IAC9E,CAAC;CACJ;AA7CG;IADC,sBAAsB,CAAC,eAAe,0CAAkC,YAAY,CAAC;4EAGrF;AA6CL,aAAa,CAAC,kDAAkD,EAAE,wCAAwC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { NodeRenderGraphConnectionPoint, Scene, FrameGraph, NodeRenderGraphBuildState, FrameGraphTextureHandle, Camera } from \"core/index\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport { NodeRenderGraphBlockConnectionPointTypes } from \"../../Types/nodeRenderGraphTypes\";\r\nimport { NodeRenderGraphBlock } from \"../../nodeRenderGraphBlock\";\r\nimport { FrameGraphUtilityLayerRendererTask } from \"../../../Tasks/Rendering/utilityLayerRendererTask\";\r\n\r\n/**\r\n * Block used to render an utility layer in the frame graph\r\n */\r\nexport class NodeRenderGraphUtilityLayerRendererBlock extends NodeRenderGraphBlock {\r\n protected override _frameGraphTask: FrameGraphUtilityLayerRendererTask;\r\n\r\n /**\r\n * Gets the frame graph task associated with this block\r\n */\r\n public override get task() {\r\n return this._frameGraphTask;\r\n }\r\n\r\n /**\r\n * Creates a new NodeRenderGraphUtilityLayerRendererBlock\r\n * @param name defines the block name\r\n * @param frameGraph defines the hosting frame graph\r\n * @param scene defines the hosting scene\r\n * @param handleEvents If the utility layer should handle events.\r\n */\r\n public constructor(name: string, frameGraph: FrameGraph, scene: Scene, handleEvents = true) {\r\n super(name, frameGraph, scene);\r\n\r\n this._additionalConstructionParameters = [handleEvents];\r\n\r\n this.registerInput(\"destination\", NodeRenderGraphBlockConnectionPointTypes.Texture);\r\n this.registerInput(\"camera\", NodeRenderGraphBlockConnectionPointTypes.Camera);\r\n this._addDependenciesInput();\r\n this.registerOutput(\"output\", NodeRenderGraphBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.destination.addAcceptedConnectionPointTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAll);\r\n this.output._typeConnectionSource = this.destination;\r\n\r\n this._frameGraphTask = new FrameGraphUtilityLayerRendererTask(name, frameGraph, scene, handleEvents);\r\n }\r\n\r\n private _createTask(handleEvents: boolean) {\r\n this._frameGraphTask.dispose();\r\n\r\n this._frameGraphTask = new FrameGraphUtilityLayerRendererTask(this.name, this._frameGraph, this._scene, handleEvents);\r\n\r\n this._additionalConstructionParameters = [handleEvents];\r\n }\r\n\r\n /** If the utility layer should handle events */\r\n @editableInPropertyPage(\"Handle events\", PropertyTypeForEdition.Boolean, \"PROPERTIES\")\r\n public get handleEvents() {\r\n return this._frameGraphTask.layer.handleEvents;\r\n }\r\n\r\n public set handleEvents(value: boolean) {\r\n this._createTask(value);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"NodeRenderGraphUtilityLayerRendererBlock\";\r\n }\r\n\r\n /**\r\n * Gets the destination input component\r\n */\r\n public get destination(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the camera input component\r\n */\r\n public get camera(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeRenderGraphConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeRenderGraphBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.output.value = this._frameGraphTask.outputTexture;\r\n\r\n this._frameGraphTask.destinationTexture = this.destination.connectedPoint?.value as FrameGraphTextureHandle;\r\n this._frameGraphTask.camera = this.camera.connectedPoint?.value as Camera;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NodeRenderGraphUtilityLayerRendererBlock\", NodeRenderGraphUtilityLayerRendererBlock);\r\n"]}
@@ -18,6 +18,7 @@ export * from "./Rendering/geometryRendererBlock";
18
18
  export * from "./Rendering/objectRendererBlock";
19
19
  export * from "./Rendering/shadowGeneratorBlock";
20
20
  export * from "./Rendering/taaObjectRendererBlock";
21
+ export * from "./Rendering/utilityLayerRendererBlock";
21
22
  export * from "./Teleport/teleportInBlock";
22
23
  export * from "./Teleport/teleportOutBlock";
23
24
  export * from "./Textures/clearBlock";
@@ -18,6 +18,7 @@ export * from "./Rendering/geometryRendererBlock.js";
18
18
  export * from "./Rendering/objectRendererBlock.js";
19
19
  export * from "./Rendering/shadowGeneratorBlock.js";
20
20
  export * from "./Rendering/taaObjectRendererBlock.js";
21
+ export * from "./Rendering/utilityLayerRendererBlock.js";
21
22
  export * from "./Teleport/teleportInBlock.js";
22
23
  export * from "./Teleport/teleportOutBlock.js";
23
24
  export * from "./Textures/clearBlock.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AAEzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,+CAA+C,CAAC;AAC9D,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mDAAmD,CAAC;AAClE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC;AAErD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from \"./elbowBlock\";\r\nexport * from \"./executeBlock\";\r\nexport * from \"./inputBlock\";\r\nexport * from \"./outputBlock\";\r\nexport * from \"./resourceContainerBlock\";\r\n\r\nexport * from \"./Layers/glowLayerBlock\";\r\nexport * from \"./Layers/highlightLayerBlock\";\r\n\r\nexport * from \"./PostProcesses/blackAndWhitePostProcessBlock\";\r\nexport * from \"./PostProcesses/bloomPostProcessBlock\";\r\nexport * from \"./PostProcesses/blurPostProcessBlock\";\r\nexport * from \"./PostProcesses/circleOfConfusionPostProcessBlock\";\r\nexport * from \"./PostProcesses/depthOfFieldPostProcessBlock\";\r\nexport * from \"./PostProcesses/extractHighlightsPostProcessBlock\";\r\nexport * from \"./PostProcesses/passPostProcessBlock\";\r\n\r\nexport * from \"./Rendering/csmShadowGeneratorBlock\";\r\nexport * from \"./Rendering/cullObjectsBlock\";\r\nexport * from \"./Rendering/geometryRendererBlock\";\r\nexport * from \"./Rendering/objectRendererBlock\";\r\nexport * from \"./Rendering/shadowGeneratorBlock\";\r\nexport * from \"./Rendering/taaObjectRendererBlock\";\r\n\r\nexport * from \"./Teleport/teleportInBlock\";\r\nexport * from \"./Teleport/teleportOutBlock\";\r\n\r\nexport * from \"./Textures/clearBlock\";\r\nexport * from \"./Textures/copyTextureBlock\";\r\nexport * from \"./Textures/generateMipmapsBlock\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AAEzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,+CAA+C,CAAC;AAC9D,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mDAAmD,CAAC;AAClE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC;AAErD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from \"./elbowBlock\";\r\nexport * from \"./executeBlock\";\r\nexport * from \"./inputBlock\";\r\nexport * from \"./outputBlock\";\r\nexport * from \"./resourceContainerBlock\";\r\n\r\nexport * from \"./Layers/glowLayerBlock\";\r\nexport * from \"./Layers/highlightLayerBlock\";\r\n\r\nexport * from \"./PostProcesses/blackAndWhitePostProcessBlock\";\r\nexport * from \"./PostProcesses/bloomPostProcessBlock\";\r\nexport * from \"./PostProcesses/blurPostProcessBlock\";\r\nexport * from \"./PostProcesses/circleOfConfusionPostProcessBlock\";\r\nexport * from \"./PostProcesses/depthOfFieldPostProcessBlock\";\r\nexport * from \"./PostProcesses/extractHighlightsPostProcessBlock\";\r\nexport * from \"./PostProcesses/passPostProcessBlock\";\r\n\r\nexport * from \"./Rendering/csmShadowGeneratorBlock\";\r\nexport * from \"./Rendering/cullObjectsBlock\";\r\nexport * from \"./Rendering/geometryRendererBlock\";\r\nexport * from \"./Rendering/objectRendererBlock\";\r\nexport * from \"./Rendering/shadowGeneratorBlock\";\r\nexport * from \"./Rendering/taaObjectRendererBlock\";\r\nexport * from \"./Rendering/utilityLayerRendererBlock\";\r\n\r\nexport * from \"./Teleport/teleportInBlock\";\r\nexport * from \"./Teleport/teleportOutBlock\";\r\n\r\nexport * from \"./Textures/clearBlock\";\r\nexport * from \"./Textures/copyTextureBlock\";\r\nexport * from \"./Textures/generateMipmapsBlock\";\r\n"]}
@@ -0,0 +1,35 @@
1
+ import type { Camera, FrameGraph, FrameGraphTextureHandle, Scene } from "../../../index.js";
2
+ import { FrameGraphTask } from "../../frameGraphTask";
3
+ import { UtilityLayerRenderer } from "../../../Rendering/utilityLayerRenderer.js";
4
+ /**
5
+ * Task used to render an utility layer.
6
+ */
7
+ export declare class FrameGraphUtilityLayerRendererTask extends FrameGraphTask {
8
+ /**
9
+ * The destination texture of the task.
10
+ */
11
+ destinationTexture: FrameGraphTextureHandle;
12
+ /**
13
+ * The camera used to render the utility layer.
14
+ */
15
+ camera: Camera;
16
+ /**
17
+ * The output texture of the task.
18
+ * This is the same texture as the destination texture, but the handles are different!
19
+ */
20
+ readonly outputTexture: FrameGraphTextureHandle;
21
+ /**
22
+ * The utility layer renderer.
23
+ */
24
+ readonly layer: UtilityLayerRenderer;
25
+ /**
26
+ * Creates a new utility layer renderer task.
27
+ * @param name The name of the task.
28
+ * @param frameGraph The frame graph the task belongs to.
29
+ * @param scene The scene the task belongs to.
30
+ * @param handleEvents If the utility layer should handle events.
31
+ */
32
+ constructor(name: string, frameGraph: FrameGraph, scene: Scene, handleEvents?: boolean);
33
+ record(): void;
34
+ dispose(): void;
35
+ }
@@ -0,0 +1,40 @@
1
+ import { FrameGraphTask } from "../../frameGraphTask.js";
2
+ import { UtilityLayerRenderer } from "../../../Rendering/utilityLayerRenderer.js";
3
+ /**
4
+ * Task used to render an utility layer.
5
+ */
6
+ export class FrameGraphUtilityLayerRendererTask extends FrameGraphTask {
7
+ /**
8
+ * Creates a new utility layer renderer task.
9
+ * @param name The name of the task.
10
+ * @param frameGraph The frame graph the task belongs to.
11
+ * @param scene The scene the task belongs to.
12
+ * @param handleEvents If the utility layer should handle events.
13
+ */
14
+ constructor(name, frameGraph, scene, handleEvents = true) {
15
+ super(name, frameGraph);
16
+ this.layer = new UtilityLayerRenderer(scene, handleEvents, true);
17
+ this.layer.utilityLayerScene._useCurrentFrameBuffer = true;
18
+ this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
19
+ }
20
+ record() {
21
+ if (!this.destinationTexture || !this.camera) {
22
+ throw new Error("FrameGraphUtilityLayerRendererTask: destinationTexture and camera are required");
23
+ }
24
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
25
+ const pass = this._frameGraph.addRenderPass(this.name);
26
+ pass.setRenderTarget(this.outputTexture);
27
+ pass.setExecuteFunc((context) => {
28
+ this.layer.setRenderCamera(this.camera);
29
+ context.render(this.layer);
30
+ });
31
+ const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
32
+ passDisabled.setRenderTarget(this.outputTexture);
33
+ passDisabled.setExecuteFunc((_context) => { });
34
+ }
35
+ dispose() {
36
+ this.layer.dispose();
37
+ super.dispose();
38
+ }
39
+ }
40
+ //# sourceMappingURL=utilityLayerRendererTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilityLayerRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,mDAA4C;AAE3E;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,cAAc;IAsBlE;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,KAAY,EAAE,YAAY,GAAG,IAAI;QAC/E,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAExB,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;QACjE,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,sBAAsB,GAAG,IAAI,CAAC;QAE3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IAChF,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;QACtG,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEnG,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAExC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Camera, FrameGraph, FrameGraphTextureHandle, Scene } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { UtilityLayerRenderer } from \"core/Rendering/utilityLayerRenderer\";\r\n\r\n/**\r\n * Task used to render an utility layer.\r\n */\r\nexport class FrameGraphUtilityLayerRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture of the task.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The camera used to render the utility layer.\r\n */\r\n public camera: Camera;\r\n\r\n /**\r\n * The output texture of the task.\r\n * This is the same texture as the destination texture, but the handles are different!\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The utility layer renderer.\r\n */\r\n public readonly layer: UtilityLayerRenderer;\r\n\r\n /**\r\n * Creates a new utility layer renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the task belongs to.\r\n * @param handleEvents If the utility layer should handle events.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, handleEvents = true) {\r\n super(name, frameGraph);\r\n\r\n this.layer = new UtilityLayerRenderer(scene, handleEvents, true);\r\n this.layer.utilityLayerScene._useCurrentFrameBuffer = true;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record(): void {\r\n if (!this.destinationTexture || !this.camera) {\r\n throw new Error(\"FrameGraphUtilityLayerRendererTask: destinationTexture and camera are required\");\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setExecuteFunc((context) => {\r\n this.layer.setRenderCamera(this.camera);\r\n\r\n context.render(this.layer);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n public override dispose(): void {\r\n this.layer.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -32,6 +32,10 @@ export declare class FrameGraph {
32
32
  * Gets the engine used by the frame graph
33
33
  */
34
34
  get engine(): AbstractEngine;
35
+ /**
36
+ * Gets the list of tasks in the frame graph
37
+ */
38
+ get tasks(): FrameGraphTask[];
35
39
  /**
36
40
  * Constructs the frame graph
37
41
  * @param engine defines the hosting engine
@@ -24,6 +24,12 @@ export class FrameGraph {
24
24
  get engine() {
25
25
  return this._engine;
26
26
  }
27
+ /**
28
+ * Gets the list of tasks in the frame graph
29
+ */
30
+ get tasks() {
31
+ return this._tasks;
32
+ }
27
33
  /**
28
34
  * Constructs the frame graph
29
35
  * @param engine defines the hosting engine
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,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AM,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;IACnC,CAAC;CACJ","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport type { Scene, AbstractEngine, FrameGraphTask, Nullable } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { _retryWithInterval } from \"core/Misc/timingTools\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n Cull = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\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 * Constructs the frame graph\r\n * @param engine defines the hosting engine\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector\r\n * @param scene defines the scene the frame graph is associated with\r\n */\r\n constructor(engine: AbstractEngine, debugTextures = false, scene: Scene) {\r\n this._engine = engine;\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext();\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\r\n\r\n /**\r\n * Adds a 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 a cull pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.Cull:\r\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /**\r\n * Builds the frame graph.\r\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\r\n */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\r\n\r\n try {\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures(this.optimizeTextureAllocation ? this._tasks : undefined);\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task.onTexturesAllocatedObservable.notifyObservers(this._renderContext);\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\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 }\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param 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 30000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public whenReadyAsync(timeStep = 16, maxTimeout = 30000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n return new Promise((resolve) => {\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 },\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 this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n 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}\r\n"]}
1
+ {"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAClD,OAAO,EAAE,kBAAkB,EAAE,+BAA8B;AAC3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ACtC,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;IACnC,CAAC;CACJ","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport type { Scene, AbstractEngine, FrameGraphTask, Nullable } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { _retryWithInterval } from \"core/Misc/timingTools\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n Cull = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\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 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 * Constructs the frame graph\r\n * @param engine defines the hosting engine\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector\r\n * @param scene defines the scene the frame graph is associated with\r\n */\r\n constructor(engine: AbstractEngine, debugTextures = false, scene: Scene) {\r\n this._engine = engine;\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext();\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\r\n\r\n /**\r\n * Adds a 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 a cull pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.Cull:\r\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /**\r\n * Builds the frame graph.\r\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\r\n */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\r\n\r\n try {\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures(this.optimizeTextureAllocation ? this._tasks : undefined);\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task.onTexturesAllocatedObservable.notifyObservers(this._renderContext);\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\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 }\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param 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 30000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public whenReadyAsync(timeStep = 16, maxTimeout = 30000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n return new Promise((resolve) => {\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 },\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 this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n 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}\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager, ObjectRenderer, Scene, FrameGraphRenderTarget } from "../index.js";
1
+ import type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager, ObjectRenderer, Scene, FrameGraphRenderTarget, UtilityLayerRenderer } from "../index.js";
2
2
  import { FrameGraphContext } from "./frameGraphContext";
3
3
  /**
4
4
  * Frame graph context used render passes.
@@ -115,7 +115,7 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
115
115
  * @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)
116
116
  * @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)
117
117
  */
118
- render(object: Layer | ObjectRenderer, viewportWidth?: number, viewportHeight?: number): void;
118
+ render(object: Layer | ObjectRenderer | UtilityLayerRenderer, viewportWidth?: number, viewportHeight?: number): void;
119
119
  /**
120
120
  * Binds a render target texture so that upcoming draw calls will render to it
121
121
  * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call