{"record":{"id":"9cbb4017c9325b3a","repo":"stride3d/stride","slug":"unsupported-depth-format-texturedescription-format-for-the","errorCode":null,"errorMessage":"Unsupported Depth Format [{textureDescription.Format}] for the Depth-Stencil Buffer","messagePattern":"Unsupported Depth Format \\[(.+?)\\] for the Depth-Stencil Buffer","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs","lineNumber":996,"sourceCode":"            if (needsTypelessDepth)\n            {\n                if (IsShaderResource && GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0)\n                {\n                    throw new NotSupportedException($\"Shader Resource Views for Depth-Stencil Textures are not supported for Graphics profile < 10.0 (Current: [{GraphicsDevice.Features.CurrentProfile}])\");\n                }\n                else\n                {\n                    // Determine a typeless format and a Shader Resource View Format\n                    if (GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0)\n                    {\n                        format = textureDescription.Format switch\n                        {\n                            PixelFormat.D16_UNorm => Silk.NET.DXGI.Format.FormatD16Unorm,\n                            PixelFormat.D32_Float => Silk.NET.DXGI.Format.FormatD32Float,\n                            PixelFormat.D24_UNorm_S8_UInt => Silk.NET.DXGI.Format.FormatD24UnormS8Uint,\n                            PixelFormat.D32_Float_S8X24_UInt => Silk.NET.DXGI.Format.FormatD32FloatS8X24Uint,\n\n                            _ => throw new NotSupportedException($\"Unsupported Depth Format [{textureDescription.Format}] for the Depth-Stencil Buffer\")\n                        };\n                    }\n                    else // GraphicsProfile.Level_10_0 or higher\n                    {\n                        format = textureDescription.Format switch\n                        {\n                            PixelFormat.D16_UNorm => Silk.NET.DXGI.Format.FormatR16Typeless,\n                            PixelFormat.D32_Float => Silk.NET.DXGI.Format.FormatR32Typeless,\n                            PixelFormat.D24_UNorm_S8_UInt => Silk.NET.DXGI.Format.FormatR24G8Typeless,//Silk.NET.DXGI.Format.FormatD24UnormS8Uint\n                            PixelFormat.D32_Float_S8X24_UInt => Silk.NET.DXGI.Format.FormatR32G8X24Typeless,\n\n                            _ => throw new NotSupportedException($\"Unsupported Depth Format [{textureDescription.Format}] for the Depth-Stencil Buffer\")\n                        };\n                    }\n                }\n            }\n\n            int quality = 0;","sourceCodeStart":978,"sourceCodeEnd":1014,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs#L978-L1014","documentation":"Thrown in ConvertToNativeDescription2D when a depth-stencil texture is created on a Level_9_0 graphics profile with a PixelFormat not among the four depth formats D3D11 supports for the low-profile path (D16_UNorm, D32_Float, D24_UNorm_S8_UInt, D32_Float_S8X24_UInt). The library throws NotSupportedException because the mapping to a native DXGI format is undefined for any other format in a depth-stencil buffer.","triggerScenarios":"Calling Texture.InitializeFromImpl / Texture.New (or description) with TextureDescription whose Flags include DepthStencil and Format set to a color or typeless format (e.g. R16_Typeless, R32_Typeless, R24G8_Typeless, R32G8X24_Typeless, or any color format) while GraphicsDevice.GraphicsProfile == Level_9_0.","commonSituations":"Migrating a project that renders shadows or post effects from a higher profile down to Level_9_0, hand-building a depth texture description with a typeless format copied from the Level_10+ code path, or letting a misconfigured GraphicsProfile fall back to Level_9_0 on limited hardware.","solutions":["Set the texture's Format to one of PixelFormat.D16_UNorm, D32_Float, D24_UNorm_S8_UInt, or D32_Float_S8X24_UInt when creating a depth-stencil buffer.","Raise GraphicsDevice.GraphicsProfile to Level_10_0 or higher so the typeless-format path is used.","Verify the texture Flags actually require DepthStencil; if the texture is color-only, remove the DepthStencil flag so the color format path is used."],"exampleFix":"// before\nvar tex = Texture.New2D(device, 1024, 1024, PixelFormat.R32_Typeless, TextureFlags.DepthStencil);\n// after\nvar tex = Texture.New2D(device, 1024, 1024, PixelFormat.D32_Float, TextureFlags.DepthStencil);","handlingStrategy":"validation","validationCode":"var validDepthFormats = new[] { PixelFormat.D16_UNorm, PixelFormat.D32_Float, PixelFormat.D24_UNorm_S8_UInt, PixelFormat.D32_Float_S8X24_UInt };\nbool ok = !desc.Flags.HasFlag(TextureFlags.DepthStencil)\n          || (device.GraphicsProfile >= GraphicsProfile.Level_10_0\n              ? new[] { PixelFormat.D16_UNorm, PixelFormat.D32_Float, PixelFormat.D24_UNorm_S8_UInt, PixelFormat.D32_Float_S8X24_UInt, PixelFormat.R16_Typeless, PixelFormat.R32_Typeless, PixelFormat.R24G8_Typeless, PixelFormat.R32G8X24_Typeless }.Contains(desc.Format)\n              : validDepthFormats.Contains(desc.Format));","typeGuard":"static bool IsLowProfileDepthFormat(PixelFormat f) => f is PixelFormat.D16_UNorm or PixelFormat.D32_Float or PixelFormat.D24_UNorm_S8_UInt or PixelFormat.D32_Float_S8X24_UInt;","tryCatchPattern":"try { texture = Texture.New2D(device, w, h, format, TextureFlags.DepthStencil); }\ncatch (NotSupportedException ex) { log.Error(ex); texture = Texture.New2D(device, w, h, PixelFormat.D16_UNorm, TextureFlags.DepthStencil); }","preventionTips":["Always use a dedicated depth PixelFormat for depth-stencil textures; never a color format.","Pin GraphicsProfile explicitly instead of relying on device fallback.","Add a unit test that creates each depth texture used by your renderer at the target profile."],"tags":["graphics","direct3d11","depth-stencil","unsupported-format","texture-creation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}