{"record":{"id":"5b38a66670b1fc10","repo":"BabylonJS/Babylon.js","slug":"classname-this-name-the-depth-texture-de","errorCode":null,"errorMessage":"${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","messagePattern":"(.+?) (.+?): the depth texture \"(.+?)\" \\((.+?) samples\\) and the output texture \"(.+?)\" \\((.+?) samples\\) must have the same number of samples","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts","lineNumber":556,"sourceCode":"    }\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\n            depthEnabled = true;\r\n        }\r\n\r\n        this._textureWidth = outputTextureDescription?.size.width ?? 1;\r\n        this._textureHeight = outputTextureDescription?.size.height ?? 1;\r\n\r\n        return depthEnabled;\r\n    }\r","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts#L538-L574","documentation":"MSAA consistency check: the depth texture and the output/target texture must declare the same number of samples. Mixing a multisampled depth texture with a non-multisampled color target (or vice versa) is invalid for a render pass, so _checkTextureCompatibility throws with both textures' labels and sample counts in the message.","triggerScenarios":"task.depthTexture.options.samples differs from target texture's samples — e.g. depth created with samples=4 while targetTexture is samples=1 (or undefined samples), checked during record() via depthEnabled/_checkTextureCompatibility.","commonSituations":"Enabling MSAA on one resource but not the other; hardware-driven default samples on the back buffer differing from a hand-made depth texture; refactors that change samples on only one texture creation options object.","solutions":["Recreate the depth texture with the same samples value as the target texture (or vice versa).","Read the target texture's description (frameGraph.textureManager.getTextureDescription) and match depthTexture creation options.samples to it.","If you don't need MSAA, set samples to 1 on both textures."],"exampleFix":"// before\nconst depth = frameGraph.createDepthStencilTexture('depth', { samples: 4 });\ntask.targetTexture = colorTexture; // samples: 1\n\n// after\nconst depth = frameGraph.createDepthStencilTexture('depth', { samples: 1 }); // match target samples\ntask.targetTexture = colorTexture;","handlingStrategy":"validation","validationCode":"const targetDesc = frameGraph.textureManager.getTextureDescription(targetHandle);\nconst depthDesc = frameGraph.textureManager.getTextureDescription(depthHandle);\nif ((depthDesc.options.samples ?? 1) !== (targetDesc.options.samples ?? 1)) {\n    throw new Error('Depth and target samples must match');\n}","typeGuard":null,"tryCatchPattern":"try {\n    frameGraph.build();\n} catch (e) {\n    if (String(e).includes('must have the same number of samples')) {\n        // recreate depth texture matching target samples, then rebuild\n    } else throw e;\n}","preventionTips":["Always create depth textures with samples copied from the target texture description.","Centralize MSAA sample count in one constant used by every texture creation.","Check back-buffer samples (can be device-dependent) before assuming samples:1."],"tags":["babylonjs","frame-graph","msaa","depth-texture","samples-mismatch"],"backgroundTag":"msaa-sample-count-mismatch","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}