{"record":{"id":"6e8627b8a6649340","repo":"stride3d/stride","slug":"shader-resource-views-for-depth-stencil-textures-are-not","errorCode":null,"errorMessage":"Shader Resource Views for Depth-Stencil Textures are not supported for Graphics profile < 10.0 (Current: [{GraphicsDevice.Features.CurrentProfile}])","messagePattern":"Shader Resource Views for Depth-Stencil Textures are not supported for Graphics profile < 10\\.0 \\(Current: \\[(.+?)\\]\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs","lineNumber":982,"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        private Texture2DDesc 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($\"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                    {","sourceCodeStart":964,"sourceCodeEnd":1000,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs#L964-L1000","documentation":"Depth formats bound as shader resources must be created typeless, which requires D3D10+ features. In ConvertToNativeDescription2D, if a texture is a depth-stencil or depth-format texture also flagged as ShaderResource while GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0, Stride throws this NotSupportedException because SRVs on depth textures cannot be set up on such a profile.","triggerScenarios":"Creating a texture with a depth format and TextureFlags.ShaderResource (with or without DepthStencil) on a GraphicsDevice initialized with GraphicsProfile.Level_9_1/9_2/9_3 — ConvertToNativeDescription2D during texture initialization.","commonSituations":"Targeting very old hardware or feature level 9.x (some emulators, old integrated GPUs, certain mobile/ARM Windows devices); a project-wide GraphicsProfile lowered to Level_9_x for compatibility while the renderer samples depth maps (shadow mapping); running tests on a device that clamps the profile down.","solutions":["Raise the GraphicsDevice's GraphicsProfile to at least GraphicsProfile.Level_10_0 when creating the device.","Remove TextureFlags.ShaderResource from depth-format textures on level 9.x profiles (restructure e.g. shadow passes to not sample depth directly).","Copy the depth into a regular color texture via a render pass on profiles < 10.0 and sample that copy instead."],"exampleFix":"// before\nvar device = GraphicsDevice.New(Platform, DeviceContext, GraphicsProfile.Level_9_3);\nvar shadow = Texture.New2D(GraphicsDevice, 2048, 2048, PixelFormat.D32_Float,\n    TextureFlags.ShaderResource | TextureFlags.DepthStencil);\n// after\nvar device = GraphicsDevice.New(Platform, DeviceContext, GraphicsProfile.Level_10_0);\nvar shadow = Texture.New2D(GraphicsDevice, 2048, 2048, PixelFormat.D32_Float,\n    TextureFlags.ShaderResource | TextureFlags.DepthStencil);","handlingStrategy":"validation","validationCode":"if ((flags & TextureFlags.ShaderResource) != 0 && IsDepthFormat(format)\n    && GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0)\n    throw new InvalidOperationException(\"Depth SRVs require GraphicsProfile >= Level_10_0\");","typeGuard":"bool SupportsDepthSrv(GraphicsDevice gd) =>\n    gd != null && gd.Features != null && gd.Features.CurrentProfile >= GraphicsProfile.Level_10_0;","tryCatchPattern":"try { var shadow = Texture.New2D(gd, 2048, 2048, PixelFormat.D32_Float, TextureFlags.ShaderResource | TextureFlags.DepthStencil); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"profile < 10.0\"))\n{\n    // fall back to rendering depth into a color RT and sampling that\n}","preventionTips":["Target GraphicsProfile.Level_10_0 or higher if shadow mapping / depth sampling is used.","Check GraphicsDevice.Features.CurrentProfile at startup and warn about depth-SRV limitations.","Keep a color-copy fallback path for level 9.x profiles."],"tags":["direct3d11","depth-stencil","shader-resource","graphics-profile"],"backgroundTag":"unsupported-platform","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"}