@babylonjs/core 8.34.1 → 8.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/Audio/audioSceneComponent.d.ts +9 -5
  2. package/Audio/audioSceneComponent.js +1 -0
  3. package/Audio/audioSceneComponent.js.map +1 -1
  4. package/AudioV2/abstractAudio/audioEngineV2.d.ts +10 -0
  5. package/AudioV2/abstractAudio/audioEngineV2.js +29 -0
  6. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  7. package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
  8. package/AudioV2/webAudio/webAudioEngine.js +8 -0
  9. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  10. package/AudioV2/webAudio/webAudioStaticSound.js +2 -2
  11. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  12. package/AudioV2/webAudio/webAudioStreamingSound.js +2 -2
  13. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  14. package/Cameras/camera.d.ts +4 -0
  15. package/Cameras/camera.js +18 -9
  16. package/Cameras/camera.js.map +1 -1
  17. package/Engines/abstractEngine.js +2 -2
  18. package/Engines/abstractEngine.js.map +1 -1
  19. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
  20. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  21. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +1 -1
  22. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
  23. package/FrameGraph/Node/Blocks/computeShaderBlock.d.ts +42 -0
  24. package/FrameGraph/Node/Blocks/computeShaderBlock.js +74 -0
  25. package/FrameGraph/Node/Blocks/computeShaderBlock.js.map +1 -0
  26. package/FrameGraph/Node/Blocks/executeBlock.d.ts +11 -1
  27. package/FrameGraph/Node/Blocks/executeBlock.js +18 -0
  28. package/FrameGraph/Node/Blocks/executeBlock.js.map +1 -1
  29. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  30. package/FrameGraph/Node/Blocks/index.js +1 -0
  31. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  32. package/FrameGraph/Node/Blocks/inputBlock.js +2 -0
  33. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  34. package/FrameGraph/Node/Blocks/outputBlock.js +1 -0
  35. package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -1
  36. package/FrameGraph/Node/nodeRenderGraph.d.ts +1 -1
  37. package/FrameGraph/Node/nodeRenderGraph.js +7 -3
  38. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  39. package/FrameGraph/Node/nodeRenderGraphBlock.js +7 -0
  40. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  41. package/FrameGraph/Passes/pass.d.ts +11 -1
  42. package/FrameGraph/Passes/pass.js +11 -1
  43. package/FrameGraph/Passes/pass.js.map +1 -1
  44. package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +115 -0
  45. package/FrameGraph/Tasks/Misc/computeShaderTask.js +174 -0
  46. package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -0
  47. package/FrameGraph/Tasks/Misc/executeTask.d.ts +5 -0
  48. package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
  49. package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
  50. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -1
  51. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
  52. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  53. package/FrameGraph/frameGraph.d.ts +1 -1
  54. package/FrameGraph/frameGraph.js +3 -6
  55. package/FrameGraph/frameGraph.js.map +1 -1
  56. package/FrameGraph/frameGraphTask.d.ts +3 -2
  57. package/FrameGraph/frameGraphTask.js +5 -2
  58. package/FrameGraph/frameGraphTask.js.map +1 -1
  59. package/FrameGraph/frameGraphTextureManager.js +2 -2
  60. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  61. package/FrameGraph/index.d.ts +1 -0
  62. package/FrameGraph/index.js +1 -0
  63. package/FrameGraph/index.js.map +1 -1
  64. package/Lights/directionalLight.js +1 -4
  65. package/Lights/directionalLight.js.map +1 -1
  66. package/Lights/pointLight.js +2 -5
  67. package/Lights/pointLight.js.map +1 -1
  68. package/Materials/clipPlaneMaterialHelper.js +11 -1
  69. package/Materials/clipPlaneMaterialHelper.js.map +1 -1
  70. package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
  71. package/Materials/floatingOriginMatrixOverrides.js +14 -2
  72. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  73. package/Materials/index.d.ts +1 -0
  74. package/Materials/index.js +1 -0
  75. package/Materials/index.js.map +1 -1
  76. package/Maths/math.like.d.ts +7 -2
  77. package/Maths/math.like.js.map +1 -1
  78. package/Maths/math.vector.functions.d.ts +57 -15
  79. package/Maths/math.vector.functions.js +77 -8
  80. package/Maths/math.vector.functions.js.map +1 -1
  81. package/Misc/decorators.d.ts +1 -1
  82. package/Misc/decorators.js.map +1 -1
  83. package/Misc/dumpTools.d.ts +20 -0
  84. package/Misc/dumpTools.js +60 -49
  85. package/Misc/dumpTools.js.map +1 -1
  86. package/Misc/index.d.ts +1 -2
  87. package/Misc/index.js +1 -2
  88. package/Misc/index.js.map +1 -1
  89. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
  90. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  91. package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +8 -0
  92. package/Particles/Node/Blocks/Emitters/createParticleBlock.js +25 -2
  93. package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
  94. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
  95. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  96. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
  97. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  98. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
  99. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  100. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
  101. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  102. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
  103. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  104. package/Particles/Node/Blocks/systemBlock.d.ts +32 -0
  105. package/Particles/Node/Blocks/systemBlock.js +76 -0
  106. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  107. package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
  108. package/Particles/Node/nodeParticleBuildState.js +7 -22
  109. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  110. package/Particles/Node/nodeParticleSystemSet.helper.js +164 -56
  111. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  112. package/Particles/thinParticleSystem.js +1 -0
  113. package/Particles/thinParticleSystem.js.map +1 -1
  114. package/Physics/physicsRaycastResult.d.ts +3 -0
  115. package/Physics/physicsRaycastResult.js.map +1 -1
  116. package/Physics/v2/Plugins/havokPlugin.js +1 -1
  117. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  118. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +1 -1
  119. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  120. package/PostProcesses/thinSSAO2PostProcess.js +9 -2
  121. package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
  122. package/package.json +1 -1
  123. package/scene.d.ts +7 -2
  124. package/scene.js +15 -8
  125. package/scene.js.map +1 -1
