@onerjs/core 8.33.5 → 8.33.7
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/Engines/WebGPU/Extensions/engine.multiRender.js +5 -10
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +4 -2
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +4 -3
- package/Engines/WebGPU/webgpuHardwareTexture.js +27 -21
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +5 -4
- package/Engines/WebGPU/webgpuTextureManager.js +20 -30
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/engine.d.ts +1 -0
- package/Engines/thinEngine.js +9 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/thinWebGPUEngine.js +2 -3
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +28 -13
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +2 -2
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +2 -2
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js +4 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js +19 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +16 -0
- package/FrameGraph/Passes/renderPass.js +12 -0
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +3 -3
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -2
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +2 -2
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +3 -2
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.js +4 -15
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +2 -2
- package/FrameGraph/frameGraphTask.js +6 -6
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTaskMultiRenderTarget.d.ts +15 -0
- package/FrameGraph/frameGraphTaskMultiRenderTarget.js +25 -0
- package/FrameGraph/frameGraphTaskMultiRenderTarget.js.map +1 -0
- package/FrameGraph/frameGraphTextureManager.js +13 -2
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/frameGraphTypes.d.ts +9 -1
- package/FrameGraph/frameGraphTypes.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +13 -0
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +4 -0
- package/Materials/Textures/baseTexture.js +4 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/textureCreationOptions.d.ts +2 -0
- package/Materials/Textures/textureCreationOptions.js +0 -1
- package/Materials/Textures/textureCreationOptions.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geometry.js +1 -0
- package/Meshes/geometry.js.map +1 -1
- package/Misc/decorators.serialization.js +1 -1
- package/Misc/decorators.serialization.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +2 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +4 -12
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/Shaders/picking.vertex.js +2 -2
- package/Shaders/picking.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +8 -14
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/picking.vertex.js +2 -2
- package/ShadersWGSL/picking.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IAmD1D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAxD5B;;WAEG;QACI,UAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAE5C;;WAEG;QACI,eAAU,GAAG,IAAI,CAAC;QAEzB;;WAEG;QACI,8BAAyB,GAAG,KAAK,CAAC;QAEzC;;WAEG;QACI,eAAU,GAAG,KAAK,CAAC;QAE1B;;WAEG;QACI,iBAAY,GAAG,KAAK,CAAC;QAE5B;;WAEG;QACI,iBAAY,GAAG,CAAC,CAAC;QA8BpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;QAC5E,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,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rC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE;YACxB,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC;YAC5E,IAAI,mBAAmB,EAAE,CAAC;gBACtB,mBAAmB,CAAC,2BAA2B,GAAG,IAAI,CAAC;YAC3D,CAAC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;gBACjC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;YAED,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/H,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,4BAA4B,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAEnF,YAAY,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YAC7C,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureHandle, FrameGraphRenderPass } from \"core/index\";\r\nimport { Color4, TmpColors } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { backbufferColorTextureHandle } from \"../../frameGraphTypes\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTask {\r\n /**\r\n * The color to clear the texture with.\r\n */\r\n public color = new Color4(0.2, 0.2, 0.3, 1);\r\n\r\n /**\r\n * If the color should be cleared.\r\n */\r\n public clearColor = true;\r\n\r\n /**\r\n * If the color should be converted to linear space (default: false).\r\n */\r\n public convertColorToLinearSpace = false;\r\n\r\n /**\r\n * If the depth should be cleared.\r\n */\r\n public clearDepth = false;\r\n\r\n /**\r\n * If the stencil should be cleared.\r\n */\r\n public clearStencil = false;\r\n\r\n /**\r\n * The value to use to clear the stencil buffer (default: 0).\r\n */\r\n public stencilValue = 0;\r\n\r\n /**\r\n * The color texture to clear.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle | FrameGraphTextureHandle[];\r\n\r\n /**\r\n * The depth attachment texture to clear.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as targetTexture, but the handle will be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth texture (same as depthTexture, but the handle will be different).\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new clear task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"FrameGraphClearTextureTask\";\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n if (this.targetTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n const targetTextures = this.targetTexture !== undefined ? (Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture]) : undefined;\r\n\r\n if (this.targetTexture !== undefined) {\r\n textureManager.resolveDanglingHandle(this.outputTexture, targetTextures![0]);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n if (this.targetTexture !== undefined && this.depthTexture !== undefined) {\r\n const targetDescription = textureManager.getTextureDescription(targetTextures![0]);\r\n const depthDescription = textureManager.getTextureDescription(this.depthTexture);\r\n\r\n if (targetDescription.size.width !== depthDescription.size.width || targetDescription.size.height !== depthDescription.size.height) {\r\n throw new Error(\r\n `FrameGraphClearTextureTask ${this.name}: the depth texture (size: ${depthDescription.size.width}x${depthDescription.size.height}) and the target texture (size: ${targetDescription.size.width}x${targetDescription.size.height}) must have the same dimensions.`\r\n );\r\n }\r\n\r\n const textureSamples = targetDescription.options.samples || 1;\r\n const depthSamples = depthDescription.options.samples || 1;\r\n\r\n if (textureSamples !== depthSamples && textureSamples !== 0 && depthSamples !== 0) {\r\n throw new Error(\r\n `FrameGraphClearTextureTask ${this.name}: the depth texture (${depthSamples} samples) and the target texture (${textureSamples} samples) must have the same number of samples.`\r\n );\r\n }\r\n }\r\n\r\n const attachments = this._frameGraph.engine.buildTextureLayout(\r\n targetTextures ? Array(targetTextures.length).fill(true) : [],\r\n this.targetTexture === backbufferColorTextureHandle && !this._frameGraph.textureManager.backBufferTextureOverriden\r\n );\r\n\r\n const color = TmpColors.Color4[0];\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(targetTextures);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setInitializeFunc(() => {\r\n const renderTargetWrapper = pass.frameGraphRenderTarget.renderTargetWrapper;\r\n if (renderTargetWrapper) {\r\n renderTargetWrapper.disableAutomaticMSAAResolve = true;\r\n }\r\n });\r\n pass.setExecuteFunc((context) => {\r\n color.copyFrom(this.color);\r\n if (this.convertColorToLinearSpace) {\r\n color.toLinearSpaceToRef(color);\r\n }\r\n\r\n context.clearAttachments(color, attachments, !!this.clearColor, !!this.clearDepth, !!this.clearStencil, this.stencilValue);\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(targetTextures);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,+BAA+B;IAmD3E;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAxD5B;;WAEG;QACI,UAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAE5C;;WAEG;QACI,eAAU,GAAG,IAAI,CAAC;QAEzB;;WAEG;QACI,8BAAyB,GAAG,KAAK,CAAC;QAEzC;;WAEG;QACI,eAAU,GAAG,KAAK,CAAC;QAE1B;;WAEG;QACI,iBAAY,GAAG,KAAK,CAAC;QAE5B;;WAEG;QACI,iBAAY,GAAG,CAAC,CAAC;QA8BpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,W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AE,GAAE,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureHandle, FrameGraphRenderPass } from \"core/index\";\r\nimport { Color4, TmpColors } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTaskMultiRenderTarget } from \"../../frameGraphTaskMultiRenderTarget\";\r\nimport { backbufferColorTextureHandle } from \"../../frameGraphTypes\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTaskMultiRenderTarget {\r\n /**\r\n * The color to clear the texture with.\r\n */\r\n public color = new Color4(0.2, 0.2, 0.3, 1);\r\n\r\n /**\r\n * If the color should be cleared.\r\n */\r\n public clearColor = true;\r\n\r\n /**\r\n * If the color should be converted to linear space (default: false).\r\n */\r\n public convertColorToLinearSpace = false;\r\n\r\n /**\r\n * If the depth should be cleared.\r\n */\r\n public clearDepth = false;\r\n\r\n /**\r\n * If the stencil should be cleared.\r\n */\r\n public clearStencil = false;\r\n\r\n /**\r\n * The value to use to clear the stencil buffer (default: 0).\r\n */\r\n public stencilValue = 0;\r\n\r\n /**\r\n * The color texture to clear.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle | FrameGraphTextureHandle[];\r\n\r\n /**\r\n * The depth attachment texture to clear.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as targetTexture, but the handle will be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth texture (same as depthTexture, but the handle will be different).\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new clear task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"FrameGraphClearTextureTask\";\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n if (this.targetTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n const targetTextures = this.targetTexture !== undefined ? (Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture]) : undefined;\r\n\r\n if (this.targetTexture !== undefined) {\r\n textureManager.resolveDanglingHandle(this.outputTexture, targetTextures![0]);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n if (this.targetTexture !== undefined && this.depthTexture !== undefined) {\r\n const targetDescription = textureManager.getTextureDescription(targetTextures![0]);\r\n const depthDescription = textureManager.getTextureDescription(this.depthTexture);\r\n\r\n if (targetDescription.size.width !== depthDescription.size.width || targetDescription.size.height !== depthDescription.size.height) {\r\n throw new Error(\r\n `FrameGraphClearTextureTask ${this.name}: the depth texture (size: ${depthDescription.size.width}x${depthDescription.size.height}) and the target texture (size: ${targetDescription.size.width}x${targetDescription.size.height}) must have the same dimensions.`\r\n );\r\n }\r\n\r\n const textureSamples = targetDescription.options.samples || 1;\r\n const depthSamples = depthDescription.options.samples || 1;\r\n\r\n if (textureSamples !== depthSamples && textureSamples !== 0 && depthSamples !== 0) {\r\n throw new Error(\r\n `FrameGraphClearTextureTask ${this.name}: the depth texture (${depthSamples} samples) and the target texture (${textureSamples} samples) must have the same number of samples.`\r\n );\r\n }\r\n }\r\n\r\n const attachments = this._frameGraph.engine.buildTextureLayout(\r\n targetTextures ? Array(targetTextures.length).fill(true) : [],\r\n this.targetTexture === backbufferColorTextureHandle && !this._frameGraph.textureManager.backBufferTextureOverriden\r\n );\r\n\r\n const color = TmpColors.Color4[0];\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(targetTextures);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setInitializeFunc(() => {\r\n const renderTargetWrapper = pass.frameGraphRenderTarget.renderTargetWrapper;\r\n if (renderTargetWrapper) {\r\n renderTargetWrapper.disableAutomaticMSAAResolve = true;\r\n }\r\n });\r\n pass.setExecuteFunc((context) => {\r\n this._updateLayerAndFaceIndices(pass);\r\n\r\n color.copyFrom(this.color);\r\n if (this.convertColorToLinearSpace) {\r\n color.toLinearSpaceToRef(color);\r\n }\r\n\r\n context.clearAttachments(color, attachments, !!this.clearColor, !!this.clearDepth, !!this.clearStencil, this.stencilValue);\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(targetTextures);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
|
|
@@ -273,19 +273,6 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
273
273
|
* @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).
|
|
274
274
|
*/
|
|
275
275
|
bindRenderTarget(renderTarget, debugMessage, applyImmediately = false) {
|
|
276
|
-
if ((renderTarget?.renderTargetWrapper === undefined && this._currentRenderTarget === undefined) ||
|
|
277
|
-
(renderTarget && this._currentRenderTarget && renderTarget.equals(this._currentRenderTarget))) {
|
|
278
|
-
this._flushDebugMessages();
|
|
279
|
-
if (debugMessage !== undefined) {
|
|
280
|
-
this.pushDebugGroup(debugMessage);
|
|
281
|
-
this._debugMessageWhenTargetBound = undefined;
|
|
282
|
-
this._debugMessageHasBeenPushed = true;
|
|
283
|
-
}
|
|
284
|
-
if (applyImmediately) {
|
|
285
|
-
this._applyRenderTarget();
|
|
286
|
-
}
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
276
|
this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;
|
|
290
277
|
this._debugMessageWhenTargetBound = debugMessage;
|
|
291
278
|
this._renderTargetIsBound = false;
|
|
@@ -308,9 +295,11 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
308
295
|
this._flushDebugMessages();
|
|
309
296
|
const renderTargetWrapper = this._currentRenderTarget?.renderTargetWrapper;
|
|
310
297
|
if (renderTargetWrapper === undefined) {
|
|
311
|
-
this._engine.
|
|
298
|
+
if (this._engine._currentRenderTarget) {
|
|
299
|
+
this._engine.restoreDefaultFramebuffer();
|
|
300
|
+
}
|
|
312
301
|
}
|
|
313
|
-
else {
|
|
302
|
+
else if (this._engine._currentRenderTarget !== renderTargetWrapper) {
|
|
314
303
|
if (this._engine._currentRenderTarget) {
|
|
315
304
|
this._engine.unBindFramebuffer(this._engine._currentRenderTarget);
|
|
316
305
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraphRenderContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderContext.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAE/E,MAAM,8BAA8B,GAAG;IACnC,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,yDAAyD;IAChE,KAAK,EAAE,wDAAwD;IAC/D,IAAI,EAAE,mEAAmE;IACzE,IAAI,EAAE,qCAAqC;IAC3C,IAAI,EAAE,oCAAoC;IAC1C,IAAI,EAAE,mCAAmC;IACzC,KAAK,EAA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AED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type {\r\n Nullable,\r\n AbstractEngine,\r\n DrawWrapper,\r\n IColor4Like,\r\n Layer,\r\n FrameGraphTextureHandle,\r\n Effect,\r\n FrameGraphTextureManager,\r\n ObjectRenderer,\r\n Scene,\r\n FrameGraphRenderTarget,\r\n InternalTexture,\r\n UtilityLayerRenderer,\r\n IStencilState,\r\n IStencilStateProperties,\r\n} from \"core/index\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer } from \"../Materials/effectRenderer\";\r\nimport { CopyTextureToTexture } from \"../Misc/copyTextureToTexture\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { IsDepthTexture } from \"../Materials/Textures/textureHelper.functions\";\r\n\r\nconst SamplingModeHasMipMapFiltering = [\r\n false, // not used\r\n false, // TEXTURE_NEAREST_SAMPLINGMODE / TEXTURE_NEAREST_NEAREST\r\n false, // TEXTURE_BILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR\r\n true, // TEXTURE_TRILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR_MIPLINEAR\r\n true, // TEXTURE_NEAREST_NEAREST_MIPNEAREST\r\n true, // TEXTURE_NEAREST_LINEAR_MIPNEAREST\r\n true, // TEXTURE_NEAREST_LINEAR_MIPLINEAR\r\n false, // TEXTURE_NEAREST_LINEAR\r\n true, // TEXTURE_NEAREST_NEAREST_MIPLINEAR\r\n true, // TEXTURE_LINEAR_NEAREST_MIPNEAREST\r\n true, // TEXTURE_LINEAR_NEAREST_MIPLINEAR\r\n true, // TEXTURE_LINEAR_LINEAR_MIPNEAREST\r\n false, // TEXTURE_LINEAR_NEAREST\r\n];\r\n\r\n/**\r\n * Frame graph context used render passes.\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderContext extends FrameGraphContext {\r\n private readonly _effectRenderer: EffectRenderer;\r\n private readonly _effectRendererBack: EffectRenderer;\r\n private _currentRenderTarget: FrameGraphRenderTarget | undefined;\r\n private _debugMessageWhenTargetBound: string | undefined;\r\n private _debugMessageHasBeenPushed = false;\r\n private _renderTargetIsBound = true;\r\n private readonly _copyTexture: CopyTextureToTexture;\r\n private readonly _copyDepthTexture: CopyTextureToTexture;\r\n\r\n private static _IsObjectRenderer(value: Layer | ObjectRenderer | UtilityLayerRenderer): value is ObjectRenderer {\r\n return (value as ObjectRenderer).initRender !== undefined;\r\n }\r\n\r\n /** @internal */\r\n constructor(engine: AbstractEngine, textureManager: FrameGraphTextureManager, scene: Scene) {\r\n super(engine, textureManager, scene);\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._effectRendererBack = new EffectRenderer(this._engine, {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 2, 1, 0, 3, 2],\r\n });\r\n this._copyTexture = new CopyTextureToTexture(this._engine);\r\n this._copyDepthTexture = new CopyTextureToTexture(this._engine, true);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color or depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color or depth texture, otherwise false\r\n */\r\n public isBackbuffer(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager._isBackbuffer(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color texture, otherwise false\r\n */\r\n public isBackbufferColor(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferColor(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's depth texture, otherwise false\r\n */\r\n public isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferDepthStencil(handle);\r\n }\r\n\r\n /**\r\n * Creates a (frame graph) render target wrapper\r\n * Note that renderTargets or renderTargetDepth can be undefined, but not both at the same time!\r\n * @param name Name of the render target wrapper\r\n * @param renderTargets Render target handles (textures) to use\r\n * @param renderTargetDepth Render target depth handle (texture) to use\r\n * @param depthReadOnly If true, the depth buffer will be read-only\r\n * @param stencilReadOnly If true, the stencil buffer will be read-only\r\n * @returns The created render target wrapper\r\n */\r\n public createRenderTarget(\r\n name: string,\r\n renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[],\r\n renderTargetDepth?: FrameGraphTextureHandle,\r\n depthReadOnly?: boolean,\r\n stencilReadOnly?: boolean\r\n ): FrameGraphRenderTarget {\r\n return this._textureManager.createRenderTarget(name, renderTargets, renderTargetDepth, depthReadOnly, stencilReadOnly);\r\n }\r\n\r\n /**\r\n * Clears the current render buffer or the current render target (if any is set up)\r\n * @param color Defines the color to use\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Clears the color attachments of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n */\r\n public clearColorAttachments(color: Nullable<IColor4Like>, attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, true, false, false);\r\n }\r\n\r\n /**\r\n * Clears all attachments (color(s) + depth/stencil) of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clearAttachments(color: Nullable<IColor4Like>, attachments: number[], backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Binds the attachments to the current render target\r\n * @param attachments The attachments to bind\r\n */\r\n public bindAttachments(attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n }\r\n\r\n /**\r\n * Generates mipmaps for the current render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._currentRenderTarget?.renderTargetWrapper === undefined) {\r\n return;\r\n }\r\n\r\n if (this._engine._currentRenderTarget && (!this._engine.isWebGPU || this._renderTargetIsBound)) {\r\n // we can't generate the mipmaps if the render target (which is the texture we want to generate mipmaps for) is bound\r\n // Also, for some reasons, on WebGL2, generating mipmaps doesn't work if a render target is bound, even if it's not the texture we want to generate mipmaps for...\r\n this._flushDebugMessages();\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n const textures = this._currentRenderTarget.renderTargetWrapper.textures;\r\n if (textures) {\r\n for (const texture of textures) {\r\n this._engine.generateMipmaps(texture);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the texture sampling mode for a given texture handle\r\n * @param handle Handle of the texture to set the sampling mode for\r\n * @param samplingMode Sampling mode to set\r\n */\r\n public setTextureSamplingMode(handle: FrameGraphTextureHandle, samplingMode: number): void {\r\n const internalTexture = this._textureManager.getTextureFromHandle(handle);\r\n if (internalTexture && internalTexture.samplingMode !== samplingMode) {\r\n internalTexture.useMipMaps = SamplingModeHasMipMapFiltering[samplingMode];\r\n this._engine.updateTextureSamplingMode(samplingMode, internalTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Binds a texture handle to a given effect (resolves the handle to a texture and binds it to the effect)\r\n * @param effect The effect to bind the texture to\r\n * @param name The name of the texture in the effect\r\n * @param handle The handle of the texture to bind\r\n */\r\n public bindTextureHandle(effect: Effect, name: string, handle: FrameGraphTextureHandle): void {\r\n let texture: Nullable<InternalTexture>;\r\n\r\n const historyEntry = this._textureManager._historyTextures.get(handle);\r\n if (historyEntry) {\r\n texture = historyEntry.textures[historyEntry.index]; // texture we write to in this frame\r\n if (\r\n this._currentRenderTarget !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper.textures!.includes(texture!)\r\n ) {\r\n // If the current render target renders to the history write texture, we bind the read texture instead\r\n texture = historyEntry.textures[historyEntry.index ^ 1];\r\n }\r\n } else {\r\n texture = this._textureManager._textures.get(handle)!.texture;\r\n }\r\n\r\n effect._bindTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Applies a full-screen effect to the current render target\r\n * @param drawWrapper The draw wrapper containing the effect to apply\r\n * @param customBindings The custom bindings to use when applying the effect (optional)\r\n * @param stencilState The stencil state to use when applying the effect (optional)\r\n * @param disableColorWrite If true, color write will be disabled when applying the effect (optional)\r\n * @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)\r\n * @param depthTest If true, depth testing will be enabled when applying the effect (default is false)\r\n * @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.\r\n * @returns True if the effect was applied, otherwise false (effect not ready)\r\n */\r\n public applyFullScreenEffect(\r\n drawWrapper: DrawWrapper,\r\n customBindings?: () => void,\r\n stencilState?: IStencilState | IStencilStateProperties,\r\n disableColorWrite?: boolean,\r\n drawBackFace?: boolean,\r\n depthTest?: boolean,\r\n noViewport?: boolean\r\n ): boolean {\r\n if (!drawWrapper.effect?.isReady()) {\r\n return false;\r\n }\r\n\r\n this._applyRenderTarget();\r\n\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n\r\n const effectRenderer = drawBackFace ? this._effectRendererBack : this._effectRenderer;\r\n\r\n effectRenderer.saveStates();\r\n if (!noViewport) {\r\n effectRenderer.setViewport();\r\n }\r\n\r\n this._engine.enableEffect(drawWrapper);\r\n this._engine.setState(false, undefined, undefined, undefined, undefined, stencilState);\r\n this._engine.setDepthBuffer(!!depthTest);\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(false);\r\n }\r\n this._engine.setDepthWrite(false);\r\n\r\n effectRenderer.bindBuffers(drawWrapper.effect);\r\n customBindings?.();\r\n effectRenderer.draw();\r\n effectRenderer.restoreStates();\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(true);\r\n }\r\n this._engine.setDepthWrite(engineDepthMask);\r\n if (engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Copies a texture to the current render target\r\n * @param sourceTexture The source texture to copy from\r\n * @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target\r\n * @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.\r\n * @param lodLevel The LOD level to use when copying the texture (default: 0).\r\n */\r\n public copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer = false, noViewport?: boolean, lodLevel = 0): void {\r\n if (forceCopyToBackbuffer) {\r\n this.bindRenderTarget();\r\n }\r\n\r\n const texture = this._textureManager.getTextureFromHandle(sourceTexture, true)!;\r\n const copyTexture = IsDepthTexture(texture.format) ? this._copyDepthTexture : this._copyTexture;\r\n\r\n copyTexture.source = texture;\r\n copyTexture.lodLevel = lodLevel;\r\n\r\n this.applyFullScreenEffect(\r\n copyTexture.effectWrapper.drawWrapper,\r\n () => {\r\n copyTexture.effectWrapper.onApplyObservable.notifyObservers({});\r\n },\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n noViewport\r\n );\r\n }\r\n\r\n /**\r\n * Renders a RenderTargetTexture or a layer\r\n * @param object The RenderTargetTexture/Layer to render\r\n * @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n * @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n */\r\n public render(object: Layer | ObjectRenderer | UtilityLayerRenderer, viewportWidth?: number, viewportHeight?: number): void {\r\n if (FrameGraphRenderContext._IsObjectRenderer(object)) {\r\n this._scene._intermediateRendering = true;\r\n if (object.shouldRender()) {\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this._applyRenderTarget();\r\n\r\n object.prepareRenderList();\r\n\r\n object.initRender(viewportWidth!, viewportHeight!);\r\n\r\n object.render();\r\n\r\n object.finishRender();\r\n }\r\n this._scene._intermediateRendering = false;\r\n } else {\r\n this._applyRenderTarget();\r\n object.render();\r\n }\r\n }\r\n\r\n /**\r\n * Binds a render target texture so that upcoming draw calls will render to it\r\n * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call\r\n * this method several times with different render targets without incurring the cost of binding if no draw calls are made\r\n * @param renderTarget The handle of the render target texture to bind (default: undefined, meaning \"back buffer\"). Pass an array for MRT rendering.\r\n * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)\r\n * @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).\r\n */\r\n public bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string, applyImmediately = false): void {\r\n if (\r\n (renderTarget?.renderTargetWrapper === undefined && this._currentRenderTarget === undefined) ||\r\n (renderTarget && this._currentRenderTarget && renderTarget.equals(this._currentRenderTarget))\r\n ) {\r\n this._flushDebugMessages();\r\n if (debugMessage !== undefined) {\r\n this.pushDebugGroup(debugMessage);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n if (applyImmediately) {\r\n this._applyRenderTarget();\r\n }\r\n return;\r\n }\r\n this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;\r\n this._debugMessageWhenTargetBound = debugMessage;\r\n this._renderTargetIsBound = false;\r\n if (applyImmediately) {\r\n this._applyRenderTarget();\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _flushDebugMessages() {\r\n if (this._debugMessageHasBeenPushed) {\r\n this.popDebugGroup();\r\n this._debugMessageHasBeenPushed = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _applyRenderTarget() {\r\n if (this._renderTargetIsBound) {\r\n return;\r\n }\r\n\r\n this._flushDebugMessages();\r\n\r\n const renderTargetWrapper = this._currentRenderTarget?.renderTargetWrapper;\r\n\r\n if (renderTargetWrapper === undefined) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n }\r\n this._engine.bindFramebuffer(renderTargetWrapper);\r\n }\r\n\r\n if (this._debugMessageWhenTargetBound !== undefined) {\r\n this.pushDebugGroup(this._debugMessageWhenTargetBound);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n\r\n this._renderTargetIsBound = true;\r\n }\r\n\r\n /** @internal */\r\n public _isReady(): boolean {\r\n return this._copyTexture.isReady() && this._copyDepthTexture.isReady();\r\n }\r\n\r\n /** @internal */\r\n public _dispose() {\r\n this._effectRenderer.dispose();\r\n this._effectRendererBack.dispose();\r\n this._copyTexture.dispose();\r\n this._copyDepthTexture.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraphRenderContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderContext.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE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AO,EAAE,CAAC;IAC3E,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type {\r\n Nullable,\r\n AbstractEngine,\r\n DrawWrapper,\r\n IColor4Like,\r\n Layer,\r\n FrameGraphTextureHandle,\r\n Effect,\r\n FrameGraphTextureManager,\r\n ObjectRenderer,\r\n Scene,\r\n FrameGraphRenderTarget,\r\n InternalTexture,\r\n UtilityLayerRenderer,\r\n IStencilState,\r\n IStencilStateProperties,\r\n} from \"core/index\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer } from \"../Materials/effectRenderer\";\r\nimport { CopyTextureToTexture } from \"../Misc/copyTextureToTexture\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { IsDepthTexture } from \"../Materials/Textures/textureHelper.functions\";\r\n\r\nconst SamplingModeHasMipMapFiltering = [\r\n false, // not used\r\n false, // TEXTURE_NEAREST_SAMPLINGMODE / TEXTURE_NEAREST_NEAREST\r\n false, // TEXTURE_BILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR\r\n true, // TEXTURE_TRILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR_MIPLINEAR\r\n true, // TEXTURE_NEAREST_NEAREST_MIPNEAREST\r\n true, // TEXTURE_NEAREST_LINEAR_MIPNEAREST\r\n true, // TEXTURE_NEAREST_LINEAR_MIPLINEAR\r\n false, // TEXTURE_NEAREST_LINEAR\r\n true, // TEXTURE_NEAREST_NEAREST_MIPLINEAR\r\n true, // TEXTURE_LINEAR_NEAREST_MIPNEAREST\r\n true, // TEXTURE_LINEAR_NEAREST_MIPLINEAR\r\n true, // TEXTURE_LINEAR_LINEAR_MIPNEAREST\r\n false, // TEXTURE_LINEAR_NEAREST\r\n];\r\n\r\n/**\r\n * Frame graph context used render passes.\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderContext extends FrameGraphContext {\r\n private readonly _effectRenderer: EffectRenderer;\r\n private readonly _effectRendererBack: EffectRenderer;\r\n private _currentRenderTarget: FrameGraphRenderTarget | undefined;\r\n private _debugMessageWhenTargetBound: string | undefined;\r\n private _debugMessageHasBeenPushed = false;\r\n private _renderTargetIsBound = true;\r\n private readonly _copyTexture: CopyTextureToTexture;\r\n private readonly _copyDepthTexture: CopyTextureToTexture;\r\n\r\n private static _IsObjectRenderer(value: Layer | ObjectRenderer | UtilityLayerRenderer): value is ObjectRenderer {\r\n return (value as ObjectRenderer).initRender !== undefined;\r\n }\r\n\r\n /** @internal */\r\n constructor(engine: AbstractEngine, textureManager: FrameGraphTextureManager, scene: Scene) {\r\n super(engine, textureManager, scene);\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._effectRendererBack = new EffectRenderer(this._engine, {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 2, 1, 0, 3, 2],\r\n });\r\n this._copyTexture = new CopyTextureToTexture(this._engine);\r\n this._copyDepthTexture = new CopyTextureToTexture(this._engine, true);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color or depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color or depth texture, otherwise false\r\n */\r\n public isBackbuffer(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager._isBackbuffer(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color texture, otherwise false\r\n */\r\n public isBackbufferColor(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferColor(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's depth texture, otherwise false\r\n */\r\n public isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferDepthStencil(handle);\r\n }\r\n\r\n /**\r\n * Creates a (frame graph) render target wrapper\r\n * Note that renderTargets or renderTargetDepth can be undefined, but not both at the same time!\r\n * @param name Name of the render target wrapper\r\n * @param renderTargets Render target handles (textures) to use\r\n * @param renderTargetDepth Render target depth handle (texture) to use\r\n * @param depthReadOnly If true, the depth buffer will be read-only\r\n * @param stencilReadOnly If true, the stencil buffer will be read-only\r\n * @returns The created render target wrapper\r\n */\r\n public createRenderTarget(\r\n name: string,\r\n renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[],\r\n renderTargetDepth?: FrameGraphTextureHandle,\r\n depthReadOnly?: boolean,\r\n stencilReadOnly?: boolean\r\n ): FrameGraphRenderTarget {\r\n return this._textureManager.createRenderTarget(name, renderTargets, renderTargetDepth, depthReadOnly, stencilReadOnly);\r\n }\r\n\r\n /**\r\n * Clears the current render buffer or the current render target (if any is set up)\r\n * @param color Defines the color to use\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Clears the color attachments of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n */\r\n public clearColorAttachments(color: Nullable<IColor4Like>, attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, true, false, false);\r\n }\r\n\r\n /**\r\n * Clears all attachments (color(s) + depth/stencil) of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)\r\n */\r\n public clearAttachments(color: Nullable<IColor4Like>, attachments: number[], backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue = 0): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);\r\n }\r\n\r\n /**\r\n * Binds the attachments to the current render target\r\n * @param attachments The attachments to bind\r\n */\r\n public bindAttachments(attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n }\r\n\r\n /**\r\n * Generates mipmaps for the current render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._currentRenderTarget?.renderTargetWrapper === undefined) {\r\n return;\r\n }\r\n\r\n if (this._engine._currentRenderTarget && (!this._engine.isWebGPU || this._renderTargetIsBound)) {\r\n // we can't generate the mipmaps if the render target (which is the texture we want to generate mipmaps for) is bound\r\n // Also, for some reasons, on WebGL2, generating mipmaps doesn't work if a render target is bound, even if it's not the texture we want to generate mipmaps for...\r\n this._flushDebugMessages();\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n const textures = this._currentRenderTarget.renderTargetWrapper.textures;\r\n if (textures) {\r\n for (const texture of textures) {\r\n this._engine.generateMipmaps(texture);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the texture sampling mode for a given texture handle\r\n * @param handle Handle of the texture to set the sampling mode for\r\n * @param samplingMode Sampling mode to set\r\n */\r\n public setTextureSamplingMode(handle: FrameGraphTextureHandle, samplingMode: number): void {\r\n const internalTexture = this._textureManager.getTextureFromHandle(handle);\r\n if (internalTexture && internalTexture.samplingMode !== samplingMode) {\r\n internalTexture.useMipMaps = SamplingModeHasMipMapFiltering[samplingMode];\r\n this._engine.updateTextureSamplingMode(samplingMode, internalTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Binds a texture handle to a given effect (resolves the handle to a texture and binds it to the effect)\r\n * @param effect The effect to bind the texture to\r\n * @param name The name of the texture in the effect\r\n * @param handle The handle of the texture to bind\r\n */\r\n public bindTextureHandle(effect: Effect, name: string, handle: FrameGraphTextureHandle): void {\r\n let texture: Nullable<InternalTexture>;\r\n\r\n const historyEntry = this._textureManager._historyTextures.get(handle);\r\n if (historyEntry) {\r\n texture = historyEntry.textures[historyEntry.index]; // texture we write to in this frame\r\n if (\r\n this._currentRenderTarget !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper !== undefined &&\r\n this._currentRenderTarget.renderTargetWrapper.textures!.includes(texture!)\r\n ) {\r\n // If the current render target renders to the history write texture, we bind the read texture instead\r\n texture = historyEntry.textures[historyEntry.index ^ 1];\r\n }\r\n } else {\r\n texture = this._textureManager._textures.get(handle)!.texture;\r\n }\r\n\r\n effect._bindTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Applies a full-screen effect to the current render target\r\n * @param drawWrapper The draw wrapper containing the effect to apply\r\n * @param customBindings The custom bindings to use when applying the effect (optional)\r\n * @param stencilState The stencil state to use when applying the effect (optional)\r\n * @param disableColorWrite If true, color write will be disabled when applying the effect (optional)\r\n * @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)\r\n * @param depthTest If true, depth testing will be enabled when applying the effect (default is false)\r\n * @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.\r\n * @returns True if the effect was applied, otherwise false (effect not ready)\r\n */\r\n public applyFullScreenEffect(\r\n drawWrapper: DrawWrapper,\r\n customBindings?: () => void,\r\n stencilState?: IStencilState | IStencilStateProperties,\r\n disableColorWrite?: boolean,\r\n drawBackFace?: boolean,\r\n depthTest?: boolean,\r\n noViewport?: boolean\r\n ): boolean {\r\n if (!drawWrapper.effect?.isReady()) {\r\n return false;\r\n }\r\n\r\n this._applyRenderTarget();\r\n\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n\r\n const effectRenderer = drawBackFace ? this._effectRendererBack : this._effectRenderer;\r\n\r\n effectRenderer.saveStates();\r\n if (!noViewport) {\r\n effectRenderer.setViewport();\r\n }\r\n\r\n this._engine.enableEffect(drawWrapper);\r\n this._engine.setState(false, undefined, undefined, undefined, undefined, stencilState);\r\n this._engine.setDepthBuffer(!!depthTest);\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(false);\r\n }\r\n this._engine.setDepthWrite(false);\r\n\r\n effectRenderer.bindBuffers(drawWrapper.effect);\r\n customBindings?.();\r\n effectRenderer.draw();\r\n effectRenderer.restoreStates();\r\n if (disableColorWrite) {\r\n this._engine.setColorWrite(true);\r\n }\r\n this._engine.setDepthWrite(engineDepthMask);\r\n if (engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Copies a texture to the current render target\r\n * @param sourceTexture The source texture to copy from\r\n * @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target\r\n * @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.\r\n * @param lodLevel The LOD level to use when copying the texture (default: 0).\r\n */\r\n public copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer = false, noViewport?: boolean, lodLevel = 0): void {\r\n if (forceCopyToBackbuffer) {\r\n this.bindRenderTarget();\r\n }\r\n\r\n const texture = this._textureManager.getTextureFromHandle(sourceTexture, true)!;\r\n const copyTexture = IsDepthTexture(texture.format) ? this._copyDepthTexture : this._copyTexture;\r\n\r\n copyTexture.source = texture;\r\n copyTexture.lodLevel = lodLevel;\r\n\r\n this.applyFullScreenEffect(\r\n copyTexture.effectWrapper.drawWrapper,\r\n () => {\r\n copyTexture.effectWrapper.onApplyObservable.notifyObservers({});\r\n },\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n noViewport\r\n );\r\n }\r\n\r\n /**\r\n * Renders a RenderTargetTexture or a layer\r\n * @param object The RenderTargetTexture/Layer to render\r\n * @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n * @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n */\r\n public render(object: Layer | ObjectRenderer | UtilityLayerRenderer, viewportWidth?: number, viewportHeight?: number): void {\r\n if (FrameGraphRenderContext._IsObjectRenderer(object)) {\r\n this._scene._intermediateRendering = true;\r\n if (object.shouldRender()) {\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this._applyRenderTarget();\r\n\r\n object.prepareRenderList();\r\n\r\n object.initRender(viewportWidth!, viewportHeight!);\r\n\r\n object.render();\r\n\r\n object.finishRender();\r\n }\r\n this._scene._intermediateRendering = false;\r\n } else {\r\n this._applyRenderTarget();\r\n object.render();\r\n }\r\n }\r\n\r\n /**\r\n * Binds a render target texture so that upcoming draw calls will render to it\r\n * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call\r\n * this method several times with different render targets without incurring the cost of binding if no draw calls are made\r\n * @param renderTarget The handle of the render target texture to bind (default: undefined, meaning \"back buffer\"). Pass an array for MRT rendering.\r\n * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)\r\n * @param applyImmediately If true, the render target will be applied immediately (otherwise it will be applied at first use). Default is false (delayed application).\r\n */\r\n public bindRenderTarget(renderTarget?: FrameGraphRenderTarget, debugMessage?: string, applyImmediately = false): void {\r\n this._currentRenderTarget = renderTarget?.renderTargetWrapper === undefined ? undefined : renderTarget;\r\n this._debugMessageWhenTargetBound = debugMessage;\r\n this._renderTargetIsBound = false;\r\n if (applyImmediately) {\r\n this._applyRenderTarget();\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _flushDebugMessages() {\r\n if (this._debugMessageHasBeenPushed) {\r\n this.popDebugGroup();\r\n this._debugMessageHasBeenPushed = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _applyRenderTarget() {\r\n if (this._renderTargetIsBound) {\r\n return;\r\n }\r\n\r\n this._flushDebugMessages();\r\n\r\n const renderTargetWrapper = this._currentRenderTarget?.renderTargetWrapper;\r\n\r\n if (renderTargetWrapper === undefined) {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.restoreDefaultFramebuffer();\r\n }\r\n } else if (this._engine._currentRenderTarget !== renderTargetWrapper) {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.unBindFramebuffer(this._engine._currentRenderTarget);\r\n }\r\n this._engine.bindFramebuffer(renderTargetWrapper);\r\n }\r\n\r\n if (this._debugMessageWhenTargetBound !== undefined) {\r\n this.pushDebugGroup(this._debugMessageWhenTargetBound);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n\r\n this._renderTargetIsBound = true;\r\n }\r\n\r\n /** @internal */\r\n public _isReady(): boolean {\r\n return this._copyTexture.isReady() && this._copyDepthTexture.isReady();\r\n }\r\n\r\n /** @internal */\r\n public _dispose() {\r\n this._effectRenderer.dispose();\r\n this._effectRendererBack.dispose();\r\n this._copyTexture.dispose();\r\n this._copyDepthTexture.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -21,11 +21,11 @@ export declare abstract class FrameGraphTask {
|
|
|
21
21
|
get disabled(): boolean;
|
|
22
22
|
set disabled(value: boolean);
|
|
23
23
|
/**
|
|
24
|
-
* Gets the
|
|
24
|
+
* Gets the passes of the task.
|
|
25
25
|
*/
|
|
26
26
|
get passes(): IFrameGraphPass[];
|
|
27
27
|
/**
|
|
28
|
-
* Gets the disabled
|
|
28
|
+
* Gets the disabled passes of the task.
|
|
29
29
|
*/
|
|
30
30
|
get passesDisabled(): IFrameGraphPass[];
|
|
31
31
|
/**
|
|
@@ -25,13 +25,13 @@ export class FrameGraphTask {
|
|
|
25
25
|
this._disabled = value;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Gets the
|
|
28
|
+
* Gets the passes of the task.
|
|
29
29
|
*/
|
|
30
30
|
get passes() {
|
|
31
31
|
return this._passes;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Gets the disabled
|
|
34
|
+
* Gets the disabled passes of the task.
|
|
35
35
|
*/
|
|
36
36
|
get passesDisabled() {
|
|
37
37
|
return this._passesDisabled;
|
|
@@ -186,23 +186,23 @@ export class FrameGraphTask {
|
|
|
186
186
|
_execute() {
|
|
187
187
|
const passes = this._disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;
|
|
188
188
|
this.onBeforeTaskExecute.notifyObservers(this);
|
|
189
|
-
this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`,
|
|
189
|
+
this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 1);
|
|
190
190
|
for (const pass of passes) {
|
|
191
191
|
pass._execute();
|
|
192
192
|
}
|
|
193
|
-
this._frameGraph.engine._debugPopGroup?.(
|
|
193
|
+
this._frameGraph.engine._debugPopGroup?.(1);
|
|
194
194
|
this.onAfterTaskExecute.notifyObservers(this);
|
|
195
195
|
}
|
|
196
196
|
/** @internal */
|
|
197
197
|
_initializePasses() {
|
|
198
|
-
this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`,
|
|
198
|
+
this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 1);
|
|
199
199
|
for (const pass of this._passes) {
|
|
200
200
|
pass._initialize();
|
|
201
201
|
}
|
|
202
202
|
for (const pass of this._passesDisabled) {
|
|
203
203
|
pass._initialize();
|
|
204
204
|
}
|
|
205
|
-
this._frameGraph.engine._debugPopGroup?.(
|
|
205
|
+
this._frameGraph.engine._debugPopGroup?.(1);
|
|
206
206
|
}
|
|
207
207
|
_checkSameRenderTarget(src, dst) {
|
|
208
208
|
if (src === null || dst === null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraphTask.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD;;;GAGG;AACH,MAAM,OAAgB,cAAc;IAUhC;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI,CAAC,KAAa;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAID;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAc;QAC9B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAaD;;;OAGG;IACI,YAAY;QACf,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,2FAA2F;IACpF,SAAS;QACZ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAiBD;;;OAGG;IACI,OAAO;QACV,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,6BAA6B,CAAC,KAAK,EAAE,CAAC;QAC3C,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,k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ameGraphTextureHandle, InternalTexture, FrameGraphRenderContext } from \"core/index\";\r\nimport { FrameGraphObjectListPass } from \"./Passes/objectListPass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\n/**\r\n * Represents a task in a frame graph.\r\n * @experimental\r\n */\r\nexport abstract class FrameGraphTask {\r\n protected readonly _frameGraph: FrameGraph;\r\n\r\n private readonly _passes: IFrameGraphPass[] = [];\r\n private readonly _passesDisabled: IFrameGraphPass[] = [];\r\n\r\n // Note: must be a getter/setter even if there's no specific processing, otherwise inherited classes can't make it a getter/setter!\r\n // Same thing for the disabled property\r\n protected _name: string;\r\n\r\n /**\r\n * The name of the task.\r\n */\r\n public get name() {\r\n return this._name;\r\n }\r\n\r\n public set name(value: string) {\r\n this._name = value;\r\n }\r\n\r\n protected _disabled = false;\r\n\r\n /**\r\n * Whether the task is disabled.\r\n */\r\n public get disabled() {\r\n return this._disabled;\r\n }\r\n\r\n public set disabled(value: boolean) {\r\n this._disabled = value;\r\n }\r\n\r\n /**\r\n * Gets the render passes of the task.\r\n */\r\n public get passes() {\r\n return this._passes;\r\n }\r\n\r\n /**\r\n * Gets the disabled render passes of the task.\r\n */\r\n public get passesDisabled() {\r\n return this._passesDisabled;\r\n }\r\n\r\n /**\r\n * The (texture) dependencies of the task (optional).\r\n */\r\n public dependencies?: Set<FrameGraphTextureHandle>;\r\n\r\n /**\r\n * Records the task in the frame graph. Use this function to add content (render passes, ...) to the task.\r\n * @param skipCreationOfDisabledPasses If true, the disabled passe(s) won't be created.\r\n */\r\n public abstract record(skipCreationOfDisabledPasses?: boolean): void;\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"FrameGraphTask\";\r\n }\r\n\r\n /**\r\n * This function is called once after the task has been added to the frame graph and before the frame graph is built for the first time.\r\n * This allows you to initialize asynchronous resources, which is not possible in the constructor.\r\n * @returns A promise that resolves when the initialization is complete.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public initAsync(): Promise<unknown> {\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * An observable that is triggered after the textures have been allocated.\r\n */\r\n public onTexturesAllocatedObservable: Observable<FrameGraphRenderContext> = new Observable();\r\n\r\n /**\r\n * An observable that is triggered before the task is executed.\r\n */\r\n public onBeforeTaskExecute: Observable<FrameGraphTask> = new Observable();\r\n\r\n /**\r\n * An observable that is triggered after the task is executed.\r\n */\r\n public onAfterTaskExecute: Observable<FrameGraphTask> = new Observable();\r\n\r\n /**\r\n * Checks if the task is ready to be executed.\r\n * @returns True if the task is ready to be executed, else false.\r\n */\r\n public isReady(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes of the task.\r\n */\r\n public dispose() {\r\n this._reset();\r\n this.onTexturesAllocatedObservable.clear();\r\n this.onBeforeTaskExecute.clear();\r\n this.onAfterTaskExecute.clear();\r\n }\r\n\r\n /**\r\n * Constructs a new frame graph task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n this.name = name;\r\n this._frameGraph = frameGraph;\r\n this._reset();\r\n }\r\n\r\n /** @internal */\r\n public _reset() {\r\n for (const pass of this._passes) {\r\n pass._dispose();\r\n }\r\n for (const pass of this._passesDisabled) {\r\n pass._dispose();\r\n }\r\n this._passes.length = 0;\r\n this._passesDisabled.length = 0;\r\n }\r\n\r\n /** @internal */\r\n public _addPass(pass: IFrameGraphPass, disabled: boolean) {\r\n if (disabled) {\r\n this._passesDisabled.push(pass);\r\n } else {\r\n this._passes.push(pass);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _checkTask() {\r\n let outputTexture: Nullable<Nullable<InternalTexture>[]> = null;\r\n let outputDepthTexture: Nullable<InternalTexture> = null;\r\n let outputObjectList: FrameGraphObjectList | undefined;\r\n\r\n for (const pass of this._passes) {\r\n const errMsg = pass._isValid();\r\n if (errMsg) {\r\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\r\n }\r\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\r\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\r\n outputTexture = [];\r\n for (const handle of handles) {\r\n if (handle !== undefined) {\r\n outputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\r\n }\r\n }\r\n outputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\r\n } else if (FrameGraphObjectListPass.IsObjectListPass(pass)) {\r\n outputObjectList = pass.objectList;\r\n }\r\n }\r\n\r\n let disabledOutputTexture: Nullable<Nullable<InternalTexture>[]> = null;\r\n let disabledOutputTextureHandle: (FrameGraphTextureHandle | undefined)[] = [];\r\n let disabledOutputDepthTexture: Nullable<InternalTexture> = null;\r\n let disabledOutputObjectList: FrameGraphObjectList | undefined;\r\n\r\n for (const pass of this._passesDisabled) {\r\n const errMsg = pass._isValid();\r\n if (errMsg) {\r\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\r\n }\r\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\r\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\r\n disabledOutputTexture = [];\r\n for (const handle of handles) {\r\n if (handle !== undefined) {\r\n disabledOutputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\r\n }\r\n }\r\n disabledOutputTextureHandle = handles;\r\n disabledOutputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\r\n } else if (FrameGraphObjectListPass.IsObjectListPass(pass)) {\r\n disabledOutputObjectList = pass.objectList;\r\n }\r\n }\r\n\r\n if (this._passesDisabled.length > 0) {\r\n if (!this._checkSameRenderTarget(outputTexture, disabledOutputTexture)) {\r\n let ok = true;\r\n for (const handle of disabledOutputTextureHandle) {\r\n if (handle !== undefined && !this._frameGraph.textureManager.isHistoryTexture(handle)) {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n if (!ok) {\r\n throw new Error(`The output texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n }\r\n if (outputDepthTexture !== disabledOutputDepthTexture && disabledOutputDepthTexture !== null) {\r\n throw new Error(`The output depth texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n if (outputObjectList !== disabledOutputObjectList && disabledOutputObjectList !== null) {\r\n throw new Error(`The output object list of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _execute() {\r\n const passes = this._disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;\r\n\r\n this.onBeforeTaskExecute.notifyObservers(this);\r\n\r\n this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 2);\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n\r\n this._frameGraph.engine._debugPopGroup?.(2);\r\n\r\n this.onAfterTaskExecute.notifyObservers(this);\r\n }\r\n\r\n /** @internal */\r\n public _initializePasses() {\r\n this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 2);\r\n\r\n for (const pass of this._passes) {\r\n pass._initialize();\r\n }\r\n\r\n for (const pass of this._passesDisabled) {\r\n pass._initialize();\r\n }\r\n\r\n this._frameGraph.engine._debugPopGroup?.(2);\r\n }\r\n\r\n private _checkSameRenderTarget(src: Nullable<Nullable<InternalTexture>[]>, dst: Nullable<Nullable<InternalTexture>[]>) {\r\n if (src === null || dst === null) {\r\n return src === dst;\r\n }\r\n\r\n if (src.length !== dst.length) {\r\n return false;\r\n }\r\n\r\n for (let i = 0; i < src.length; i++) {\r\n if (src[i] !== dst[i]) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraphTask.js","sourceRoot":"","s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AkB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,gBAAgB;IACT,iBAAiB;QACpB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;QAEtF,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACtC,IAAI,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IAEO,sBAAsB,CAAC,GAA0C,EAAE,GAA0C;QACjH,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC/B,OAAO,GAAG,KAAK,GAAG,CAAC;QACvB,CAAC;QAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphObjectList, IFrameGraphPass, Nullable, FrameGraphTextureHandle, InternalTexture, FrameGraphRenderContext } from \"core/index\";\r\nimport { FrameGraphObjectListPass } from \"./Passes/objectListPass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\n/**\r\n * Represents a task in a frame graph.\r\n * @experimental\r\n */\r\nexport abstract class FrameGraphTask {\r\n protected readonly _frameGraph: FrameGraph;\r\n\r\n private readonly _passes: IFrameGraphPass[] = [];\r\n private readonly _passesDisabled: IFrameGraphPass[] = [];\r\n\r\n // Note: must be a getter/setter even if there's no specific processing, otherwise inherited classes can't make it a getter/setter!\r\n // Same thing for the disabled property\r\n protected _name: string;\r\n\r\n /**\r\n * The name of the task.\r\n */\r\n public get name() {\r\n return this._name;\r\n }\r\n\r\n public set name(value: string) {\r\n this._name = value;\r\n }\r\n\r\n protected _disabled = false;\r\n\r\n /**\r\n * Whether the task is disabled.\r\n */\r\n public get disabled() {\r\n return this._disabled;\r\n }\r\n\r\n public set disabled(value: boolean) {\r\n this._disabled = value;\r\n }\r\n\r\n /**\r\n * Gets the passes of the task.\r\n */\r\n public get passes() {\r\n return this._passes;\r\n }\r\n\r\n /**\r\n * Gets the disabled passes of the task.\r\n */\r\n public get passesDisabled() {\r\n return this._passesDisabled;\r\n }\r\n\r\n /**\r\n * The (texture) dependencies of the task (optional).\r\n */\r\n public dependencies?: Set<FrameGraphTextureHandle>;\r\n\r\n /**\r\n * Records the task in the frame graph. Use this function to add content (render passes, ...) to the task.\r\n * @param skipCreationOfDisabledPasses If true, the disabled passe(s) won't be created.\r\n */\r\n public abstract record(skipCreationOfDisabledPasses?: boolean): void;\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"FrameGraphTask\";\r\n }\r\n\r\n /**\r\n * This function is called once after the task has been added to the frame graph and before the frame graph is built for the first time.\r\n * This allows you to initialize asynchronous resources, which is not possible in the constructor.\r\n * @returns A promise that resolves when the initialization is complete.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public initAsync(): Promise<unknown> {\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * An observable that is triggered after the textures have been allocated.\r\n */\r\n public onTexturesAllocatedObservable: Observable<FrameGraphRenderContext> = new Observable();\r\n\r\n /**\r\n * An observable that is triggered before the task is executed.\r\n */\r\n public onBeforeTaskExecute: Observable<FrameGraphTask> = new Observable();\r\n\r\n /**\r\n * An observable that is triggered after the task is executed.\r\n */\r\n public onAfterTaskExecute: Observable<FrameGraphTask> = new Observable();\r\n\r\n /**\r\n * Checks if the task is ready to be executed.\r\n * @returns True if the task is ready to be executed, else false.\r\n */\r\n public isReady(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes of the task.\r\n */\r\n public dispose() {\r\n this._reset();\r\n this.onTexturesAllocatedObservable.clear();\r\n this.onBeforeTaskExecute.clear();\r\n this.onAfterTaskExecute.clear();\r\n }\r\n\r\n /**\r\n * Constructs a new frame graph task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n this.name = name;\r\n this._frameGraph = frameGraph;\r\n this._reset();\r\n }\r\n\r\n /** @internal */\r\n public _reset() {\r\n for (const pass of this._passes) {\r\n pass._dispose();\r\n }\r\n for (const pass of this._passesDisabled) {\r\n pass._dispose();\r\n }\r\n this._passes.length = 0;\r\n this._passesDisabled.length = 0;\r\n }\r\n\r\n /** @internal */\r\n public _addPass(pass: IFrameGraphPass, disabled: boolean) {\r\n if (disabled) {\r\n this._passesDisabled.push(pass);\r\n } else {\r\n this._passes.push(pass);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _checkTask() {\r\n let outputTexture: Nullable<Nullable<InternalTexture>[]> = null;\r\n let outputDepthTexture: Nullable<InternalTexture> = null;\r\n let outputObjectList: FrameGraphObjectList | undefined;\r\n\r\n for (const pass of this._passes) {\r\n const errMsg = pass._isValid();\r\n if (errMsg) {\r\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\r\n }\r\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\r\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\r\n outputTexture = [];\r\n for (const handle of handles) {\r\n if (handle !== undefined) {\r\n outputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\r\n }\r\n }\r\n outputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\r\n } else if (FrameGraphObjectListPass.IsObjectListPass(pass)) {\r\n outputObjectList = pass.objectList;\r\n }\r\n }\r\n\r\n let disabledOutputTexture: Nullable<Nullable<InternalTexture>[]> = null;\r\n let disabledOutputTextureHandle: (FrameGraphTextureHandle | undefined)[] = [];\r\n let disabledOutputDepthTexture: Nullable<InternalTexture> = null;\r\n let disabledOutputObjectList: FrameGraphObjectList | undefined;\r\n\r\n for (const pass of this._passesDisabled) {\r\n const errMsg = pass._isValid();\r\n if (errMsg) {\r\n throw new Error(`Pass \"${pass.name}\" is not valid. ${errMsg}`);\r\n }\r\n if (FrameGraphRenderPass.IsRenderPass(pass)) {\r\n const handles = Array.isArray(pass.renderTarget) ? pass.renderTarget : [pass.renderTarget];\r\n disabledOutputTexture = [];\r\n for (const handle of handles) {\r\n if (handle !== undefined) {\r\n disabledOutputTexture.push(this._frameGraph.textureManager.getTextureFromHandle(handle));\r\n }\r\n }\r\n disabledOutputTextureHandle = handles;\r\n disabledOutputDepthTexture = pass.renderTargetDepth !== undefined ? this._frameGraph.textureManager.getTextureFromHandle(pass.renderTargetDepth) : null;\r\n } else if (FrameGraphObjectListPass.IsObjectListPass(pass)) {\r\n disabledOutputObjectList = pass.objectList;\r\n }\r\n }\r\n\r\n if (this._passesDisabled.length > 0) {\r\n if (!this._checkSameRenderTarget(outputTexture, disabledOutputTexture)) {\r\n let ok = true;\r\n for (const handle of disabledOutputTextureHandle) {\r\n if (handle !== undefined && !this._frameGraph.textureManager.isHistoryTexture(handle)) {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n if (!ok) {\r\n throw new Error(`The output texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n }\r\n if (outputDepthTexture !== disabledOutputDepthTexture && disabledOutputDepthTexture !== null) {\r\n throw new Error(`The output depth texture of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n if (outputObjectList !== disabledOutputObjectList && disabledOutputObjectList !== null) {\r\n throw new Error(`The output object list of the task \"${this.name}\" is different when it is enabled or disabled.`);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _execute() {\r\n const passes = this._disabled && this._passesDisabled.length > 0 ? this._passesDisabled : this._passes;\r\n\r\n this.onBeforeTaskExecute.notifyObservers(this);\r\n\r\n this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 1);\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n\r\n this._frameGraph.engine._debugPopGroup?.(1);\r\n\r\n this.onAfterTaskExecute.notifyObservers(this);\r\n }\r\n\r\n /** @internal */\r\n public _initializePasses() {\r\n this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`, 1);\r\n\r\n for (const pass of this._passes) {\r\n pass._initialize();\r\n }\r\n\r\n for (const pass of this._passesDisabled) {\r\n pass._initialize();\r\n }\r\n\r\n this._frameGraph.engine._debugPopGroup?.(1);\r\n }\r\n\r\n private _checkSameRenderTarget(src: Nullable<Nullable<InternalTexture>[]>, dst: Nullable<Nullable<InternalTexture>[]>) {\r\n if (src === null || dst === null) {\r\n return src === dst;\r\n }\r\n\r\n if (src.length !== dst.length) {\r\n return false;\r\n }\r\n\r\n for (let i = 0; i < src.length; i++) {\r\n if (src[i] !== dst[i]) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FrameGraphRenderPass, LayerAndFaceIndex } from "../index.js";
|
|
2
|
+
import { FrameGraphTask } from "./frameGraphTask.js";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for frame graph tasks that involve multi-target rendering.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class FrameGraphTaskMultiRenderTarget extends FrameGraphTask {
|
|
7
|
+
private _outputLayerAndFaceIndices;
|
|
8
|
+
private _layerAndFaceIndicesUpdated;
|
|
9
|
+
/**
|
|
10
|
+
* Sets the output layer and face indices for multi-target rendering.
|
|
11
|
+
* @param indices The array of layer and face indices.
|
|
12
|
+
*/
|
|
13
|
+
setOutputLayerAndFaceIndices(indices: LayerAndFaceIndex[]): void;
|
|
14
|
+
protected _updateLayerAndFaceIndices(pass: FrameGraphRenderPass): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FrameGraphTask } from "./frameGraphTask.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for frame graph tasks that involve multi-target rendering.
|
|
4
|
+
*/
|
|
5
|
+
export class FrameGraphTaskMultiRenderTarget extends FrameGraphTask {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this._layerAndFaceIndicesUpdated = false;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sets the output layer and face indices for multi-target rendering.
|
|
12
|
+
* @param indices The array of layer and face indices.
|
|
13
|
+
*/
|
|
14
|
+
setOutputLayerAndFaceIndices(indices) {
|
|
15
|
+
this._outputLayerAndFaceIndices = indices;
|
|
16
|
+
this._layerAndFaceIndicesUpdated = indices.length > 0;
|
|
17
|
+
}
|
|
18
|
+
_updateLayerAndFaceIndices(pass) {
|
|
19
|
+
if (this._layerAndFaceIndicesUpdated) {
|
|
20
|
+
pass.setOutputLayerAndFaceIndices(this._outputLayerAndFaceIndices);
|
|
21
|
+
this._layerAndFaceIndicesUpdated = false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=frameGraphTaskMultiRenderTarget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameGraphTaskMultiRenderTarget.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphTaskMultiRenderTarget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAgB,+BAAgC,SAAQ,cAAc;IAA5E;;QAEY,gCAA2B,GAAG,KAAK,CAAC;IAiBhD,CAAC;IAfG;;;OAGG;IACI,4BAA4B,CAAC,OAA4B;QAC5D,IAAI,CAAC,0BAA0B,GAAG,OAAO,CAAC;QAC1C,IAAI,CAAC,2BAA2B,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1D,CAAC;IAES,0BAA0B,CAAC,IAA0B;QAC3D,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACnC,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACnE,IAAI,CAAC,2BAA2B,GAAG,KAAK,CAAC;QAC7C,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { FrameGraphRenderPass, LayerAndFaceIndex } from \"core/index\";\r\nimport { FrameGraphTask } from \"./frameGraphTask\";\r\n\r\n/**\r\n * Base class for frame graph tasks that involve multi-target rendering.\r\n */\r\nexport abstract class FrameGraphTaskMultiRenderTarget extends FrameGraphTask {\r\n private _outputLayerAndFaceIndices: LayerAndFaceIndex[];\r\n private _layerAndFaceIndicesUpdated = false;\r\n\r\n /**\r\n * Sets the output layer and face indices for multi-target rendering.\r\n * @param indices The array of layer and face indices.\r\n */\r\n public setOutputLayerAndFaceIndices(indices: LayerAndFaceIndex[]) {\r\n this._outputLayerAndFaceIndices = indices;\r\n this._layerAndFaceIndicesUpdated = indices.length > 0;\r\n }\r\n\r\n protected _updateLayerAndFaceIndices(pass: FrameGraphRenderPass) {\r\n if (this._layerAndFaceIndicesUpdated) {\r\n pass.setOutputLayerAndFaceIndices(this._outputLayerAndFaceIndices);\r\n this._layerAndFaceIndicesUpdated = false;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -506,8 +506,12 @@ export class FrameGraphTextureManager {
|
|
|
506
506
|
}
|
|
507
507
|
else {
|
|
508
508
|
const creationOptions = entry.creationOptions;
|
|
509
|
-
const size = creationOptions.sizeIsPercentage ? this.getAbsoluteDimensions(creationOptions.size) : creationOptions.size;
|
|
509
|
+
const size = getDimensionsFromTextureSize(creationOptions.sizeIsPercentage ? this.getAbsoluteDimensions(creationOptions.size) : creationOptions.size);
|
|
510
510
|
const textureIndex = entry.textureIndex || 0;
|
|
511
|
+
const targetType = creationOptions.options.targetTypes?.[textureIndex] ?? 3553;
|
|
512
|
+
const is3D = targetType === 32879;
|
|
513
|
+
const isArray = targetType === 35866 || targetType === 3735928559;
|
|
514
|
+
const layerCount = creationOptions.options.layerCounts?.[textureIndex] ?? 0;
|
|
511
515
|
const internalTextureCreationOptions = {
|
|
512
516
|
createMipMaps: creationOptions.options.createMipMaps,
|
|
513
517
|
samples: creationOptions.options.samples,
|
|
@@ -518,6 +522,7 @@ export class FrameGraphTextureManager {
|
|
|
518
522
|
label: creationOptions.options.labels?.[textureIndex] ?? `${entry.name}${textureIndex > 0 ? "#" + textureIndex : ""}`,
|
|
519
523
|
samplingMode: 1,
|
|
520
524
|
createMSAATexture: creationOptions.options.samples > 1,
|
|
525
|
+
isCube: targetType === 34067 || targetType === 3735928559,
|
|
521
526
|
};
|
|
522
527
|
const isDepthTexture = IsDepthTexture(internalTextureCreationOptions.format);
|
|
523
528
|
const hasStencil = HasStencilAspect(internalTextureCreationOptions.format);
|
|
@@ -526,7 +531,7 @@ export class FrameGraphTextureManager {
|
|
|
526
531
|
: isDepthTexture || hasStencil
|
|
527
532
|
? 14 /* InternalTextureSource.Depth */
|
|
528
533
|
: 5 /* InternalTextureSource.RenderTarget */;
|
|
529
|
-
const internalTexture = this.engine._createInternalTexture(size, internalTextureCreationOptions, false, source);
|
|
534
|
+
const internalTexture = this.engine._createInternalTexture({ width: size.width, height: size.height, depth: is3D ? layerCount : undefined, layers: isArray ? layerCount : undefined }, internalTextureCreationOptions, false, source);
|
|
530
535
|
if (isDepthTexture) {
|
|
531
536
|
internalTexture.type = GetTypeForDepthTexture(internalTexture.format);
|
|
532
537
|
}
|
|
@@ -711,8 +716,10 @@ export class FrameGraphTextureManager {
|
|
|
711
716
|
hash.push(options.sizeIsPercentage ? "%" : "A");
|
|
712
717
|
hash.push(options.options.createMipMaps ? "M" : "N");
|
|
713
718
|
hash.push(options.options.samples ? `${options.options.samples}` : "S1");
|
|
719
|
+
hash.push(options.options.targetTypes ? options.options.targetTypes.join("_") : `${3553}`);
|
|
714
720
|
hash.push(options.options.types ? options.options.types.join("_") : `${0}`);
|
|
715
721
|
hash.push(options.options.formats ? options.options.formats.join("_") : `${5}`);
|
|
722
|
+
hash.push(options.options.layerCounts ? options.options.layerCounts.join("_") : `0`);
|
|
716
723
|
hash.push(options.options.useSRGBBuffers ? options.options.useSRGBBuffers.join("_") : "false");
|
|
717
724
|
hash.push(options.options.creationFlags ? options.options.creationFlags.join("_") : "0");
|
|
718
725
|
return hash.join("_");
|
|
@@ -852,8 +859,10 @@ export class FrameGraphTextureManager {
|
|
|
852
859
|
? {
|
|
853
860
|
createMipMaps: options.createMipMaps,
|
|
854
861
|
samples: options.samples,
|
|
862
|
+
targetTypes: options.targetTypes ? [options.targetTypes[textureIndex]] : undefined,
|
|
855
863
|
types: options.types ? [options.types[textureIndex]] : undefined,
|
|
856
864
|
formats: options.formats ? [options.formats[textureIndex]] : undefined,
|
|
865
|
+
layerCounts: options.layerCounts ? [options.layerCounts[textureIndex]] : undefined,
|
|
857
866
|
useSRGBBuffers: options.useSRGBBuffers ? [options.useSRGBBuffers[textureIndex]] : undefined,
|
|
858
867
|
creationFlags: options.creationFlags ? [options.creationFlags[textureIndex]] : undefined,
|
|
859
868
|
labels: options.labels ? [options.labels[textureIndex]] : undefined,
|
|
@@ -861,8 +870,10 @@ export class FrameGraphTextureManager {
|
|
|
861
870
|
: {
|
|
862
871
|
createMipMaps: options.createMipMaps,
|
|
863
872
|
samples: options.samples,
|
|
873
|
+
targetTypes: options.targetTypes ? [...options.targetTypes] : undefined,
|
|
864
874
|
types: options.types ? [...options.types] : undefined,
|
|
865
875
|
formats: options.formats ? [...options.formats] : undefined,
|
|
876
|
+
layerCounts: options.layerCounts ? [...options.layerCounts] : undefined,
|
|
866
877
|
useSRGBBuffers: options.useSRGBBuffers ? [...options.useSRGBBuffers] : undefined,
|
|
867
878
|
creationFlags: options.creationFlags ? [...options.creationFlags] : undefined,
|
|
868
879
|
labels: options.labels && preserveLabels ? [...options.labels] : undefined,
|