{"record":{"id":"d4d1a13aeafcbe86","repo":"stride3d/stride","slug":"creating-shader-resource-views-for-depth-stencil-buffers-are","errorCode":null,"errorMessage":"Creating Shader Resource Views for Depth-Stencil Buffers are not supported for Graphics Profiles < 10.0 (Current: [{GraphicsDevice.Features.CurrentProfile}])","messagePattern":"Creating Shader Resource Views for Depth-Stencil Buffers are not supported for Graphics Profiles < 10\\.0 \\(Current: \\[(.+?)\\]\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs","lineNumber":1069,"sourceCode":"        /// <exception cref=\"NotSupportedException\">\n        ///   For a <see cref=\"GraphicsProfile\"/> lower than <see cref=\"GraphicsProfile.Level_10_0\"/>, creating Shader Resource Views\n        ///   for Depth-Stencil Textures is not supported,\n        /// </exception>\n        /// <exception cref=\"NotSupportedException\">\n        ///   The specified pixel format is not supported for Depth-Stencil Textures.\n        /// </exception>\n        internal ResourceDesc ConvertToNativeDescription2D()\n        {\n            var format = (Format) textureDescription.Format;\n            var flags = textureDescription.Flags;\n\n            // Depth formats bound as shader resources must be created as typeless — covers both DS+SR and SR-only.\n            var needsTypelessDepth = IsDepthStencil || (IsShaderResource && IsDepthFormat(textureDescription.Format));\n            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                    {","sourceCodeStart":1051,"sourceCodeEnd":1087,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs#L1051-L1087","documentation":"Thrown when a Texture is constructed with shader-resource access on a depth-stencil format while the graphics device is at a feature level below GraphicsProfile.Level_10_0. Sampling depth buffers as SRVs requires D3D10+ features (typeless resources), so the D3D12 backend refuses it under lower profiles.","triggerScenarios":"Creating a depth texture with TextureFlags.ShaderResource (e.g. for shadow maps) on a device whose GraphicsDevice.Features.CurrentProfile is Level_9_1/9_2/9_3.","commonSituations":"Shadow mapping on very old hardware or a feature-level-limited device; WARP/low feature-level fallback; tests configuring GraphicsProfile below 10.0 while binding depth textures to shaders.","solutions":["Raise the device GraphicsProfile to Level_10_0 or higher when creating the GraphicsDevice.","Remove ShaderResource flag from the depth texture if sampling it is not needed.","Check GraphicsDevice.Features.CurrentProfile before creating depth SRVs and fall back to a non-sampled depth path."],"exampleFix":"// before\nvar device = GraphicsDevice.New(null, GraphicsProfile.Level_9_3);\n// after\nvar device = GraphicsDevice.New(null, GraphicsProfile.Level_10_0);","handlingStrategy":"validation","validationCode":"if (isDepth && (flags & TextureFlags.ShaderResource) != 0 &&\n    device.Features.CurrentProfile < GraphicsProfile.Level_10_0)\n{\n    // avoid creating a depth SRV on low profiles\n    flags &= ~TextureFlags.ShaderResource;\n}","typeGuard":"bool SupportsDepthSRV(GraphicsDevice device) =>\n    device?.Features?.CurrentProfile is >= GraphicsProfile.Level_10_0;","tryCatchPattern":"try { return Texture.New2D(device, w, h, depthFormat, TextureFlags.DepthStencil | TextureFlags.ShaderResource); }\ncatch (NotSupportedException) { return Texture.New2D(device, w, h, depthFormat, TextureFlags.DepthStencil); }","preventionTips":["Target GraphicsProfile.Level_10_0 or higher when shadow mapping / depth sampling is required.","Gate depth-SRV code paths behind a feature check on GraphicsDevice.Features.CurrentProfile.","Test the low-profile fallback path on a feature-level-limited device."],"tags":["direct3d12","depth-stencil","shader-resource-view","graphics-profile"],"backgroundTag":"unsupported-operation","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"}