@@ -0,0 +1,115 @@
1
+ import type { BaseTexture, DataBuffer, ExternalTexture, FrameGraph, FrameGraphContext, FrameGraphPass, IComputeShaderOptions, IComputeShaderPath, InternalTexture, StorageBuffer, TextureSampler, VideoTexture } from "../../../index.js";
2
+ import { FrameGraphTask } from "../../frameGraphTask.js";
3
+ import { ComputeShader } from "../../../Compute/computeShader.js";
4
+ import { Vector3 } from "../../../Maths/math.vector.js";
5
+ import { UniformBuffer } from "../../../Materials/uniformBuffer.js";
6
+ /**
7
+ * Task used to execute a compute shader (WebGPU only)
8
+ */
9
+ export declare class FrameGraphComputeShaderTask extends FrameGraphTask {
10
+ private readonly _notSupported;
11
+ private readonly _cs;
12
+ private readonly _ubo;
13
+ /**
14
+ * Defines the dispatch size for the compute shader
15
+ */
16
+ dispatchSize: Vector3;
17
+ /**
18
+ * Defines an indirect dispatch buffer and offset.
19
+ * If set, this will be used instead of the dispatchSize property and an indirect dispatch will be performed.
20
+ * "offset" is the offset in the buffer where the workgroup counts are stored (default: 0)
21
+ */
22
+ indirectDispatch?: {
23
+ buffer: StorageBuffer | DataBuffer;
24
+ offset?: number;
25
+ };
26
+ /**
27
+ * An optional execute function that will be called at the beginning of the task execution
28
+ */
29
+ execute?: (context: FrameGraphContext) => void;
30
+ /**
31
+ * Gets the compute shader used by the task
32
+ */
33
+ get computeShader(): ComputeShader;
34
+ /**
35
+ * Gets a uniform buffer created by a call to createUniformBuffer()
36
+ * @param name Name of the uniform buffer
37
+ * @returns The uniform buffer
38
+ */
39
+ getUniformBuffer(name: string): UniformBuffer;
40
+ /**
41
+ * Creates a new compute shader task.
42
+ * @param name The name of the task.
43
+ * @param frameGraph The frame graph the task belongs to.
44
+ * @param shaderPath Defines the route to the shader code in one of three ways:
45
+ * * object: \{ compute: "custom" \}, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
46
+ * * object: \{ computeElement: "HTMLElementId" \}, used with shader code in script tags
47
+ * * object: \{ computeSource: "compute shader code string" \}, where the string contains the shader code
48
+ * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
49
+ * @param options Define the options used to create the shader
50
+ */
51
+ constructor(name: string, frameGraph: FrameGraph, shaderPath: IComputeShaderPath | string, options?: Partial<IComputeShaderOptions>);
52
+ isReady(): boolean;
53
+ /**
54
+ * Creates a uniform buffer and binds it to the shader
55
+ * @param name Name of the uniform buffer
56
+ * @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms
57
+ * @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)
58
+ * @returns The created uniform buffer
59
+ */
60
+ createUniformBuffer(name: string, description: {
61
+ [name: string]: number;
62
+ }, autoUpdate?: boolean): UniformBuffer;
63
+ /**
64
+ * Binds a texture to the shader
65
+ * @param name Binding name of the texture
66
+ * @param texture Texture to bind
67
+ * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture
68
+ */
69
+ setTexture(name: string, texture: BaseTexture, bindSampler?: boolean): void;
70
+ /**
71
+ * Binds an internal texture to the shader
72
+ * @param name Binding name of the texture
73
+ * @param texture Texture to bind
74
+ */
75
+ setInternalTexture(name: string, texture: InternalTexture): void;
76
+ /**
77
+ * Binds a storage texture to the shader
78
+ * @param name Binding name of the texture
79
+ * @param texture Texture to bind
80
+ */
81
+ setStorageTexture(name: string, texture: BaseTexture): void;
82
+ /**
83
+ * Binds an external texture to the shader
84
+ * @param name Binding name of the texture
85
+ * @param texture Texture to bind
86
+ */
87
+ setExternalTexture(name: string, texture: ExternalTexture): void;
88
+ /**
89
+ * Binds a video texture to the shader (by binding the external texture attached to this video)
90
+ * @param name Binding name of the texture
91
+ * @param texture Texture to bind
92
+ * @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures
93
+ */
94
+ setVideoTexture(name: string, texture: VideoTexture): boolean;
95
+ /**
96
+ * Binds a uniform buffer to the shader
97
+ * @param name Binding name of the buffer
98
+ * @param buffer Buffer to bind
99
+ */
100
+ setUniformBuffer(name: string, buffer: UniformBuffer | DataBuffer): void;
101
+ /**
102
+ * Binds a storage buffer to the shader
103
+ * @param name Binding name of the buffer
104
+ * @param buffer Buffer to bind
105
+ */
106
+ setStorageBuffer(name: string, buffer: StorageBuffer | DataBuffer): void;
107
+ /**
108
+ * Binds a texture sampler to the shader
109
+ * @param name Binding name of the sampler
110
+ * @param sampler Sampler to bind
111
+ */
112
+ setTextureSampler(name: string, sampler: TextureSampler): void;
113
+ record(skipCreationOfDisabledPasses?: boolean): FrameGraphPass<FrameGraphContext>;
114
+ dispose(): void;
115
+ }
@@ -0,0 +1,174 @@
1
+ import { FrameGraphTask } from "../../frameGraphTask.js";
2
+ import { ComputeShader } from "../../../Compute/computeShader.js";
3
+ import { Vector3 } from "../../../Maths/math.vector.js";
4
+ import { UniformBuffer } from "../../../Materials/uniformBuffer.js";
5
+ import { Logger } from "../../../Misc/logger.js";
6
+ /**
7
+ * Task used to execute a compute shader (WebGPU only)
8
+ */
9
+ export class FrameGraphComputeShaderTask extends FrameGraphTask {
10
+ /**
11
+ * Gets the compute shader used by the task
12
+ */
13
+ get computeShader() {
14
+ return this._cs;
15
+ }
16
+ /**
17
+ * Gets a uniform buffer created by a call to createUniformBuffer()
18
+ * @param name Name of the uniform buffer
19
+ * @returns The uniform buffer
20
+ */
21
+ getUniformBuffer(name) {
22
+ return this._ubo[name]?.ubo;
23
+ }
24
+ /**
25
+ * Creates a new compute shader task.
26
+ * @param name The name of the task.
27
+ * @param frameGraph The frame graph the task belongs to.
28
+ * @param shaderPath Defines the route to the shader code in one of three ways:
29
+ * * object: \{ compute: "custom" \}, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
30
+ * * object: \{ computeElement: "HTMLElementId" \}, used with shader code in script tags
31
+ * * object: \{ computeSource: "compute shader code string" \}, where the string contains the shader code
32
+ * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
33
+ * @param options Define the options used to create the shader
34
+ */
35
+ constructor(name, frameGraph, shaderPath, options = {}) {
36
+ super(name, frameGraph);
37
+ /**
38
+ * Defines the dispatch size for the compute shader
39
+ */
40
+ this.dispatchSize = new Vector3(1, 1, 1);
41
+ if (!frameGraph.engine.getCaps().supportComputeShaders) {
42
+ this._notSupported = true;
43
+ Logger.Error("This engine does not support compute shaders!");
44
+ return;
45
+ }
46
+ this._notSupported = false;
47
+ this._cs = new ComputeShader(name + "_cs", frameGraph.engine, shaderPath, options);
48
+ this._ubo = {};
49
+ }
50
+ isReady() {
51
+ return this._notSupported ? true : this._cs.isReady();
52
+ }
53
+ /**
54
+ * Creates a uniform buffer and binds it to the shader
55
+ * @param name Name of the uniform buffer
56
+ * @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms
57
+ * @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)
58
+ * @returns The created uniform buffer
59
+ */
60
+ createUniformBuffer(name, description, autoUpdate = true) {
61
+ const uBuffer = new UniformBuffer(this._frameGraph.engine);
62
+ this._ubo[name] = { ubo: uBuffer, autoUpdate };
63
+ for (const key in description) {
64
+ uBuffer.addUniform(key, description[key]);
65
+ }
66
+ this._cs.setUniformBuffer(name, uBuffer);
67
+ return uBuffer;
68
+ }
69
+ /**
70
+ * Binds a texture to the shader
71
+ * @param name Binding name of the texture
72
+ * @param texture Texture to bind
73
+ * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture
74
+ */
75
+ setTexture(name, texture, bindSampler = true) {
76
+ this._cs.setTexture(name, texture, bindSampler);
77
+ }
78
+ /**
79
+ * Binds an internal texture to the shader
80
+ * @param name Binding name of the texture
81
+ * @param texture Texture to bind
82
+ */
83
+ setInternalTexture(name, texture) {
84
+ this._cs.setInternalTexture(name, texture);
85
+ }
86
+ /**
87
+ * Binds a storage texture to the shader
88
+ * @param name Binding name of the texture
89
+ * @param texture Texture to bind
90
+ */
91
+ setStorageTexture(name, texture) {
92
+ this._cs.setStorageTexture(name, texture);
93
+ }
94
+ /**
95
+ * Binds an external texture to the shader
96
+ * @param name Binding name of the texture
97
+ * @param texture Texture to bind
98
+ */
99
+ setExternalTexture(name, texture) {
100
+ this._cs.setExternalTexture(name, texture);
101
+ }
102
+ /**
103
+ * Binds a video texture to the shader (by binding the external texture attached to this video)
104
+ * @param name Binding name of the texture
105
+ * @param texture Texture to bind
106
+ * @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures
107
+ */
108
+ setVideoTexture(name, texture) {
109
+ return this._cs.setVideoTexture(name, texture);
110
+ }
111
+ /**
112
+ * Binds a uniform buffer to the shader
113
+ * @param name Binding name of the buffer
114
+ * @param buffer Buffer to bind
115
+ */
116
+ setUniformBuffer(name, buffer) {
117
+ this._cs.setUniformBuffer(name, buffer);
118
+ }
119
+ /**
120
+ * Binds a storage buffer to the shader
121
+ * @param name Binding name of the buffer
122
+ * @param buffer Buffer to bind
123
+ */
124
+ setStorageBuffer(name, buffer) {
125
+ this._cs.setStorageBuffer(name, buffer);
126
+ }
127
+ /**
128
+ * Binds a texture sampler to the shader
129
+ * @param name Binding name of the sampler
130
+ * @param sampler Sampler to bind
131
+ */
132
+ setTextureSampler(name, sampler) {
133
+ this._cs.setTextureSampler(name, sampler);
134
+ }
135
+ record(skipCreationOfDisabledPasses) {
136
+ const pass = this._frameGraph.addPass(this.name);
137
+ if (this._notSupported) {
138
+ pass.setExecuteFunc(() => { });
139
+ }
140
+ else {
141
+ pass.setExecuteFunc((context) => {
142
+ this.execute?.(context);
143
+ for (const key in this._ubo) {
144
+ const uboEntry = this._ubo[key];
145
+ if (uboEntry.autoUpdate) {
146
+ uboEntry.ubo.update();
147
+ }
148
+ }
149
+ if (this.indirectDispatch) {
150
+ context.pushDebugGroup(`Indirect dispatch compute shader (${this.name})`);
151
+ this._cs.dispatchIndirect(this.indirectDispatch.buffer, this.indirectDispatch.offset);
152
+ context.popDebugGroup();
153
+ }
154
+ else {
155
+ context.pushDebugGroup(`Dispatch compute shader (${this.name})`);
156
+ this._cs.dispatch(this.dispatchSize.x, this.dispatchSize.y, this.dispatchSize.z);
157
+ context.popDebugGroup();
158
+ }
159
+ });
160
+ }
161
+ if (!skipCreationOfDisabledPasses) {
162
+ const passDisabled = this._frameGraph.addPass(this.name + "_disabled", true);
163
+ passDisabled.setExecuteFunc(() => { });
164
+ }
165
+ return pass;
166
+ }
167
+ dispose() {
168
+ for (const key in this._ubo) {
169
+ this._ubo[key].ubo.dispose();
170
+ }
171
+ super.dispose();
172
+ }
173
+ }
174
+ //# sourceMappingURL=computeShaderTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeShaderTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/computeShaderTask.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,0CAAmC;AAC3D,OAAO,EAAE,OAAO,EAAE,sCAA+B;AACjD,OAAO,EAAE,aAAa,EAAE,4CAAqC;AAC7D,OAAO,EAAE,MAAM,EAAE,gCAAyB;AAE1C;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,cAAc;IAsB3D;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAChC,CAAC;IAED;;;;;;;;;;OAUG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,UAAuC,EAAE,UAA0C,EAAE;QACnI,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QA7C5B;;WAEG;QACI,iBAAY,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QA4CvC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,qBAAqB,EAAE,CAAC;YACrD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC1B,MA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C1B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n BaseTexture,\r\n DataBuffer,\r\n ExternalTexture,\r\n FrameGraph,\r\n FrameGraphContext,\r\n FrameGraphPass,\r\n IComputeShaderOptions,\r\n IComputeShaderPath,\r\n InternalTexture,\r\n StorageBuffer,\r\n TextureSampler,\r\n VideoTexture,\r\n} from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ComputeShader } from \"core/Compute/computeShader\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Task used to execute a compute shader (WebGPU only)\r\n */\r\nexport class FrameGraphComputeShaderTask extends FrameGraphTask {\r\n private readonly _notSupported: boolean;\r\n private readonly _cs: ComputeShader;\r\n private readonly _ubo: { [name: string]: { ubo: UniformBuffer; autoUpdate: boolean } };\r\n\r\n /**\r\n * Defines the dispatch size for the compute shader\r\n */\r\n public dispatchSize = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * Defines an indirect dispatch buffer and offset.\r\n * If set, this will be used instead of the dispatchSize property and an indirect dispatch will be performed.\r\n * \"offset\" is the offset in the buffer where the workgroup counts are stored (default: 0)\r\n */\r\n public indirectDispatch?: { buffer: StorageBuffer | DataBuffer; offset?: number };\r\n\r\n /**\r\n * An optional execute function that will be called at the beginning of the task execution\r\n */\r\n public execute?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Gets the compute shader used by the task\r\n */\r\n public get computeShader(): ComputeShader {\r\n return this._cs;\r\n }\r\n\r\n /**\r\n * Gets a uniform buffer created by a call to createUniformBuffer()\r\n * @param name Name of the uniform buffer\r\n * @returns The uniform buffer\r\n */\r\n public getUniformBuffer(name: string): UniformBuffer {\r\n return this._ubo[name]?.ubo;\r\n }\r\n\r\n /**\r\n * Creates a new compute shader task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param shaderPath Defines the route to the shader code in one of three ways:\r\n * * object: \\{ compute: \"custom\" \\}, used with ShaderStore.ShadersStoreWGSL[\"customComputeShader\"]\r\n * * object: \\{ computeElement: \"HTMLElementId\" \\}, used with shader code in script tags\r\n * * object: \\{ computeSource: \"compute shader code string\" \\}, where the string contains the shader code\r\n * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + \"ComputeShader\"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.\r\n * @param options Define the options used to create the shader\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, shaderPath: IComputeShaderPath | string, options: Partial<IComputeShaderOptions> = {}) {\r\n super(name, frameGraph);\r\n\r\n if (!frameGraph.engine.getCaps().supportComputeShaders) {\r\n this._notSupported = true;\r\n Logger.Error(\"This engine does not support compute shaders!\");\r\n return;\r\n }\r\n\r\n this._notSupported = false;\r\n this._cs = new ComputeShader(name + \"_cs\", frameGraph.engine, shaderPath, options);\r\n this._ubo = {};\r\n }\r\n\r\n public override isReady(): boolean {\r\n return this._notSupported ? true : this._cs.isReady();\r\n }\r\n\r\n /**\r\n * Creates a uniform buffer and binds it to the shader\r\n * @param name Name of the uniform buffer\r\n * @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms\r\n * @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)\r\n * @returns The created uniform buffer\r\n */\r\n public createUniformBuffer(name: string, description: { [name: string]: number }, autoUpdate = true): UniformBuffer {\r\n const uBuffer = new UniformBuffer(this._frameGraph.engine);\r\n\r\n this._ubo[name] = { ubo: uBuffer, autoUpdate };\r\n\r\n for (const key in description) {\r\n uBuffer.addUniform(key, description[key]);\r\n }\r\n\r\n this._cs.setUniformBuffer(name, uBuffer);\r\n\r\n return uBuffer;\r\n }\r\n\r\n /**\r\n * Binds a texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture\r\n */\r\n public setTexture(name: string, texture: BaseTexture, bindSampler = true): void {\r\n this._cs.setTexture(name, texture, bindSampler);\r\n }\r\n\r\n /**\r\n * Binds an internal texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setInternalTexture(name: string, texture: InternalTexture): void {\r\n this._cs.setInternalTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a storage texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setStorageTexture(name: string, texture: BaseTexture): void {\r\n this._cs.setStorageTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds an external texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setExternalTexture(name: string, texture: ExternalTexture): void {\r\n this._cs.setExternalTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a video texture to the shader (by binding the external texture attached to this video)\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n * @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures\r\n */\r\n public setVideoTexture(name: string, texture: VideoTexture) {\r\n return this._cs.setVideoTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a uniform buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setUniformBuffer(name: string, buffer: UniformBuffer | DataBuffer): void {\r\n this._cs.setUniformBuffer(name, buffer);\r\n }\r\n\r\n /**\r\n * Binds a storage buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setStorageBuffer(name: string, buffer: StorageBuffer | DataBuffer): void {\r\n this._cs.setStorageBuffer(name, buffer);\r\n }\r\n\r\n /**\r\n * Binds a texture sampler to the shader\r\n * @param name Binding name of the sampler\r\n * @param sampler Sampler to bind\r\n */\r\n public setTextureSampler(name: string, sampler: TextureSampler): void {\r\n this._cs.setTextureSampler(name, sampler);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses?: boolean): FrameGraphPass<FrameGraphContext> {\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n if (this._notSupported) {\r\n pass.setExecuteFunc(() => {});\r\n } else {\r\n pass.setExecuteFunc((context) => {\r\n this.execute?.(context);\r\n\r\n for (const key in this._ubo) {\r\n const uboEntry = this._ubo[key];\r\n if (uboEntry.autoUpdate) {\r\n uboEntry.ubo.update();\r\n }\r\n }\r\n\r\n if (this.indirectDispatch) {\r\n context.pushDebugGroup(`Indirect dispatch compute shader (${this.name})`);\r\n this._cs.dispatchIndirect(this.indirectDispatch.buffer, this.indirectDispatch.offset);\r\n context.popDebugGroup();\r\n } else {\r\n context.pushDebugGroup(`Dispatch compute shader (${this.name})`);\r\n this._cs.dispatch(this.dispatchSize.x, this.dispatchSize.y, this.dispatchSize.z);\r\n context.popDebugGroup();\r\n }\r\n });\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc(() => {});\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n for (const key in this._ubo) {\r\n this._ubo[key].ubo.dispose();\r\n }\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -12,6 +12,11 @@ export declare class FrameGraphExecuteTask extends FrameGraphTask {
12
12
  * The function to execute when the task is disabled (optional).
