{"record":{"id":"9245414b3e1c4427","repo":"stride3d/stride","slug":"unsupported-depth-format-texturedescription-format-for-depth","errorCode":null,"errorMessage":"Unsupported Depth format [{textureDescription.Format}] for Depth Buffer","messagePattern":"Unsupported Depth format \\[(.+?)\\] for Depth Buffer","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs","lineNumber":1083,"sourceCode":"            if (needsTypelessDepth)\n            {\n                if (IsShaderResource && GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0)\n                {\n                    throw new NotSupportedException($\"Creating Shader Resource Views for Depth-Stencil Buffers are not supported for Graphics Profiles < 10.0 (Current: [{GraphicsDevice.Features.CurrentProfile}])\");\n                }\n                else\n                {\n                    // Determine Typeless Format and 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 Depth Buffer\")\n                        };\n                    }\n                    else // GraphicsProfile >= 10.0\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,\n                            PixelFormat.D32_Float_S8X24_UInt => Silk.NET.DXGI.Format.FormatR32G8X24Typeless,\n\n                            _ => throw new NotSupportedException($\"Unsupported Depth format [{textureDescription.Format}] for Depth Buffer\")\n                        };\n                    }\n                }\n            }\n\n            return new ResourceDesc","sourceCodeStart":1065,"sourceCodeEnd":1101,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs#L1065-L1101","documentation":"Thrown by the Texture constructor (D3D12) when GraphicsProfile < 10.0: the code maps typed depth PixelFormats directly to concrete DXGI depth formats, and the provided format is not one of D16_UNorm, D32_Float, D24_UNorm_S8_UInt, or D32_Float_S8X24_UInt. Only those typed depth formats are accepted for a depth buffer at low profiles.","triggerScenarios":"Creating a depth-stencil Texture with a typeless format (e.g. R32_Typeless) or a non-depth format while GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0; the typed-format switch hits the default arm.","commonSituations":"Using typeless depth formats on a low feature-level device where only typed mapping is allowed; format set by pipeline descriptor does not match the profile path.","solutions":["Use a typed depth format: PixelFormat.D16_UNorm, D32_Float, D24_UNorm_S8_UInt, or D32_Float_S8X24_UInt.","Raise the GraphicsProfile to Level_10_0 or higher so typeless formats map via the R*_Typeless path.","Validate the texture format against the current profile before allocation."],"exampleFix":"// before (profile < 10.0)\nvar tex = Texture.New2D(device, w, h, PixelFormat.R32_Typeless, TextureFlags.DepthStencil);\n// after\nvar tex = Texture.New2D(device, w, h, PixelFormat.D32_Float, TextureFlags.DepthStencil);","handlingStrategy":"validation","validationCode":"if (device.Features.CurrentProfile < GraphicsProfile.Level_10_0 &&\n    Array.IndexOf(new[] { PixelFormat.D16_UNorm, PixelFormat.D32_Float, PixelFormat.D24_UNorm_S8_UInt, PixelFormat.D32_Float_S8X24_UInt }, format) < 0)\n    throw new ArgumentException(\"Typed depth format required on profiles < 10.0\");","typeGuard":"bool IsTypedDepthFormat(PixelFormat f) =>\n    f is PixelFormat.D16_UNorm or PixelFormat.D32_Float\n      or PixelFormat.D24_UNorm_S8_UInt or PixelFormat.D32_Float_S8X24_UInt;","tryCatchPattern":"try { tex = Texture.New2D(device, w, h, format, TextureFlags.DepthStencil); }\ncatch (NotSupportedException ex) { log.Error(ex, \"Invalid depth format for current profile\"); throw; }","preventionTips":["On profiles below 10.0, restrict depth buffers to typed depth formats only.","Validate formats against the active GraphicsProfile before texture allocation.","Document per-profile format support in your render-target setup code."],"tags":["direct3d12","depth-buffer","pixel-format","graphics-profile"],"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-16T04:17:20.429Z"}