stride3d/stride · error · NotSupportedException

Creating Shader Resource Views for Depth-Stencil Buffers…

Error message

Creating Shader Resource Views for Depth-Stencil Buffers are not supported for Graphics Profiles < 10.0 (Current: [{GraphicsDevice.Features.CurrentProfile}])

What it means

Thrown when a Texture is constructed with shader-resource access on a depth-stencil format while the graphics device is at a feature level below GraphicsProfile.Level_10_0. Sampling depth buffers as SRVs requires D3D10+ features (typeless resources), so the D3D12 backend refuses it under lower profiles.

Solutions

  1. Raise the device GraphicsProfile to Level_10_0 or higher when creating the GraphicsDevice.
  2. Remove ShaderResource flag from the depth texture if sampling it is not needed.
  3. Check GraphicsDevice.Features.CurrentProfile before creating depth SRVs and fall back to a non-sampled depth path.

Example fix

// before
var device = GraphicsDevice.New(null, GraphicsProfile.Level_9_3);
// after
var device = GraphicsDevice.New(null, GraphicsProfile.Level_10_0);
Defensive patterns

Strategy: validation

Validate before calling

if (isDepth && (flags & TextureFlags.ShaderResource) != 0 &&
    device.Features.CurrentProfile < GraphicsProfile.Level_10_0)
{
    // avoid creating a depth SRV on low profiles
    flags &= ~TextureFlags.ShaderResource;
}

Type guard

bool SupportsDepthSRV(GraphicsDevice device) =>
    device?.Features?.CurrentProfile is >= GraphicsProfile.Level_10_0;

Try / catch

try { return Texture.New2D(device, w, h, depthFormat, TextureFlags.DepthStencil | TextureFlags.ShaderResource); }
catch (NotSupportedException) { return Texture.New2D(device, w, h, depthFormat, TextureFlags.DepthStencil); }

Prevention

When it happens

Trigger: Creating a depth texture with TextureFlags.ShaderResource (e.g. for shadow maps) on a device whose GraphicsDevice.Features.CurrentProfile is Level_9_1/9_2/9_3.

Common situations: Shadow mapping on very old hardware or a feature-level-limited device; WARP/low feature-level fallback; tests configuring GraphicsProfile below 10.0 while binding depth textures to shaders.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

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

        /// <exception cref="NotSupportedException">
        ///   For a <see cref="GraphicsProfile"/> lower than <see cref="GraphicsProfile.Level_10_0"/>, creating Shader Resource Views
        ///   for Depth-Stencil Textures is not supported,
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///   The specified pixel format is not supported for Depth-Stencil Textures.
        /// </exception>
        internal ResourceDesc ConvertToNativeDescription2D()
        {
            var format = (Format) textureDescription.Format;
            var flags = textureDescription.Flags;

            // Depth formats bound as shader resources must be created as typeless — covers both DS+SR and SR-only.
            var needsTypelessDepth = IsDepthStencil || (IsShaderResource && IsDepthFormat(textureDescription.Format));
            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
                    {

View on GitHub (pinned to 96fad776d2)