13
13
  */
14
14
  funcDisabled?: (context: FrameGraphContext) => void;
15
+ /**
16
+ * Custom readiness check (optional).
17
+ */
18
+ customIsReady?: () => boolean;
19
+ isReady(): boolean;
15
20
  /**
16
21
  * Creates a new execute task.
17
22
  * @param name The name of the task.
@@ -3,6 +3,9 @@ import { FrameGraphTask } from "../../frameGraphTask.js";
3
3
  * Task used to execute a custom function.
4
4
  */
5
5
  export class FrameGraphExecuteTask extends FrameGraphTask {
6
+ isReady() {
7
+ return !this.customIsReady || this.customIsReady();
8
+ }
6
9
  /**
7
10
  * Creates a new execute task.
8
11
  * @param name The name of the task.
@@ -1 +1 @@
1
- {"version":3,"file":"executeTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/executeTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IAWrD;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphContext, FrameGraphPass } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to execute a custom function.\r\n */\r\nexport class FrameGraphExecuteTask extends FrameGraphTask {\r\n /**\r\n * The function to execute.\r\n */\r\n public func: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * The function to execute when the task is disabled (optional).\r\n */\r\n public funcDisabled?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Creates a new execute 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\r\n public record(): FrameGraphPass<FrameGraphContext> {\r\n if (!this.func) {\r\n throw new Error(\"FrameGraphExecuteTask: Execute task must have a function.\");\r\n }\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this.func(context);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((context) => {\r\n this.funcDisabled?.(context);\r\n });\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"executeTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/executeTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IAgBrC,OAAO;QACnB,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphContext, FrameGraphPass } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to execute a custom function.\r\n */\r\nexport class FrameGraphExecuteTask extends FrameGraphTask {\r\n /**\r\n * The function to execute.\r\n */\r\n public func: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * The function to execute when the task is disabled (optional).\r\n */\r\n public funcDisabled?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Custom readiness check (optional).\r\n */\r\n public customIsReady?: () => boolean;\r\n\r\n public override isReady(): boolean {\r\n return !this.customIsReady || this.customIsReady();\r\n }\r\n\r\n /**\r\n * Creates a new execute 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\r\n public record(): FrameGraphPass<FrameGraphContext> {\r\n if (!this.func) {\r\n throw new Error(\"FrameGraphExecuteTask: Execute task must have a function.\");\r\n }\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this.func(context);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((context) => {\r\n this.funcDisabled?.(context);\r\n });\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
@@ -51,7 +51,7 @@ export declare class FrameGraphBloomTask extends FrameGraphTask {
51
51
  * @param hdr Whether the bloom effect is HDR.
52
52
  * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.
53
53
  */
54
- constructor(name: string, frameGraph: FrameGraph, weight: number, kernel: number, threshold: number, hdr?: boolean, bloomScale?: number);
54
+ constructor(name: string, frameGraph: FrameGraph, weight?: number, kernel?: number, threshold?: number, hdr?: boolean, bloomScale?: number);
55
55
  isReady(): boolean;
56
56
  record(): void;
57
57
  dispose(): void;
@@ -39,7 +39,7 @@ export class FrameGraphBloomTask extends FrameGraphTask {
39
39
  * @param hdr Whether the bloom effect is HDR.
40
40
  * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.
41
41
  */
42
- constructor(name, frameGraph, weight, kernel, threshold, hdr = false, bloomScale = 0.5) {
42
+ constructor(name, frameGraph, weight = 0.25, kernel = 64, threshold = 0.2, hdr = false, bloomScale = 0.5) {
43
43
  super(name, frameGraph);
44
44
  /**
45
45
  * The sampling mode to use for the source texture.
@@ -1 +1 @@
1
- {"version":3,"file":"bloomTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/bloomTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,kDAA2C;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IAiCnD;;OAEG;IACH,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,I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W,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureCreationOptions, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphBloomMergeTask } from \"./bloomMergeTask\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ThinBloomEffect } from \"core/PostProcesses/thinBloomEffect\";\r\nimport { FrameGraphExtractHighlightsTask } from \"./extractHighlightsTask\";\r\nimport { FrameGraphBlurTask } from \"./blurTask\";\r\n\r\n/**\r\n * Task which applies a bloom render effect.\r\n */\r\nexport class FrameGraphBloomTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the bloom effect on.\r\n */\r\n public sourceTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the bloom effect to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the bloom effect.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The bloom effect to apply.\r\n */\r\n public readonly bloom: ThinBloomEffect;\r\n\r\n /**\r\n * Whether the bloom effect is HDR.\r\n * When true, the bloom effect will use a higher precision texture format (half float or float). Else, it will use unsigned byte.\r\n */\r\n public readonly hdr: boolean;\r\n\r\n /**\r\n * The name of the task.\r\n */\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(name: string) {\r\n this._name = name;\r\n if (this._downscale) {\r\n this._downscale.name = `${name} Downscale`;\r\n }\r\n\r\n if (this._blurX) {\r\n this._blurX.name = `${name} Blur X`;\r\n }\r\n\r\n if (this._blurY) {\r\n this._blurY.name = `${name} Blur Y`;\r\n }\r\n\r\n if (this._merge) {\r\n this._merge.name = `${name} Merge`;\r\n }\r\n }\r\n\r\n private readonly _downscale: FrameGraphExtractHighlightsTask;\r\n private readonly _blurX: FrameGraphBlurTask;\r\n private readonly _blurY: FrameGraphBlurTask;\r\n private readonly _merge: FrameGraphBloomMergeTask;\r\n private readonly _defaultPipelineTextureType: number;\r\n\r\n /**\r\n * Constructs a new bloom task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param weight Weight of the bloom effect.\r\n * @param kernel Kernel size of the bloom effect.\r\n * @param threshold Threshold of the bloom effect.\r\n * @param hdr Whether the bloom effect is HDR.\r\n * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, weight: number, kernel: number, threshold: number, hdr = false, bloomScale = 0.5) {\r\n super(name, frameGraph);\r\n\r\n this.hdr = hdr;\r\n\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (hdr) {\r\n const caps = frameGraph.engine.getCaps();\r\n if (caps.textureHalfFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (caps.textureFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n }\r\n\r\n this.bloom = new ThinBloomEffect(name, frameGraph.engine, bloomScale);\r\n this.bloom.threshold = threshold;\r\n this.bloom.kernel = kernel;\r\n this.bloom.weight = weight;\r\n\r\n this._downscale = new FrameGraphExtractHighlightsTask(`${name} Downscale`, this._frameGraph, this.bloom._downscale);\r\n this._blurX = new FrameGraphBlurTask(`${name} Blur X`, this._frameGraph, this.bloom._blurX);\r\n this._blurY = new FrameGraphBlurTask(`${name} Blur Y`, this._frameGraph, this.bloom._blurY);\r\n this._merge = new FrameGraphBloomMergeTask(`${name} Merge`, this._frameGraph, this.bloom._merge);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.bloom.isReady();\r\n }\r\n\r\n public record(): void {\r\n if (this.sourceTexture === undefined) {\r\n throw new Error(\"FrameGraphBloomTask: sourceTexture is required\");\r\n }\r\n\r\n const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: {\r\n width: Math.floor(sourceTextureDescription.size.width * this.bloom.scale) || 1,\r\n height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale) || 1,\r\n },\r\n options: {\r\n createMipMaps: false,\r\n types: [this._defaultPipelineTextureType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n };\r\n\r\n const downscaleTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._downscale.name, textureCreationOptions);\r\n\r\n this._downscale.sourceTexture = this.sourceTexture;\r\n this._downscale.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._downscale.targetTexture = downscaleTextureHandle;\r\n this._downscale.record(true);\r\n\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX.name, textureCreationOptions);\r\n\r\n this._blurX.sourceTexture = downscaleTextureHandle;\r\n this._blurX.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX.targetTexture = blurXTextureHandle;\r\n this._blurX.record(true);\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY.name, textureCreationOptions);\r\n\r\n this._blurY.sourceTexture = blurXTextureHandle;\r\n this._blurY.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY.targetTexture = blurYTextureHandle;\r\n this._blurY.record(true);\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this._merge.name, sourceTextureCreationOptions);\r\n\r\n this._merge.sourceTexture = this.sourceTexture;\r\n this._merge.sourceSamplingMode = this.sourceSamplingMode;\r\n this._merge.blurTexture = blurYTextureHandle;\r\n this._merge.targetTexture = this.outputTexture;\r\n this._merge.record(true);\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n this._downscale.dispose();\r\n this._blurX.dispose();\r\n this._blurY.dispose();\r\n this._merge.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"bloomTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/bloomTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAA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QAC/C,IAAI,CAAC,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACzD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzB,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;QAEjD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureCreationOptions, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphBloomMergeTask } from \"./bloomMergeTask\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ThinBloomEffect } from \"core/PostProcesses/thinBloomEffect\";\r\nimport { FrameGraphExtractHighlightsTask } from \"./extractHighlightsTask\";\r\nimport { FrameGraphBlurTask } from \"./blurTask\";\r\n\r\n/**\r\n * Task which applies a bloom render effect.\r\n */\r\nexport class FrameGraphBloomTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the bloom effect on.\r\n */\r\n public sourceTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the bloom effect to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the bloom effect.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The bloom effect to apply.\r\n */\r\n public readonly bloom: ThinBloomEffect;\r\n\r\n /**\r\n * Whether the bloom effect is HDR.\r\n * When true, the bloom effect will use a higher precision texture format (half float or float). Else, it will use unsigned byte.\r\n */\r\n public readonly hdr: boolean;\r\n\r\n /**\r\n * The name of the task.\r\n */\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(name: string) {\r\n this._name = name;\r\n if (this._downscale) {\r\n this._downscale.name = `${name} Downscale`;\r\n }\r\n\r\n if (this._blurX) {\r\n this._blurX.name = `${name} Blur X`;\r\n }\r\n\r\n if (this._blurY) {\r\n this._blurY.name = `${name} Blur Y`;\r\n }\r\n\r\n if (this._merge) {\r\n this._merge.name = `${name} Merge`;\r\n }\r\n }\r\n\r\n private readonly _downscale: FrameGraphExtractHighlightsTask;\r\n private readonly _blurX: FrameGraphBlurTask;\r\n private readonly _blurY: FrameGraphBlurTask;\r\n private readonly _merge: FrameGraphBloomMergeTask;\r\n private readonly _defaultPipelineTextureType: number;\r\n\r\n /**\r\n * Constructs a new bloom task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param weight Weight of the bloom effect.\r\n * @param kernel Kernel size of the bloom effect.\r\n * @param threshold Threshold of the bloom effect.\r\n * @param hdr Whether the bloom effect is HDR.\r\n * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, weight = 0.25, kernel = 64, threshold = 0.2, hdr = false, bloomScale = 0.5) {\r\n super(name, frameGraph);\r\n\r\n this.hdr = hdr;\r\n\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (hdr) {\r\n const caps = frameGraph.engine.getCaps();\r\n if (caps.textureHalfFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (caps.textureFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n }\r\n\r\n this.bloom = new ThinBloomEffect(name, frameGraph.engine, bloomScale);\r\n this.bloom.threshold = threshold;\r\n this.bloom.kernel = kernel;\r\n this.bloom.weight = weight;\r\n\r\n this._downscale = new FrameGraphExtractHighlightsTask(`${name} Downscale`, this._frameGraph, this.bloom._downscale);\r\n this._blurX = new FrameGraphBlurTask(`${name} Blur X`, this._frameGraph, this.bloom._blurX);\r\n this._blurY = new FrameGraphBlurTask(`${name} Blur Y`, this._frameGraph, this.bloom._blurY);\r\n this._merge = new FrameGraphBloomMergeTask(`${name} Merge`, this._frameGraph, this.bloom._merge);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.bloom.isReady();\r\n }\r\n\r\n public record(): void {\r\n if (this.sourceTexture === undefined) {\r\n throw new Error(\"FrameGraphBloomTask: sourceTexture is required\");\r\n }\r\n\r\n const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: {\r\n width: Math.floor(sourceTextureDescription.size.width * this.bloom.scale) || 1,\r\n height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale) || 1,\r\n },\r\n options: {\r\n createMipMaps: false,\r\n types: [this._defaultPipelineTextureType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n };\r\n\r\n const downscaleTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._downscale.name, textureCreationOptions);\r\n\r\n this._downscale.sourceTexture = this.sourceTexture;\r\n this._downscale.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._downscale.targetTexture = downscaleTextureHandle;\r\n this._downscale.record(true);\r\n\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX.name, textureCreationOptions);\r\n\r\n this._blurX.sourceTexture = downscaleTextureHandle;\r\n this._blurX.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX.targetTexture = blurXTextureHandle;\r\n this._blurX.record(true);\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY.name, textureCreationOptions);\r\n\r\n this._blurY.sourceTexture = blurXTextureHandle;\r\n this._blurY.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY.targetTexture = blurYTextureHandle;\r\n this._blurY.record(true);\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this._merge.name, sourceTextureCreationOptions);\r\n\r\n this._merge.sourceTexture = this.sourceTexture;\r\n this._merge.sourceSamplingMode = this.sourceSamplingMode;\r\n this._merge.blurTexture = blurYTextureHandle;\r\n this._merge.targetTexture = this.outputTexture;\r\n this._merge.record(true);\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n this._downscale.dispose();\r\n this._blurX.dispose();\r\n this._blurY.dispose();\r\n this._merge.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -121,7 +121,7 @@ export declare class FrameGraph implements IDisposable {
121
121
  * Returns a promise that resolves when the frame graph is ready to be executed
122
122
  * This method must be called after the graph has been built (FrameGraph.build called)!
123
123
  * @param timeStep Time step in ms between retries (default is 16)
124
- * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 30000)
124
+ * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 5000)
125
125
  * @returns The promise that resolves when the graph is ready
126
126
  */
127
127
  whenReadyAsync(timeStep?: number, maxTimeout?: number): Promise<void>;
@@ -198,10 +198,10 @@ export class FrameGraph {
198
198
  * Returns a promise that resolves when the frame graph is ready to be executed
199
199
  * This method must be called after the graph has been built (FrameGraph.build called)!
200
200
  * @param timeStep Time step in ms between retries (default is 16)
201
- * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 30000)
201
+ * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 5000)
202
202
  * @returns The promise that resolves when the graph is ready
203
203
  */
204
- async whenReadyAsync(timeStep = 16, maxTimeout = 30000) {
204
+ async whenReadyAsync(timeStep = 16, maxTimeout = 5000) {
205
205
  let firstNotReadyTask = null;
206
206
  return await new Promise((resolve) => {
207
207
  this._whenReadyAsyncCancel = _RetryWithInterval(() => {
@@ -247,10 +247,7 @@ export class FrameGraph {
247
247
  this._renderContext.bindRenderTarget();
248
248
  this.textureManager._updateHistoryTextures();
249
249
  for (const task of this._tasks) {
250
- const passes = task._getPasses();
251
- for (const pass of passes) {
252
- pass._execute();
253
- }
250
+ task._execute();
254
251
  }
255
252
  this._renderContext.bindRenderTarget(undefined, undefined, true); // restore default framebuffer
256
253
  }
@@ -1 +1 @@
1
- {"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"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I,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 { 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\nimport { UniqueIdGenerator } from \"core/Misc/uniqueIdGenerator\";\r\n\r\nimport \"core/Engines/Extensions/engine.multiRender\";\r\nimport \"core/Engines/WebGPU/Extensions/engine.multiRender\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n 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 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 _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\r\n\r\n /**\r\n * Name of the frame graph\r\n */\r\n public name = \"Frame Graph\";\r\n\r\n /**\r\n * Gets the unique id of the frame graph\r\n */\r\n public readonly uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)\r\n */\r\n public optimizeTextureAllocation = true;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the scene used by the frame graph\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the list of tasks in the frame graph\r\n */\r\n public get tasks() {\r\n return this._tasks;\r\n }\r\n\r\n /**\r\n * Indicates whether the execution of the frame graph is paused (default is false)\r\n */\r\n public pausedExecution = false;\r\n\r\n /**\r\n * Gets the node render graph linked to the frame graph (if any)\r\n * @returns the linked node render graph or null if none\r\n */\r\n public getLinkedNodeRenderGraph(): Nullable<NodeRenderGraph> {\r\n return this._linkedNodeRenderGraph;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param scene defines the scene the frame graph is associated with\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector (default is false)\r\n * @param _linkedNodeRenderGraph defines the linked node render graph (if any)\r\n */\r\n constructor(\r\n scene: Scene,\r\n debugTextures = false,\r\n private readonly _linkedNodeRenderGraph: Nullable<NodeRenderGraph> = null\r\n ) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n\r\n this._scene.addFrameGraph(this);\r\n }\r\n\r\n /**\r\n * Gets the class name of the frame graph\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FrameGraph\";\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Gets all tasks of a specific type\r\n * @param taskType Type of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[] {\r\n return this._tasks.filter((t) => t instanceof taskType) as T[];\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\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 async whenReadyAsync(timeStep = 16, maxTimeout = 30000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n return await 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 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 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 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,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;AAC3D,OAAO,EAAE,MAAM,EAAE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, FrameGraphTask, Nullable, NodeRenderGraph, IDisposable } 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\nimport { UniqueIdGenerator } from \"core/Misc/uniqueIdGenerator\";\r\n\r\nimport \"core/Engines/Extensions/engine.multiRender\";\r\nimport \"core/Engines/WebGPU/Extensions/engine.multiRender\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n 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 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 _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\r\n\r\n /**\r\n * Name of the frame graph\r\n */\r\n public name = \"Frame Graph\";\r\n\r\n /**\r\n * Gets the unique id of the frame graph\r\n */\r\n public readonly uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)\r\n */\r\n public optimizeTextureAllocation = true;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the scene used by the frame graph\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the list of tasks in the frame graph\r\n */\r\n public get tasks() {\r\n return this._tasks;\r\n }\r\n\r\n /**\r\n * Indicates whether the execution of the frame graph is paused (default is false)\r\n */\r\n public pausedExecution = false;\r\n\r\n /**\r\n * Gets the node render graph linked to the frame graph (if any)\r\n * @returns the linked node render graph or null if none\r\n */\r\n public getLinkedNodeRenderGraph(): Nullable<NodeRenderGraph> {\r\n return this._linkedNodeRenderGraph;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param scene defines the scene the frame graph is associated with\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector (default is false)\r\n * @param _linkedNodeRenderGraph defines the linked node render graph (if any)\r\n */\r\n constructor(\r\n scene: Scene,\r\n debugTextures = false,\r\n private readonly _linkedNodeRenderGraph: Nullable<NodeRenderGraph> = null\r\n ) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n\r\n this._scene.addFrameGraph(this);\r\n }\r\n\r\n /**\r\n * Gets the class name of the frame graph\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FrameGraph\";\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Gets all tasks of a specific type\r\n * @param taskType Type of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[] {\r\n return this._tasks.filter((t) => t instanceof taskType) as T[];\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\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 5000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 5000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n return await 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 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"]}
@@ -34,8 +34,9 @@ export declare abstract class FrameGraphTask {
34
34
  dependencies?: Set<FrameGraphTextureHandle>;
35
35
  /**
36
36
  * Records the task in the frame graph. Use this function to add content (render passes, ...) to the task.
37
+ * @param skipCreationOfDisabledPasses If true, the disabled passe(s) won't be created.
37
38
  */
38
- abstract record(): void;
39
+ abstract record(skipCreationOfDisabledPasses?: boolean): void;
39
40
  /**
40
41
  * An observable that is triggered after the textures have been allocated.
41
42
  */
@@ -62,6 +63,6 @@ export declare abstract class FrameGraphTask {
62
63
  /** @internal */
63
64
  _checkTask(): void;
64
65
  /** @internal */
65
- _getPasses(): IFrameGraphPass[];
66
+ _execute(): void;
66
67
  private _checkSameRenderTarget;
67
68
  }
@@ -151,8 +151,11 @@ export class FrameGraphTask {
151
151
  }
152
152
  }
153
153
  /** @internal */
154
- _getPasses() {
155
- return this.disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;
154
+ _execute() {
155
+ const passes = this._disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;
156
+ for (const pass of passes) {
157
+ pass._execute();
158
+ }
156
159
  }
157
160
  _checkSameRenderTarget(src, dst) {
158
161
  if (src === null || dst === null) {