{"record":{"id":"248ac312838f0c2e","repo":"stride3d/stride","slug":"depth-stencil-format-viewformat-not-supported","errorCode":null,"errorMessage":"Depth-Stencil format [{ViewFormat}] not supported","messagePattern":"Depth-Stencil format \\[(.+?)\\] not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs","lineNumber":759,"sourceCode":"                var descriptorHandle = GraphicsDevice.RenderTargetViewAllocator.Allocate(1);\n\n                NativeDevice.CreateRenderTargetView(NativeResource, in rtvDescription, descriptorHandle);\n                return descriptorHandle;\n            }\n\n            //\n            // Gets a Depth-Stencil View from the Texture.\n            //\n            CpuDescriptorHandle GetDepthStencilView(out bool hasStencil)\n            {\n                hasStencil = false;\n\n                if (!IsDepthStencil)\n                    return default;\n\n                // Check that the format is supported\n                if (ComputeShaderResourceFormatFromDepthFormat(ViewFormat) == PixelFormat.None)\n                    throw new NotSupportedException($\"Depth-Stencil format [{ViewFormat}] not supported\");\n\n                hasStencil = IsStencilFormat(ViewFormat);\n\n                // Create a Depth-Stencil View on this Texture\n                var depthStencilViewDescription = new DepthStencilViewDesc\n                {\n                    Format = ComputeDepthViewFormatFromTextureFormat(ViewFormat),\n                    Flags = DsvFlags.None\n                };\n\n                // Initialize for Texture Arrays or Texture Cube\n                if (ArraySize > 1)\n                {\n                    depthStencilViewDescription.ViewDimension = DsvDimension.Texture2Darray;\n                    depthStencilViewDescription.Texture2DArray.ArraySize = (uint) ArraySize;\n                    depthStencilViewDescription.Texture2DArray.FirstArraySlice = 0;\n                    depthStencilViewDescription.Texture2DArray.MipSlice = 0;\n                }","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs#L741-L777","documentation":"Depth-stencil views (DSVs) in D3D12 require a typeless parent format with a known typeless-to-typed mapping. ComputeShaderResourceFormatFromDepthFormat(ViewFormat) returns PixelFormat.None when ViewFormat is not a recognized depth format, so the backend cannot create the DSV and throws in InitializeFromImpl.","triggerScenarios":"Creating a Texture with IsDepthStencil (TextureFlags.DepthStencil) and a ViewFormat such as a plain color format (R8G8B8A8, R32.Float with wrong binding) that has no depth counterpart, on the Direct3D12 backend.","commonSituations":"Using D32.Float_S8X24.UInt variants unsupported by the device; copying a color render-target format into a depth target; forgetting that depth textures must be created with a depth (typeless) format.","solutions":["Use a supported depth format: D32.Float, D16.UInt, D32.Float_S8X24.UInt, or D24_S8.UInt (per PixelFormat).","Check ComputeShaderResourceFormatFromDepthFormat(ViewFormat) != PixelFormat.None before creating the texture.","Query device feature/format support (GraphicsDevice / check supported depth formats) and fall back to D32.Float or D16.UInt."],"exampleFix":"// before\nvar depth = Texture.New2D(device, 1024, 1024, PixelFormat.R32.Float, TextureFlags.DepthStencil | TextureFlags.ShaderResource);\n// after\nvar depth = Texture.New2D(device, 1024, 1024, PixelFormat.D32.Float, TextureFlags.DepthStencil | TextureFlags.ShaderResource);","handlingStrategy":"validation","validationCode":"if (flags.HasFlag(TextureFlags.DepthStencil) && Texture.ComputeShaderResourceFormatFromDepthFormat(format) == PixelFormat.None)\n    throw new InvalidOperationException($\"Format {format} is not a valid depth-stencil format.\");","typeGuard":null,"tryCatchPattern":"try { return Texture.New2D(device, w, h, format, TextureFlags.DepthStencil | TextureFlags.ShaderResource); }\ncatch (NotSupportedException) { return Texture.New2D(device, w, h, PixelFormat.D32.Float, TextureFlags.DepthStencil | TextureFlags.ShaderResource); }","preventionTips":["Only use D32.Float, D16.UInt, D24_S8.UInt, or D32.Float_S8X24.UInt for depth textures.","Never reuse color render-target formats for depth buffers.","Validate depth formats against device support at startup."],"tags":["direct3d12","depth-stencil","pixel-format","texture"],"backgroundTag":"unsupported-dtype","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"}