{"record":{"id":"0ea32c24024b65f7","repo":"BabylonJS/Babylon.js","slug":"classname-this-name-the-back-buffer-depth-s","errorCode":null,"errorMessage":"${className} ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the target is the back buffer color","messagePattern":"(.+?) (.+?): the back buffer depth/stencil texture is the only depth texture allowed when the target is the back buffer color","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts","lineNumber":548,"sourceCode":"            this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n        }\r\n    }\r\n\r\n    protected _checkParameters() {\r\n        if (this.targetTexture === undefined || this.objectList === undefined || this.camera === undefined) {\r\n            throw new Error(`FrameGraphObjectRendererTask ${this.name}: targetTexture, objectList, and camera are required`);\r\n        }\r\n    }\r\n\r\n    protected _checkTextureCompatibility(targetTextures: FrameGraphTextureHandle[]): boolean {\r\n        const className = this.getClassName();\r\n\r\n        let outputTextureDescription = targetTextures.length > 0 ? this._frameGraph.textureManager.getTextureDescription(targetTextures[0]) : null;\r\n        let depthEnabled = false;\r\n\r\n        if (this.depthTexture !== undefined) {\r\n            if (outputTextureDescription && this.depthTexture !== backbufferDepthStencilTextureHandle && targetTextures[0] === backbufferColorTextureHandle) {\r\n                throw new Error(`${className} ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the target is the back buffer color`);\r\n            }\r\n\r\n            const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n            if (!outputTextureDescription) {\r\n                outputTextureDescription = depthTextureDescription;\r\n            }\r\n            if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n                throw new Error(\r\n                    `${className} ${this.name}: the depth texture \"${depthTextureDescription.options.labels?.[0] ?? \"noname\"}\" (${depthTextureDescription.options.samples} samples) and the output texture \"${outputTextureDescription.options.labels?.[0] ?? \"noname\"}\" (${outputTextureDescription.options.samples} samples) must have the same number of samples`\r\n                );\r\n            }\r\n\r\n            if (depthTextureDescription.size.width !== outputTextureDescription.size.width || depthTextureDescription.size.height !== outputTextureDescription.size.height) {\r\n                throw new Error(\r\n                    `${className} ${this.name}: the depth texture (size: ${depthTextureDescription.size.width}x${depthTextureDescription.size.height}) and the target texture (size: ${outputTextureDescription.size.width}x${outputTextureDescription.size.height}) must have the same dimensions.`\r\n                );\r\n            }\r\n\r","sourceCodeStart":530,"sourceCodeEnd":566,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts#L530-L566","documentation":"When an ObjectRendererTask renders directly to the frame graph's back buffer color texture, the only depth attachment permitted is the back buffer's own depth/stencil texture. Supplying any custom depthTexture would conflict with the back buffer's depth, so _checkTextureCompatibility throws.","triggerScenarios":"Setting task.depthTexture to a custom depth texture (any handle other than the back buffer depth/stencil handle) while task.targetTexture equals the back buffer color texture handle.","commonSituations":"Reusing depth texture configuration from an offscreen-target task and switching targetTexture to the back buffer; assuming custom depth works with back-buffer rendering; sharing one task definition between window and texture targets.","solutions":["Either remove the custom depthTexture so the back buffer's own depth/stencil is used, or","Render to a non-back-buffer target texture when a custom depth texture is needed.","If back-buffer depth is available as a handle, set depthTexture to the back buffer depth/stencil handle instead of a custom one."],"exampleFix":"// before\ntask.targetTexture = frameGraph.backBufferColorTexture;\ntask.depthTexture = myCustomDepthTexture; // not allowed\n\n// after\ntask.targetTexture = frameGraph.backBufferColorTexture;\ntask.depthTexture = undefined; // use back buffer depth/stencil","handlingStrategy":"validation","validationCode":"if (task.targetTexture === frameGraph.backBufferColorTexture.handle && task.depthTexture !== undefined && task.depthTexture !== frameGraph.backBufferDepthStencilTexture.handle) {\n    throw new Error('Custom depth not allowed when targeting back buffer color');\n}","typeGuard":null,"tryCatchPattern":"try {\n    frameGraph.build();\n} catch (e) {\n    if (String(e).includes('back buffer depth/stencil texture is the only depth texture allowed')) {\n        task.depthTexture = undefined; // fall back to back buffer depth\n        frameGraph.build();\n    } else throw e;\n}","preventionTips":["Decide up front whether a task targets the back buffer or an offscreen texture; configure depth accordingly.","Do not share one task configuration between back-buffer and offscreen targets.","When targeting the back buffer, omit depthTexture entirely unless you specifically need the back buffer depth handle."],"tags":["babylonjs","frame-graph","depth-texture","back-buffer","incompatible-configuration"],"backgroundTag":"incompatible-depth-attachment","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}