{"record":{"id":"7145940bba77fe71","repo":"stride3d/stride","slug":"cannot-create-a-read-only-depth-stencil-view-not-supported","errorCode":null,"errorMessage":"Cannot create a read-only Depth-Stencil View. Not supported on this device","messagePattern":"Cannot create a read-only Depth-Stencil View\\. Not supported on this device","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs","lineNumber":818,"sourceCode":"            {\n                dsvDescription.ViewDimension = DsvDimension.Texture2Darray;\n                dsvDescription.Texture2DArray.ArraySize = (uint) ArraySize;\n                dsvDescription.Texture2DArray.FirstArraySlice = 0;\n                dsvDescription.Texture2DArray.MipSlice = 0;\n            }\n            else // Not a Texture Array or Texture Cube\n            {\n                dsvDescription.ViewDimension = DsvDimension.Texture2D;\n                dsvDescription.Texture2D.MipSlice = 0;\n            }\n\n            if (MultisampleCount > MultisampleCount.None)\n                dsvDescription.ViewDimension = DsvDimension.Texture2Dms;\n\n            if (IsDepthStencilReadOnly)\n            {\n                if (!IsDepthStencilReadOnlySupported(GraphicsDevice))\n                    throw new NotSupportedException(\"Cannot create a read-only Depth-Stencil View. Not supported on this device\");\n\n                dsvDescription.Flags = (uint) DsvFlag.Depth;\n                if (HasStencil)\n                    dsvDescription.Flags |= (uint) DsvFlag.Stencil;\n            }\n\n            ComPtr<ID3D11DepthStencilView> dsv = default;\n            HResult result = NativeDevice.CreateDepthStencilView(NativeResource, in dsvDescription, ref dsv);\n\n            if (result.IsFailure)\n                result.Throw();\n\n            return dsv;\n        }\n\n        /// <summary>\n        ///   Converts the specified <see cref=\"TextureFlags\"/> to Silk.NET's <see cref=\"BindFlag\"/>.\n        /// </summary>","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs#L800-L836","documentation":"Read-only depth-stencil views (D3D11_DSV_READ_ONLY flags, requiring D3D11.1 / feature level support) are only available if the device reports the capability. Stride checks IsDepthStencilReadOnlySupported(GraphicsDevice) and throws this NotSupportedException when IsDepthStencilReadOnly is requested on a device that lacks the feature.","triggerScenarios":"Creating/initializing a depth-stencil texture with IsDepthStencilReadOnly (or read-only depth flags in the texture description) on a GraphicsDevice whose hardware/driver does not support read-only depth-stencil views (GetDepthStencilView during InitializeFromImpl).","commonSituations":"Running on old GPUs, software adapters (WARP), or feature levels below the required level; enabling read-only depth in shared code without checking device features; a renderer change that started binding depth as read-only for simultaneous depth-read + write passes.","solutions":["Check IsDepthStencilReadOnlySupported(GraphicsDevice) before enabling read-only depth-stencil and fall back to a non-read-only view.","Remove the read-only flag and instead bind depth as shader resource only when the bind order permits.","Update GPU drivers/hardware, or require a higher GraphicsProfile for the feature path."],"exampleFix":"// before\ndesc.IsDepthStencilReadOnly = true;\n// after\nif (Texture.IsDepthStencilReadOnlySupported(GraphicsDevice))\n    desc.IsDepthStencilReadOnly = true;\nelse\n    desc.IsDepthStencilReadOnly = false; // fallback path","handlingStrategy":"fallback","validationCode":"bool canReadOnlyDsv = Texture.IsDepthStencilReadOnlySupported(GraphicsDevice);\ndesc.IsDepthStencilReadOnly = canReadOnlyDsv && wantReadOnly;","typeGuard":null,"tryCatchPattern":"try { var tex = new Texture(GraphicsDevice, desc); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"read-only Depth-Stencil\"))\n{\n    desc.IsDepthStencilReadOnly = false;\n    var tex = new Texture(GraphicsDevice, desc); // non-read-only fallback\n}","preventionTips":["Always gate read-only depth usage behind IsDepthStencilReadOnlySupported.","Design render passes that work with a plain DSV when the feature is missing."],"tags":["direct3d11","depth-stencil","device-capability","read-only"],"backgroundTag":"feature-not-enabled","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"}