stride3d/stride · error · NotSupportedException

Unsupported Depth format

Error message

Unsupported Depth format [{textureDescription.Format}] for Depth Buffer

What it means

Thrown by the Texture constructor (D3D12) when GraphicsProfile < 10.0: the code maps typed depth PixelFormats directly to concrete DXGI depth formats, and the provided format is not one of D16_UNorm, D32_Float, D24_UNorm_S8_UInt, or D32_Float_S8X24_UInt. Only those typed depth formats are accepted for a depth buffer at low profiles.

Solutions

  1. Use a typed depth format: PixelFormat.D16_UNorm, D32_Float, D24_UNorm_S8_UInt, or D32_Float_S8X24_UInt.
  2. Raise the GraphicsProfile to Level_10_0 or higher so typeless formats map via the R*_Typeless path.
  3. Validate the texture format against the current profile before allocation.

Example fix

// before (profile < 10.0)
var tex = Texture.New2D(device, w, h, PixelFormat.R32_Typeless, TextureFlags.DepthStencil);
// after
var tex = Texture.New2D(device, w, h, PixelFormat.D32_Float, TextureFlags.DepthStencil);
Defensive patterns

Strategy: validation

Validate before calling

if (device.Features.CurrentProfile < GraphicsProfile.Level_10_0 &&
    Array.IndexOf(new[] { PixelFormat.D16_UNorm, PixelFormat.D32_Float, PixelFormat.D24_UNorm_S8_UInt, PixelFormat.D32_Float_S8X24_UInt }, format) < 0)
    throw new ArgumentException("Typed depth format required on profiles < 10.0");

Type guard

bool IsTypedDepthFormat(PixelFormat f) =>
    f is PixelFormat.D16_UNorm or PixelFormat.D32_Float
      or PixelFormat.D24_UNorm_S8_UInt or PixelFormat.D32_Float_S8X24_UInt;

Try / catch

try { tex = Texture.New2D(device, w, h, format, TextureFlags.DepthStencil); }
catch (NotSupportedException ex) { log.Error(ex, "Invalid depth format for current profile"); throw; }

Prevention

When it happens

Trigger: Creating a depth-stencil Texture with a typeless format (e.g. R32_Typeless) or a non-depth format while GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0; the typed-format switch hits the default arm.

Common situations: Using typeless depth formats on a low feature-level device where only typed mapping is allowed; format set by pipeline descriptor does not match the profile path.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/9245414b3e1c4427. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs:1083

            if (needsTypelessDepth)
            {
                if (IsShaderResource && GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0)
                {
                    throw new NotSupportedException($"Creating Shader Resource Views for Depth-Stencil Buffers are not supported for Graphics Profiles < 10.0 (Current: [{GraphicsDevice.Features.CurrentProfile}])");
                }
                else
                {
                    // Determine Typeless Format and Shader Resource View Format
                    if (GraphicsDevice.Features.CurrentProfile < GraphicsProfile.Level_10_0)
                    {
                        format = textureDescription.Format switch
                        {
                            PixelFormat.D16_UNorm => Silk.NET.DXGI.Format.FormatD16Unorm,
                            PixelFormat.D32_Float => Silk.NET.DXGI.Format.FormatD32Float,
                            PixelFormat.D24_UNorm_S8_UInt => Silk.NET.DXGI.Format.FormatD24UnormS8Uint,
                            PixelFormat.D32_Float_S8X24_UInt => Silk.NET.DXGI.Format.FormatD32FloatS8X24Uint,

                            _ => throw new NotSupportedException($"Unsupported Depth format [{textureDescription.Format}] for Depth Buffer")
                        };
                    }
                    else // GraphicsProfile >= 10.0
                    {
                        format = textureDescription.Format switch
                        {
                            PixelFormat.D16_UNorm => Silk.NET.DXGI.Format.FormatR16Typeless,
                            PixelFormat.D32_Float => Silk.NET.DXGI.Format.FormatR32Typeless,
                            PixelFormat.D24_UNorm_S8_UInt => Silk.NET.DXGI.Format.FormatR24G8Typeless,
                            PixelFormat.D32_Float_S8X24_UInt => Silk.NET.DXGI.Format.FormatR32G8X24Typeless,

                            _ => throw new NotSupportedException($"Unsupported Depth format [{textureDescription.Format}] for Depth Buffer")
                        };
                    }
                }
            }

            return new ResourceDesc

View on GitHub (pinned to 96fad776d2)