stride3d/stride · error · NotSupportedException
Depth-Stencil format
Error message
Depth-Stencil format [{ViewFormat}] not supported What it means
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.
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.
Example fix
// before var depth = Texture.New2D(device, 1024, 1024, PixelFormat.R32.Float, TextureFlags.DepthStencil | TextureFlags.ShaderResource); // after var depth = Texture.New2D(device, 1024, 1024, PixelFormat.D32.Float, TextureFlags.DepthStencil | TextureFlags.ShaderResource);
Defensive patterns
Strategy: validation
Validate before calling
if (flags.HasFlag(TextureFlags.DepthStencil) && Texture.ComputeShaderResourceFormatFromDepthFormat(format) == PixelFormat.None)
throw new InvalidOperationException($"Format {format} is not a valid depth-stencil format."); Try / catch
try { return Texture.New2D(device, w, h, format, TextureFlags.DepthStencil | TextureFlags.ShaderResource); }
catch (NotSupportedException) { return Texture.New2D(device, w, h, PixelFormat.D32.Float, TextureFlags.DepthStencil | TextureFlags.ShaderResource); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported depth format
- This Depth-Stencil format is not supported
- The Depth-Stencil format
- NoStencilBufferForDepthFormat (formatted with ViewFormat)
- Expecting texture supporting UAV
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/248ac312838f0c2e.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs:759
var descriptorHandle = GraphicsDevice.RenderTargetViewAllocator.Allocate(1);
NativeDevice.CreateRenderTargetView(NativeResource, in rtvDescription, descriptorHandle);
return descriptorHandle;
}
//
// Gets a Depth-Stencil View from the Texture.
//
CpuDescriptorHandle GetDepthStencilView(out bool hasStencil)
{
hasStencil = false;
if (!IsDepthStencil)
return default;
// Check that the format is supported
if (ComputeShaderResourceFormatFromDepthFormat(ViewFormat) == PixelFormat.None)
throw new NotSupportedException($"Depth-Stencil format [{ViewFormat}] not supported");
hasStencil = IsStencilFormat(ViewFormat);
// Create a Depth-Stencil View on this Texture
var depthStencilViewDescription = new DepthStencilViewDesc
{
Format = ComputeDepthViewFormatFromTextureFormat(ViewFormat),
Flags = DsvFlags.None
};
// Initialize for Texture Arrays or Texture Cube
if (ArraySize > 1)
{
depthStencilViewDescription.ViewDimension = DsvDimension.Texture2Darray;
depthStencilViewDescription.Texture2DArray.ArraySize = (uint) ArraySize;
depthStencilViewDescription.Texture2DArray.FirstArraySlice = 0;
depthStencilViewDescription.Texture2DArray.MipSlice = 0;
}View on GitHub (pinned to 96fad776d2)