@onerjs/core 8.27.2 → 8.27.4
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.
- package/Cameras/arcRotateCamera.js +7 -5
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/targetCamera.d.ts +12 -0
- package/Cameras/targetCamera.js +19 -5
- package/Cameras/targetCamera.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +7 -5
- package/Decorators/nodeDecorator.js +7 -5
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +22 -22
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js +8 -8
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/renderPass.js +3 -3
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +7 -7
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +4 -0
- package/FrameGraph/frameGraph.js +8 -0
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
- package/FrameGraph/frameGraphRenderContext.js +10 -3
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +32 -2
- package/FrameGraph/frameGraphTextureManager.js +139 -9
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +1 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +4 -4
- package/Materials/Node/Blocks/conditionalBlock.js +1 -1
- package/Materials/Node/Blocks/curveBlock.js +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js +1 -1
- package/Materials/Node/Blocks/waveBlock.js +1 -1
- package/Materials/PBR/openPbrMaterial.d.ts +2 -0
- package/Materials/PBR/openPbrMaterial.js +3 -1
- package/Materials/PBR/openPbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +2 -0
- package/Materials/PBR/pbrBaseMaterial.js +3 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/texture.js +13 -3
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +11 -6
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +3 -3
- package/Materials/materialHelper.functions.js +3 -3
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -0
- package/Materials/standardMaterial.js +3 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +17 -0
- package/Maths/math.vector.functions.js +27 -0
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/Node/Blocks/Set/aggregatorBlock.js +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -1
- package/Meshes/Node/Blocks/conditionBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryCurveBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryEaseBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +1 -1
- package/Meshes/Node/Blocks/mappingBlock.js +1 -1
- package/Meshes/Node/Blocks/mathBlock.js +1 -1
- package/Meshes/Node/Blocks/randomBlock.js +1 -1
- package/Meshes/abstractMesh.d.ts +4 -0
- package/Meshes/abstractMesh.js +7 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/screenshotTools.d.ts +63 -1
- package/Misc/screenshotTools.js +207 -4
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/textureTools.d.ts +6 -0
- package/Misc/textureTools.js +6 -1
- package/Misc/textureTools.js.map +1 -1
- package/Particles/Node/Blocks/Conditions/particleConditionBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleFresnelBlock.d.ts +34 -0
- package/Particles/Node/Blocks/particleFresnelBlock.js +74 -0
- package/Particles/Node/Blocks/particleFresnelBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleLerpBlock.d.ts +1 -1
- package/Particles/Node/Blocks/particleLerpBlock.js +1 -1
- package/Particles/Node/Blocks/particleLerpBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleLocalVariableBlock.js +1 -1
- package/Particles/Node/Blocks/particleMathBlock.js +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.js +1 -1
- package/Particles/Node/Blocks/particleTrigonometryBlock.js +1 -1
- package/Particles/Node/Blocks/systemBlock.js +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleSystemSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleSystemSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleSystemSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +1 -1
- package/Particles/Node/nodeParticleBuildState.js +4 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/gpuParticleSystem.js +1 -0
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +1 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +1 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +2 -2
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +2 -2
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/node.js +4 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,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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ACb,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QAEvC,IAAI,CAAC,cAAc,CAAC,sBAAsB,EAAE,CAAC;QAE7C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAEjC,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;gBACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAElC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene, AbstractEngine, FrameGraphTask, Nullable, NodeRenderGraph, IDisposable } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { 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 * 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 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 this._scene.removeFrameGraph(this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts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AI,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"]}
|
|
@@ -121,8 +121,9 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
121
121
|
* this method several times with different render targets without incurring the cost of binding if no draw calls are made
|
|
122
122
|
* @param renderTarget The handle of the render target texture to bind (default: undefined, meaning "back buffer"). Pass an array for MRT rendering.
|
|
123
123
|
* @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)
|
|
124
|
+
* @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).
|
|
124
125
|
*/
|
|
125
|
-
bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string): void;
|
|
126
|
+
bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string, applyImmediately?: boolean): void;
|
|
126
127
|
/** @internal */
|
|
127
128
|
_flushDebugMessages(): void;
|
|
128
129
|
/** @internal */
|
|
@@ -28,7 +28,7 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
28
28
|
* @returns True if the handle points to the backbuffer's color or depth texture, otherwise false
|
|
29
29
|
*/
|
|
30
30
|
isBackbuffer(handle) {
|
|
31
|
-
return this._textureManager.
|
|
31
|
+
return this._textureManager._isBackbuffer(handle);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Checks whether a texture handle points to the backbuffer's color texture
|
|
@@ -204,7 +204,7 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
204
204
|
this.bindRenderTarget();
|
|
205
205
|
}
|
|
206
206
|
this._applyRenderTarget();
|
|
207
|
-
this._copyTexture.copy(this._textureManager.getTextureFromHandle(sourceTexture));
|
|
207
|
+
this._copyTexture.copy(this._textureManager.getTextureFromHandle(sourceTexture, true));
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
210
|
* Renders a RenderTargetTexture or a layer
|
|
@@ -237,8 +237,9 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
237
237
|
* this method several times with different render targets without incurring the cost of binding if no draw calls are made
|
|
238
238
|
* @param renderTarget The handle of the render target texture to bind (default: undefined, meaning "back buffer"). Pass an array for MRT rendering.
|
|
239
239
|
* @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)
|
|
240
|
+
* @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).
|
|
240
241
|
*/
|
|
241
|
-
bindRenderTarget(renderTarget, debugMessage) {
|
|
242
|
+
bindRenderTarget(renderTarget, debugMessage, applyImmediately = false) {
|
|
242
243
|
if ((renderTarget?.renderTargetWrapper === undefined && this._currentRenderTarget === undefined) ||
|
|
243
244
|
(renderTarget && this._currentRenderTarget && renderTarget.equals(this._currentRenderTarget))) {
|
|
244
245
|
this._flushDebugMessages();
|
|
@@ -247,11 +248,17 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
247
248
|
this._debugMessageWhenTargetBound = undefined;
|
|
248
249
|
this._debugMessageHasBeenPushed = true;
|
|
249
250
|
}
|
|
251
|
+
if (applyImmediately) {
|
|
252
|
+
this._applyRenderTarget();
|
|
253
|
+
}
|
|
250
254
|
return;
|
|
251
255
|
}
|
|
252
256
|
this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;
|
|
253
257
|
this._debugMessageWhenTargetBound = debugMessage;
|
|
254
258
|
this._renderTargetIsBound = false;
|
|
259
|
+
if (applyImmediately) {
|
|
260
|
+
this._applyRenderTarget();
|
|
261
|
+
}
|
|
255
262
|
}
|
|
256
263
|
/** @internal */
|
|
257
264
|
_flushDebugMessages() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraphRenderContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderContext.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,iBAAiB;IASlD,MAAM,CAAC,iBAAiB,CAAC,KAAoD;QACjF,OAAQ,KAAwB,CAAC,UAAU,KAAK,SAAS,CAAC;IAC9D,CAAC;IAED,gBAAgB;IAChB,YAAY,MAAsB,EAAE,cAAwC,EAAE,KAAY;QACtF,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;QAVjC,+BAA0B,GAAG,KAAK,CAAC;QACnC,yBAAoB,GAAG,IAAI,CAAC;QAUhC,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,mBAAmB,GAAG,IAAI,cAAc,CAAC,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AE,mBAAmB,CAAC;QAE3E,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBACpC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;YACtE,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,IAAI,CAAC,4BAA4B,KAAK,SAAS,EAAE,CAAC;YAClD,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,4BAA4B,GAAG,SAAS,CAAC;YAC9C,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACvC,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;CACJ","sourcesContent":["import type {\r\n Nullable,\r\n AbstractEngine,\r\n DrawWrapper,\r\n IColor4Like,\r\n Layer,\r\n FrameGraphTextureHandle,\r\n Effect,\r\n FrameGraphTextureManager,\r\n ObjectRenderer,\r\n Scene,\r\n FrameGraphRenderTarget,\r\n InternalTexture,\r\n UtilityLayerRenderer,\r\n IStencilState,\r\n} from \"core/index\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer } from \"../Materials/effectRenderer\";\r\nimport { CopyTextureToTexture } from \"../Misc/copyTextureToTexture\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\n\r\n/**\r\n * Frame graph context used render passes.\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderContext extends FrameGraphContext {\r\n private readonly _effectRenderer: EffectRenderer;\r\n private readonly _effectRendererBack: EffectRenderer;\r\n private _currentRenderTarget: FrameGraphRenderTarget | undefined;\r\n private _debugMessageWhenTargetBound: string | undefined;\r\n private _debugMessageHasBeenPushed = false;\r\n private _renderTargetIsBound = true;\r\n private readonly _copyTexture: CopyTextureToTexture;\r\n\r\n private static _IsObjectRenderer(value: Layer | ObjectRenderer | UtilityLayerRenderer): value is ObjectRenderer {\r\n return (value as ObjectRenderer).initRender !== undefined;\r\n }\r\n\r\n /** @internal */\r\n constructor(engine: AbstractEngine, textureManager: FrameGraphTextureManager, scene: Scene) {\r\n super(engine, textureManager, scene);\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._effectRendererBack = new EffectRenderer(this._engine, {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 2, 1, 0, 3, 2],\r\n });\r\n this._copyTexture = new CopyTextureToTexture(this._engine);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color or depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color or depth texture, otherwise false\r\n */\r\n public isBackbuffer(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbuffer(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color texture, otherwise false\r\n */\r\n public isBackbufferColor(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferColor(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's depth texture, otherwise false\r\n */\r\n public isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferDepthStencil(handle);\r\n }\r\n\r\n /**\r\n * Creates a (frame graph) render target wrapper\r\n * Note that renderTargets or renderTargetDepth can be undefined, but not both at the same time!\r\n * @param name Name of the render target wrapper\r\n * @param renderTargets Render target handles (textures) to use\r\n * @param renderTargetDepth Render target depth handle (texture) to use\r\n * @param depthReadOnly If true, the depth buffer will be read-only\r\n * @param stencilReadOnly If true, the stencil buffer will be read-only\r\n * @returns The created render target wrapper\r\n */\r\n public createRenderTarget(\r\n name: string,\r\n renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[],\r\n renderTargetDepth?: FrameGraphTextureHandle,\r\n depthReadOnly?: boolean,\r\n stencilReadOnly?: boolean\r\n ): FrameGraphRenderTarget {\r\n return this._textureManager.createRenderTarget(name, renderTargets, renderTargetDepth, depthReadOnly, stencilReadOnly);\r\n }\r\n\r\n /**\r\n * Clears the current render buffer or the current render target (if any is set up)\r\n * @param color Defines the color to use\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Clears the color attachments of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n */\r\n public clearColorAttachments(color: Nullable<IColor4Like>, attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, true, false, false);\r\n }\r\n\r\n /**\r\n * Clears all attachments (color(s) + depth/stencil) of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clearAttachments(color: Nullable<IColor4Like>, attachments: number[], backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Binds the attachments to the current render target\r\n * @param attachments The attachments to bind\r\n */\r\n public bindAttachments(attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n }\r\n\r\n /**\r\n * Generates mipmaps for the current render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._currentRenderTarget?.renderTargetWrapper === undefined) {\r\n return;\r\n }\r\n\r\n if (this._renderTargetIsBound && this._engine._currentRenderTarget) {\r\n // we can't generate the mipmaps if the render target is bound\r\n this._flushDebugMessages();\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n const textures = this._currentRenderTarget.renderTargetWrapper.textures;\r\n if (textures) {\r\n for (const texture of textures) {\r\n this._engine.generateMipmaps(texture);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the texture sampling mode for a given texture handle\r\n * @param handle Handle of the texture to set the sampling mode for\r\n * @param samplingMode Sampling mode to set\r\n */\r\n public setTextureSamplingMode(handle: FrameGraphTextureHandle, samplingMode: number): void {\r\n const internalTexture = this._textureManager.getTextureFromHandle(handle);\r\n if (internalTexture && internalTexture.samplingMode !== samplingMode) {\r\n this._engine.updateTextureSamplingMode(samplingMode, internalTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Binds a texture handle to a given effect (resolves the handle to a texture and binds it to the effect)\r\n * @param effect The effect to bind the texture to\r\n * @param name The name of the texture in the effect\r\n * @param handle The handle of the texture to bind\r\n */\r\n public bindTextureHandle(effect: Effect, name: string, handle: FrameGraphTextureHandle): void {\r\n let texture: Nullable<InternalTexture>;\r\n\r\n const historyEntry = this._textureManager._historyTextures.get(handle);\r\n if (historyEntry) {\r\n texture = historyEntry.textures[historyEntry.index]; // texture we write to in this frame\r\n if (\r\n this._currentRenderTarget !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper.textures!.includes(texture!)\r\n ) {\r\n // If the current render target renders to the history write texture, we bind the read texture instead\r\n texture = historyEntry.textures[historyEntry.index ^ 1];\r\n }\r\n } else {\r\n texture = this._textureManager._textures.get(handle)!.texture;\r\n }\r\n\r\n effect._bindTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Applies a full-screen effect to the current render target\r\n * @param drawWrapper The draw wrapper containing the effect to apply\r\n * @param customBindings The custom bindings to use when applying the effect (optional)\r\n * @param stencilState The stencil state to use when applying the effect (optional)\r\n * @param disableColorWrite If true, color write will be disabled when applying the effect (optional)\r\n * @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)\r\n * @param depthTest If true, depth testing will be enabled when applying the effect (default is false)\r\n * @returns True if the effect was applied, otherwise false (effect not ready)\r\n */\r\n public applyFullScreenEffect(\r\n drawWrapper: DrawWrapper,\r\n customBindings?: () => void,\r\n stencilState?: IStencilState,\r\n disableColorWrite?: boolean,\r\n drawBackFace?: boolean,\r\n depthTest?: boolean\r\n ): boolean {\r\n if (!drawWrapper.effect?.isReady()) {\r\n return false;\r\n }\r\n\r\n this._applyRenderTarget();\r\n\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n const effectRenderer = drawBackFace ? this._effectRendererBack : this._effectRenderer;\r\n\r\n effectRenderer.saveStates();\r\n effectRenderer.setViewport();\r\n\r\n this._engine.enableEffect(drawWrapper);\r\n this._engine.setState(false, undefined, undefined, undefined, undefined, stencilState);\r\n this._engine.setDepthBuffer(!!depthTest);\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(false);\r\n }\r\n this._engine.setDepthWrite(false);\r\n\r\n effectRenderer.bindBuffers(drawWrapper.effect);\r\n customBindings?.();\r\n effectRenderer.draw();\r\n effectRenderer.restoreStates();\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(true);\r\n }\r\n this._engine.setDepthWrite(engineDepthMask);\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Copies a texture to the current render target\r\n * @param sourceTexture The source texture to copy from\r\n * @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target\r\n */\r\n public copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer = false): void {\r\n if (forceCopyToBackbuffer) {\r\n this.bindRenderTarget();\r\n }\r\n this._applyRenderTarget();\r\n this._copyTexture.copy(this._textureManager.getTextureFromHandle(sourceTexture)!);\r\n }\r\n\r\n /**\r\n * Renders a RenderTargetTexture or a layer\r\n * @param object The RenderTargetTexture/Layer to render\r\n * @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n * @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n */\r\n public render(object: Layer | ObjectRenderer | UtilityLayerRenderer, viewportWidth?: number, viewportHeight?: number): void {\r\n if (FrameGraphRenderContext._IsObjectRenderer(object)) {\r\n this._scene._intermediateRendering = true;\r\n if (object.shouldRender()) {\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this._applyRenderTarget();\r\n\r\n object.prepareRenderList();\r\n\r\n object.initRender(viewportWidth!, viewportHeight!);\r\n\r\n object.render();\r\n\r\n object.finishRender();\r\n }\r\n this._scene._intermediateRendering = false;\r\n } else {\r\n this._applyRenderTarget();\r\n object.render();\r\n }\r\n }\r\n\r\n /**\r\n * Binds a render target texture so that upcoming draw calls will render to it\r\n * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call\r\n * this method several times with different render targets without incurring the cost of binding if no draw calls are made\r\n * @param renderTarget The handle of the render target texture to bind (default: undefined, meaning \"back buffer\"). Pass an array for MRT rendering.\r\n * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)\r\n */\r\n public bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string) {\r\n if (\r\n (renderTarget?.renderTargetWrapper === undefined && this._currentRenderTarget === undefined) ||\r\n (renderTarget && this._currentRenderTarget && renderTarget.equals(this._currentRenderTarget))\r\n ) {\r\n this._flushDebugMessages();\r\n if (debugMessage !== undefined) {\r\n this._engine._debugPushGroup?.(debugMessage, 2);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n return;\r\n }\r\n this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;\r\n this._debugMessageWhenTargetBound = debugMessage;\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n /** @internal */\r\n public _flushDebugMessages() {\r\n if (this._debugMessageHasBeenPushed) {\r\n this._engine._debugPopGroup?.(2);\r\n this._debugMessageHasBeenPushed = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _applyRenderTarget() {\r\n if (this._renderTargetIsBound) {\r\n return;\r\n }\r\n\r\n this._flushDebugMessages();\r\n\r\n const renderTargetWrapper = this._currentRenderTarget?.renderTargetWrapper;\r\n\r\n if (renderTargetWrapper === undefined) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n }\r\n this._engine.bindFramebuffer(renderTargetWrapper);\r\n }\r\n\r\n if (this._debugMessageWhenTargetBound !== undefined) {\r\n this._engine._debugPushGroup?.(this._debugMessageWhenTargetBound, 2);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n\r\n this._renderTargetIsBound = true;\r\n }\r\n\r\n /** @internal */\r\n public _isReady(): boolean {\r\n return this._copyTexture.isReady();\r\n }\r\n\r\n /** @internal */\r\n public _dispose() {\r\n this._effectRenderer.dispose();\r\n this._effectRendererBack.dispose();\r\n this._copyTexture.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraphRenderContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderContext.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,iBAAiB;IASlD,MAAM,CAAC,iBAAiB,CAAC,KAAoD;QACjF,OAAQ,KAAwB,CAAC,UAAU,KAAK,SAAS,CAAC;IAC9D,CAAC;IAED,gBAAgB;IAChB,YAAY,MAAsB,EAAE,cAAwC,EAAE,KAAY;QACtF,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;QAVjC,+BAA0B,GAAG,KAAK,CAAC;QACnC,yBAAoB,GAAG,IAAI,CAAC;QAUhC,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,mBAAmB,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE;YACxD,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACvC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,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S,EAAE,CAAC;YACpC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBACpC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;YACtE,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,IAAI,CAAC,4BAA4B,KAAK,SAAS,EAAE,CAAC;YAClD,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,4BAA4B,GAAG,SAAS,CAAC;YAC9C,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACvC,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;CACJ","sourcesContent":["import type {\r\n Nullable,\r\n AbstractEngine,\r\n DrawWrapper,\r\n IColor4Like,\r\n Layer,\r\n FrameGraphTextureHandle,\r\n Effect,\r\n FrameGraphTextureManager,\r\n ObjectRenderer,\r\n Scene,\r\n FrameGraphRenderTarget,\r\n InternalTexture,\r\n UtilityLayerRenderer,\r\n IStencilState,\r\n} from \"core/index\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer } from \"../Materials/effectRenderer\";\r\nimport { CopyTextureToTexture } from \"../Misc/copyTextureToTexture\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\n\r\n/**\r\n * Frame graph context used render passes.\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderContext extends FrameGraphContext {\r\n private readonly _effectRenderer: EffectRenderer;\r\n private readonly _effectRendererBack: EffectRenderer;\r\n private _currentRenderTarget: FrameGraphRenderTarget | undefined;\r\n private _debugMessageWhenTargetBound: string | undefined;\r\n private _debugMessageHasBeenPushed = false;\r\n private _renderTargetIsBound = true;\r\n private readonly _copyTexture: CopyTextureToTexture;\r\n\r\n private static _IsObjectRenderer(value: Layer | ObjectRenderer | UtilityLayerRenderer): value is ObjectRenderer {\r\n return (value as ObjectRenderer).initRender !== undefined;\r\n }\r\n\r\n /** @internal */\r\n constructor(engine: AbstractEngine, textureManager: FrameGraphTextureManager, scene: Scene) {\r\n super(engine, textureManager, scene);\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._effectRendererBack = new EffectRenderer(this._engine, {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 2, 1, 0, 3, 2],\r\n });\r\n this._copyTexture = new CopyTextureToTexture(this._engine);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color or depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color or depth texture, otherwise false\r\n */\r\n public isBackbuffer(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager._isBackbuffer(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color texture, otherwise false\r\n */\r\n public isBackbufferColor(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferColor(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's depth texture, otherwise false\r\n */\r\n public isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferDepthStencil(handle);\r\n }\r\n\r\n /**\r\n * Creates a (frame graph) render target wrapper\r\n * Note that renderTargets or renderTargetDepth can be undefined, but not both at the same time!\r\n * @param name Name of the render target wrapper\r\n * @param renderTargets Render target handles (textures) to use\r\n * @param renderTargetDepth Render target depth handle (texture) to use\r\n * @param depthReadOnly If true, the depth buffer will be read-only\r\n * @param stencilReadOnly If true, the stencil buffer will be read-only\r\n * @returns The created render target wrapper\r\n */\r\n public createRenderTarget(\r\n name: string,\r\n renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[],\r\n renderTargetDepth?: FrameGraphTextureHandle,\r\n depthReadOnly?: boolean,\r\n stencilReadOnly?: boolean\r\n ): FrameGraphRenderTarget {\r\n return this._textureManager.createRenderTarget(name, renderTargets, renderTargetDepth, depthReadOnly, stencilReadOnly);\r\n }\r\n\r\n /**\r\n * Clears the current render buffer or the current render target (if any is set up)\r\n * @param color Defines the color to use\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Clears the color attachments of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n */\r\n public clearColorAttachments(color: Nullable<IColor4Like>, attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, true, false, false);\r\n }\r\n\r\n /**\r\n * Clears all attachments (color(s) + depth/stencil) of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clearAttachments(color: Nullable<IColor4Like>, attachments: number[], backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Binds the attachments to the current render target\r\n * @param attachments The attachments to bind\r\n */\r\n public bindAttachments(attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n }\r\n\r\n /**\r\n * Generates mipmaps for the current render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._currentRenderTarget?.renderTargetWrapper === undefined) {\r\n return;\r\n }\r\n\r\n if (this._renderTargetIsBound && this._engine._currentRenderTarget) {\r\n // we can't generate the mipmaps if the render target is bound\r\n this._flushDebugMessages();\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n const textures = this._currentRenderTarget.renderTargetWrapper.textures;\r\n if (textures) {\r\n for (const texture of textures) {\r\n this._engine.generateMipmaps(texture);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the texture sampling mode for a given texture handle\r\n * @param handle Handle of the texture to set the sampling mode for\r\n * @param samplingMode Sampling mode to set\r\n */\r\n public setTextureSamplingMode(handle: FrameGraphTextureHandle, samplingMode: number): void {\r\n const internalTexture = this._textureManager.getTextureFromHandle(handle);\r\n if (internalTexture && internalTexture.samplingMode !== samplingMode) {\r\n this._engine.updateTextureSamplingMode(samplingMode, internalTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Binds a texture handle to a given effect (resolves the handle to a texture and binds it to the effect)\r\n * @param effect The effect to bind the texture to\r\n * @param name The name of the texture in the effect\r\n * @param handle The handle of the texture to bind\r\n */\r\n public bindTextureHandle(effect: Effect, name: string, handle: FrameGraphTextureHandle): void {\r\n let texture: Nullable<InternalTexture>;\r\n\r\n const historyEntry = this._textureManager._historyTextures.get(handle);\r\n if (historyEntry) {\r\n texture = historyEntry.textures[historyEntry.index]; // texture we write to in this frame\r\n if (\r\n this._currentRenderTarget !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper.textures!.includes(texture!)\r\n ) {\r\n // If the current render target renders to the history write texture, we bind the read texture instead\r\n texture = historyEntry.textures[historyEntry.index ^ 1];\r\n }\r\n } else {\r\n texture = this._textureManager._textures.get(handle)!.texture;\r\n }\r\n\r\n effect._bindTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Applies a full-screen effect to the current render target\r\n * @param drawWrapper The draw wrapper containing the effect to apply\r\n * @param customBindings The custom bindings to use when applying the effect (optional)\r\n * @param stencilState The stencil state to use when applying the effect (optional)\r\n * @param disableColorWrite If true, color write will be disabled when applying the effect (optional)\r\n * @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)\r\n * @param depthTest If true, depth testing will be enabled when applying the effect (default is false)\r\n * @returns True if the effect was applied, otherwise false (effect not ready)\r\n */\r\n public applyFullScreenEffect(\r\n drawWrapper: DrawWrapper,\r\n customBindings?: () => void,\r\n stencilState?: IStencilState,\r\n disableColorWrite?: boolean,\r\n drawBackFace?: boolean,\r\n depthTest?: boolean\r\n ): boolean {\r\n if (!drawWrapper.effect?.isReady()) {\r\n return false;\r\n }\r\n\r\n this._applyRenderTarget();\r\n\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n const effectRenderer = drawBackFace ? this._effectRendererBack : this._effectRenderer;\r\n\r\n effectRenderer.saveStates();\r\n effectRenderer.setViewport();\r\n\r\n this._engine.enableEffect(drawWrapper);\r\n this._engine.setState(false, undefined, undefined, undefined, undefined, stencilState);\r\n this._engine.setDepthBuffer(!!depthTest);\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(false);\r\n }\r\n this._engine.setDepthWrite(false);\r\n\r\n effectRenderer.bindBuffers(drawWrapper.effect);\r\n customBindings?.();\r\n effectRenderer.draw();\r\n effectRenderer.restoreStates();\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(true);\r\n }\r\n this._engine.setDepthWrite(engineDepthMask);\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Copies a texture to the current render target\r\n * @param sourceTexture The source texture to copy from\r\n * @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target\r\n */\r\n public copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer = false): void {\r\n if (forceCopyToBackbuffer) {\r\n this.bindRenderTarget();\r\n }\r\n this._applyRenderTarget();\r\n this._copyTexture.copy(this._textureManager.getTextureFromHandle(sourceTexture, true)!);\r\n }\r\n\r\n /**\r\n * Renders a RenderTargetTexture or a layer\r\n * @param object The RenderTargetTexture/Layer to render\r\n * @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n * @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n */\r\n public render(object: Layer | ObjectRenderer | UtilityLayerRenderer, viewportWidth?: number, viewportHeight?: number): void {\r\n if (FrameGraphRenderContext._IsObjectRenderer(object)) {\r\n this._scene._intermediateRendering = true;\r\n if (object.shouldRender()) {\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this._applyRenderTarget();\r\n\r\n object.prepareRenderList();\r\n\r\n object.initRender(viewportWidth!, viewportHeight!);\r\n\r\n object.render();\r\n\r\n object.finishRender();\r\n }\r\n this._scene._intermediateRendering = false;\r\n } else {\r\n this._applyRenderTarget();\r\n object.render();\r\n }\r\n }\r\n\r\n /**\r\n * Binds a render target texture so that upcoming draw calls will render to it\r\n * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call\r\n * this method several times with different render targets without incurring the cost of binding if no draw calls are made\r\n * @param renderTarget The handle of the render target texture to bind (default: undefined, meaning \"back buffer\"). Pass an array for MRT rendering.\r\n * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)\r\n * @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).\r\n */\r\n public bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string, applyImmediately = false): void {\r\n if (\r\n (renderTarget?.renderTargetWrapper === undefined && this._currentRenderTarget === undefined) ||\r\n (renderTarget && this._currentRenderTarget && renderTarget.equals(this._currentRenderTarget))\r\n ) {\r\n this._flushDebugMessages();\r\n if (debugMessage !== undefined) {\r\n this._engine._debugPushGroup?.(debugMessage, 2);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n if (applyImmediately) {\r\n this._applyRenderTarget();\r\n }\r\n return;\r\n }\r\n this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;\r\n this._debugMessageWhenTargetBound = debugMessage;\r\n this._renderTargetIsBound = false;\r\n if (applyImmediately) {\r\n this._applyRenderTarget();\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _flushDebugMessages() {\r\n if (this._debugMessageHasBeenPushed) {\r\n this._engine._debugPopGroup?.(2);\r\n this._debugMessageHasBeenPushed = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _applyRenderTarget() {\r\n if (this._renderTargetIsBound) {\r\n return;\r\n }\r\n\r\n this._flushDebugMessages();\r\n\r\n const renderTargetWrapper = this._currentRenderTarget?.renderTargetWrapper;\r\n\r\n if (renderTargetWrapper === undefined) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n }\r\n this._engine.bindFramebuffer(renderTargetWrapper);\r\n }\r\n\r\n if (this._debugMessageWhenTargetBound !== undefined) {\r\n this._engine._debugPushGroup?.(this._debugMessageWhenTargetBound, 2);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n\r\n this._renderTargetIsBound = true;\r\n }\r\n\r\n /** @internal */\r\n public _isReady(): boolean {\r\n return this._copyTexture.isReady();\r\n }\r\n\r\n /** @internal */\r\n public _dispose() {\r\n this._effectRenderer.dispose();\r\n this._effectRendererBack.dispose();\r\n this._copyTexture.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -50,6 +50,9 @@ export declare class FrameGraphTextureManager {
|
|
|
50
50
|
* Gets or sets a boolean indicating if debug logs should be shown when applying texture allocation optimization (default: false)
|
|
51
51
|
*/
|
|
52
52
|
showDebugLogsForTextureAllcationOptimization: boolean;
|
|
53
|
+
private _backBufferTextureEntry;
|
|
54
|
+
private _backBufferDepthStencilTextureEntry;
|
|
55
|
+
private _backBufferTextureOverriden;
|
|
53
56
|
/**
|
|
54
57
|
* Constructs a new instance of the texture manager
|
|
55
58
|
* @param engine The engine to use
|
|
@@ -63,6 +66,8 @@ export declare class FrameGraphTextureManager {
|
|
|
63
66
|
* @returns True if the handle is a backbuffer handle
|
|
64
67
|
*/
|
|
65
68
|
isBackbuffer(handle: FrameGraphTextureHandle): boolean;
|
|
69
|
+
/** @internal */
|
|
70
|
+
_isBackbuffer(handle: FrameGraphTextureHandle): boolean;
|
|
66
71
|
/**
|
|
67
72
|
* Checks if a handle is a backbuffer color handle
|
|
68
73
|
* @param handle The handle to check
|
|
@@ -104,11 +109,12 @@ export declare class FrameGraphTextureManager {
|
|
|
104
109
|
getTextureHandleOrCreateTexture(handle?: FrameGraphTextureHandle, newTextureName?: string, creationOptions?: FrameGraphTextureCreationOptions): FrameGraphTextureHandle;
|
|
105
110
|
/**
|
|
106
111
|
* Gets a texture from a handle.
|
|
107
|
-
* Note that if the texture is a history texture, the read texture for the current frame will be returned.
|
|
112
|
+
* Note that if the texture is a history texture, the read texture for the current frame will be returned, except if historyGetWriteTexture is true.
|
|
108
113
|
* @param handle The handle of the texture
|
|
114
|
+
* @param historyGetWriteTexture If true and the texture is a history texture, the write texture for the current frame will be returned (default: false)
|
|
109
115
|
* @returns The texture or null if not found
|
|
110
116
|
*/
|
|
111
|
-
getTextureFromHandle(handle: FrameGraphTextureHandle): Nullable<InternalTexture>;
|
|
117
|
+
getTextureFromHandle(handle: FrameGraphTextureHandle, historyGetWriteTexture?: boolean): Nullable<InternalTexture>;
|
|
112
118
|
/**
|
|
113
119
|
* Imports a texture into the texture manager
|
|
114
120
|
* @param name Name of the texture
|
|
@@ -170,6 +176,30 @@ export declare class FrameGraphTextureManager {
|
|
|
170
176
|
* @returns The total size of all textures
|
|
171
177
|
*/
|
|
172
178
|
computeTotalTextureSize(optimizedSize: boolean, outputWidth: number, outputHeight: number): number;
|
|
179
|
+
/**
|
|
180
|
+
* True if the back buffer texture has been overriden by a call to setBackBufferTexture
|
|
181
|
+
*/
|
|
182
|
+
get backBufferTextureOverriden(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Overrides the default back buffer color/depth-stencil textures used by the frame graph.
|
|
185
|
+
* Note that if both textureCreationOptions and depthStencilTextureCreationOptions are provided,
|
|
186
|
+
* the engine will use them to create the back buffer color and depth/stencil textures respectively.
|
|
187
|
+
* In that case, width and height are ignored.
|
|
188
|
+
* @param width The width of the back buffer color/depth-stencil texture (if 0, the engine's current back buffer color/depth-stencil texture width will be used)
|
|
189
|
+
* @param height The height of the back buffer color/depth-stencil texture (if 0, the engine's current back buffer color/depth-stencil texture height will be used)
|
|
190
|
+
* @param textureCreationOptions The color texture creation options (optional)
|
|
191
|
+
* @param depthStencilTextureCreationOptions The depth/stencil texture creation options (optional)
|
|
192
|
+
*/
|
|
193
|
+
setBackBufferTextures(width: number, height: number, textureCreationOptions?: FrameGraphTextureCreationOptions, depthStencilTextureCreationOptions?: FrameGraphTextureCreationOptions): void;
|
|
194
|
+
/**
|
|
195
|
+
* Resets the back buffer color/depth-stencil textures to the default (the engine's current back buffer textures)
|
|
196
|
+
* It has no effect if setBackBufferTextures has not been called before.
|
|
197
|
+
*/
|
|
198
|
+
resetBackBufferTextures(): void;
|
|
199
|
+
/**
|
|
200
|
+
* Returns true if the texture manager has at least one history texture
|
|
201
|
+
*/
|
|
202
|
+
get hasHistoryTextures(): boolean;
|
|
173
203
|
/** @internal */
|
|
174
204
|
_dispose(): void;
|
|
175
205
|
/** @internal */
|
|
@@ -37,6 +37,9 @@ export class FrameGraphTextureManager {
|
|
|
37
37
|
* Gets or sets a boolean indicating if debug logs should be shown when applying texture allocation optimization (default: false)
|
|
38
38
|
*/
|
|
39
39
|
this.showDebugLogsForTextureAllcationOptimization = false;
|
|
40
|
+
this._backBufferTextureEntry = null;
|
|
41
|
+
this._backBufferDepthStencilTextureEntry = null;
|
|
42
|
+
this._backBufferTextureOverriden = false;
|
|
40
43
|
this._addSystemTextures();
|
|
41
44
|
}
|
|
42
45
|
/**
|
|
@@ -45,6 +48,13 @@ export class FrameGraphTextureManager {
|
|
|
45
48
|
* @returns True if the handle is a backbuffer handle
|
|
46
49
|
*/
|
|
47
50
|
isBackbuffer(handle) {
|
|
51
|
+
if (this._backBufferTextureOverriden) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return this._isBackbuffer(handle);
|
|
55
|
+
}
|
|
56
|
+
/** @internal */
|
|
57
|
+
_isBackbuffer(handle) {
|
|
48
58
|
if (handle === backbufferColorTextureHandle || handle === backbufferDepthStencilTextureHandle) {
|
|
49
59
|
return true;
|
|
50
60
|
}
|
|
@@ -60,6 +70,9 @@ export class FrameGraphTextureManager {
|
|
|
60
70
|
* @returns True if the handle is a backbuffer color handle
|
|
61
71
|
*/
|
|
62
72
|
isBackbufferColor(handle) {
|
|
73
|
+
if (this._backBufferTextureOverriden) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
63
76
|
if (handle === backbufferColorTextureHandle) {
|
|
64
77
|
return true;
|
|
65
78
|
}
|
|
@@ -75,6 +88,9 @@ export class FrameGraphTextureManager {
|
|
|
75
88
|
* @returns True if the handle is a backbuffer depth/stencil handle
|
|
76
89
|
*/
|
|
77
90
|
isBackbufferDepthStencil(handle) {
|
|
91
|
+
if (this._backBufferTextureOverriden) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
78
94
|
if (handle === backbufferDepthStencilTextureHandle) {
|
|
79
95
|
return true;
|
|
80
96
|
}
|
|
@@ -103,6 +119,7 @@ export class FrameGraphTextureManager {
|
|
|
103
119
|
* @returns The creation options of the texture
|
|
104
120
|
*/
|
|
105
121
|
getTextureCreationOptions(handle) {
|
|
122
|
+
handle = this._textures.get(handle)?.refHandle ?? handle;
|
|
106
123
|
const entry = this._textures.get(handle);
|
|
107
124
|
const creationOptions = entry.creationOptions;
|
|
108
125
|
return {
|
|
@@ -148,16 +165,21 @@ export class FrameGraphTextureManager {
|
|
|
148
165
|
}
|
|
149
166
|
/**
|
|
150
167
|
* Gets a texture from a handle.
|
|
151
|
-
* Note that if the texture is a history texture, the read texture for the current frame will be returned.
|
|
168
|
+
* Note that if the texture is a history texture, the read texture for the current frame will be returned, except if historyGetWriteTexture is true.
|
|
152
169
|
* @param handle The handle of the texture
|
|
170
|
+
* @param historyGetWriteTexture If true and the texture is a history texture, the write texture for the current frame will be returned (default: false)
|
|
153
171
|
* @returns The texture or null if not found
|
|
154
172
|
*/
|
|
155
|
-
getTextureFromHandle(handle) {
|
|
156
|
-
const
|
|
173
|
+
getTextureFromHandle(handle, historyGetWriteTexture) {
|
|
174
|
+
const entry = this._textures.get(handle);
|
|
175
|
+
const refHandle = entry?.refHandle;
|
|
176
|
+
const finalEntry = refHandle !== undefined ? this._textures.get(refHandle) : entry;
|
|
177
|
+
const finalHandle = refHandle !== undefined ? refHandle : handle;
|
|
178
|
+
const historyEntry = this._historyTextures.get(finalHandle);
|
|
157
179
|
if (historyEntry) {
|
|
158
|
-
return historyEntry.textures[historyEntry.index ^ 1];
|
|
180
|
+
return historyEntry.textures[historyGetWriteTexture ? historyEntry.index : historyEntry.index ^ 1];
|
|
159
181
|
}
|
|
160
|
-
return
|
|
182
|
+
return finalEntry.texture;
|
|
161
183
|
}
|
|
162
184
|
/**
|
|
163
185
|
* Imports a texture into the texture manager
|
|
@@ -260,6 +282,7 @@ export class FrameGraphTextureManager {
|
|
|
260
282
|
if (textureEntry === undefined) {
|
|
261
283
|
throw new Error(`resolveDanglingHandle: Handle ${handle} does not exist!`);
|
|
262
284
|
}
|
|
285
|
+
handle = textureEntry.refHandle ?? handle; // gets the refHandle if handle is a (resolved) dangling handle itself
|
|
263
286
|
this._textures.set(danglingHandle, {
|
|
264
287
|
texture: textureEntry.texture,
|
|
265
288
|
refHandle: handle,
|
|
@@ -281,7 +304,10 @@ export class FrameGraphTextureManager {
|
|
|
281
304
|
* @param screenHeight The height of the screen (default: the height of the rendering canvas)
|
|
282
305
|
* @returns The absolute dimensions of the texture
|
|
283
306
|
*/
|
|
284
|
-
getAbsoluteDimensions(size, screenWidth
|
|
307
|
+
getAbsoluteDimensions(size, screenWidth, screenHeight) {
|
|
308
|
+
const backbufferColorTextureSize = this._textures.get(backbufferColorTextureHandle).creationOptions.size;
|
|
309
|
+
screenWidth = backbufferColorTextureSize.width;
|
|
310
|
+
screenHeight = backbufferColorTextureSize.height;
|
|
285
311
|
const { width, height } = getDimensionsFromTextureSize(size);
|
|
286
312
|
return {
|
|
287
313
|
width: Math.floor((width * screenWidth) / 100),
|
|
@@ -298,7 +324,8 @@ export class FrameGraphTextureManager {
|
|
|
298
324
|
computeTotalTextureSize(optimizedSize, outputWidth, outputHeight) {
|
|
299
325
|
let totalSize = 0;
|
|
300
326
|
this._textures.forEach((entry, handle) => {
|
|
301
|
-
if (handle === backbufferColorTextureHandle || handle === backbufferDepthStencilTextureHandle ||
|
|
327
|
+
if ((!this._backBufferTextureOverriden && (handle === backbufferColorTextureHandle || handle === backbufferDepthStencilTextureHandle)) ||
|
|
328
|
+
entry.refHandle !== undefined) {
|
|
302
329
|
return;
|
|
303
330
|
}
|
|
304
331
|
if (optimizedSize && entry.aliasHandle !== undefined) {
|
|
@@ -321,6 +348,105 @@ export class FrameGraphTextureManager {
|
|
|
321
348
|
});
|
|
322
349
|
return totalSize;
|
|
323
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* True if the back buffer texture has been overriden by a call to setBackBufferTexture
|
|
353
|
+
*/
|
|
354
|
+
get backBufferTextureOverriden() {
|
|
355
|
+
return this._backBufferTextureOverriden;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Overrides the default back buffer color/depth-stencil textures used by the frame graph.
|
|
359
|
+
* Note that if both textureCreationOptions and depthStencilTextureCreationOptions are provided,
|
|
360
|
+
* the engine will use them to create the back buffer color and depth/stencil textures respectively.
|
|
361
|
+
* In that case, width and height are ignored.
|
|
362
|
+
* @param width The width of the back buffer color/depth-stencil texture (if 0, the engine's current back buffer color/depth-stencil texture width will be used)
|
|
363
|
+
* @param height The height of the back buffer color/depth-stencil texture (if 0, the engine's current back buffer color/depth-stencil texture height will be used)
|
|
364
|
+
* @param textureCreationOptions The color texture creation options (optional)
|
|
365
|
+
* @param depthStencilTextureCreationOptions The depth/stencil texture creation options (optional)
|
|
366
|
+
*/
|
|
367
|
+
setBackBufferTextures(width, height, textureCreationOptions, depthStencilTextureCreationOptions) {
|
|
368
|
+
if ((width === 0 || height === 0) && (!textureCreationOptions || !depthStencilTextureCreationOptions)) {
|
|
369
|
+
if (this._backBufferTextureOverriden) {
|
|
370
|
+
let entry = this._textures.get(backbufferColorTextureHandle);
|
|
371
|
+
entry.texture?.dispose();
|
|
372
|
+
entry.texture = null;
|
|
373
|
+
entry.debug?.dispose();
|
|
374
|
+
entry.debug = undefined;
|
|
375
|
+
entry = this._textures.get(backbufferDepthStencilTextureHandle);
|
|
376
|
+
entry.texture?.dispose();
|
|
377
|
+
entry.texture = null;
|
|
378
|
+
entry.debug?.dispose();
|
|
379
|
+
entry.debug = undefined;
|
|
380
|
+
}
|
|
381
|
+
this._backBufferTextureEntry = null;
|
|
382
|
+
this._backBufferDepthStencilTextureEntry = null;
|
|
383
|
+
this._backBufferTextureOverriden = false;
|
|
384
|
+
this._addSystemTextures();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
this._backBufferTextureOverriden = true;
|
|
388
|
+
const size = { width, height };
|
|
389
|
+
this._backBufferTextureEntry = {
|
|
390
|
+
name: "backbuffer color",
|
|
391
|
+
texture: null,
|
|
392
|
+
creationOptions: textureCreationOptions ?? {
|
|
393
|
+
size,
|
|
394
|
+
options: {
|
|
395
|
+
createMipMaps: false,
|
|
396
|
+
samples: this.engine.getCreationOptions().antialias ? 4 : 1,
|
|
397
|
+
types: [0],
|
|
398
|
+
formats: [5],
|
|
399
|
+
useSRGBBuffers: [false],
|
|
400
|
+
creationFlags: [0],
|
|
401
|
+
labels: ["backbuffer color"],
|
|
402
|
+
},
|
|
403
|
+
sizeIsPercentage: false,
|
|
404
|
+
},
|
|
405
|
+
namespace: FrameGraphTextureNamespace.Graph,
|
|
406
|
+
lifespan: {
|
|
407
|
+
firstTask: Number.MAX_VALUE,
|
|
408
|
+
lastTask: 0,
|
|
409
|
+
},
|
|
410
|
+
};
|
|
411
|
+
this._backBufferTextureEntry.textureDescriptionHash = this._createTextureDescriptionHash(this._backBufferTextureEntry.creationOptions);
|
|
412
|
+
this._backBufferDepthStencilTextureEntry = {
|
|
413
|
+
name: "backbuffer depth/stencil",
|
|
414
|
+
texture: null,
|
|
415
|
+
creationOptions: depthStencilTextureCreationOptions ?? {
|
|
416
|
+
size,
|
|
417
|
+
options: {
|
|
418
|
+
createMipMaps: false,
|
|
419
|
+
samples: this.engine.getCreationOptions().antialias ? 4 : 1,
|
|
420
|
+
types: [0],
|
|
421
|
+
formats: [this.engine.isStencilEnable ? 13 : 14],
|
|
422
|
+
useSRGBBuffers: [false],
|
|
423
|
+
creationFlags: [0],
|
|
424
|
+
labels: ["backbuffer depth/stencil"],
|
|
425
|
+
},
|
|
426
|
+
sizeIsPercentage: false,
|
|
427
|
+
},
|
|
428
|
+
namespace: FrameGraphTextureNamespace.Graph,
|
|
429
|
+
lifespan: {
|
|
430
|
+
firstTask: Number.MAX_VALUE,
|
|
431
|
+
lastTask: 0,
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
this._backBufferDepthStencilTextureEntry.textureDescriptionHash = this._createTextureDescriptionHash(this._backBufferDepthStencilTextureEntry.creationOptions);
|
|
435
|
+
this._addSystemTextures();
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Resets the back buffer color/depth-stencil textures to the default (the engine's current back buffer textures)
|
|
439
|
+
* It has no effect if setBackBufferTextures has not been called before.
|
|
440
|
+
*/
|
|
441
|
+
resetBackBufferTextures() {
|
|
442
|
+
this.setBackBufferTextures(0, 0);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Returns true if the texture manager has at least one history texture
|
|
446
|
+
*/
|
|
447
|
+
get hasHistoryTextures() {
|
|
448
|
+
return this._historyTextures.size > 0;
|
|
449
|
+
}
|
|
324
450
|
/** @internal */
|
|
325
451
|
_dispose() {
|
|
326
452
|
this._releaseTextures();
|
|
@@ -414,6 +540,7 @@ export class FrameGraphTextureManager {
|
|
|
414
540
|
entry.texture = null;
|
|
415
541
|
if (releaseAll || entry.namespace === FrameGraphTextureNamespace.Task) {
|
|
416
542
|
this._textures.delete(handle);
|
|
543
|
+
this._historyTextures.delete(handle);
|
|
417
544
|
}
|
|
418
545
|
});
|
|
419
546
|
this._historyTextures.forEach((entry) => {
|
|
@@ -441,7 +568,7 @@ export class FrameGraphTextureManager {
|
|
|
441
568
|
}
|
|
442
569
|
_addSystemTextures() {
|
|
443
570
|
const size = { width: this.engine.getRenderWidth(true), height: this.engine.getRenderHeight(true) };
|
|
444
|
-
this._textures.set(backbufferColorTextureHandle, {
|
|
571
|
+
this._textures.set(backbufferColorTextureHandle, this._backBufferTextureEntry ?? {
|
|
445
572
|
name: "backbuffer color",
|
|
446
573
|
texture: null,
|
|
447
574
|
creationOptions: {
|
|
@@ -459,7 +586,7 @@ export class FrameGraphTextureManager {
|
|
|
459
586
|
},
|
|
460
587
|
namespace: FrameGraphTextureNamespace.External,
|
|
461
588
|
});
|
|
462
|
-
this._textures.set(backbufferDepthStencilTextureHandle, {
|
|
589
|
+
this._textures.set(backbufferDepthStencilTextureHandle, this._backBufferDepthStencilTextureEntry ?? {
|
|
463
590
|
name: "backbuffer depth/stencil",
|
|
464
591
|
texture: null,
|
|
465
592
|
creationOptions: {
|
|
@@ -659,6 +786,9 @@ export class FrameGraphTextureManager {
|
|
|
659
786
|
const iterator = dependencies.keys();
|
|
660
787
|
for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
|
|
661
788
|
const textureHandle = key.value;
|
|
789
|
+
if (this.isBackbuffer(textureHandle)) {
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
662
792
|
let textureEntry = this._textures.get(textureHandle);
|
|
663
793
|
if (!textureEntry) {
|
|
664
794
|
throw new Error(`FrameGraph._computeTextureLifespan: Texture handle "${textureHandle}" not found in the texture manager.`);
|