stride3d/stride · error · NotSupportedException

Cannot create a read-only Depth-Stencil View. Not supported…

Error message

Cannot create a read-only Depth-Stencil View. Not supported on this device

What it means

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.

Solutions

  1. Check IsDepthStencilReadOnlySupported(GraphicsDevice) before enabling read-only depth-stencil and fall back to a non-read-only view.
  2. Remove the read-only flag and instead bind depth as shader resource only when the bind order permits.
  3. Update GPU drivers/hardware, or require a higher GraphicsProfile for the feature path.

Example fix

// before
desc.IsDepthStencilReadOnly = true;
// after
if (Texture.IsDepthStencilReadOnlySupported(GraphicsDevice))
    desc.IsDepthStencilReadOnly = true;
else
    desc.IsDepthStencilReadOnly = false; // fallback path
Defensive patterns

Strategy: fallback

Validate before calling

bool canReadOnlyDsv = Texture.IsDepthStencilReadOnlySupported(GraphicsDevice);
desc.IsDepthStencilReadOnly = canReadOnlyDsv && wantReadOnly;

Try / catch

try { var tex = new Texture(GraphicsDevice, desc); }
catch (NotSupportedException ex) when (ex.Message.Contains("read-only Depth-Stencil"))
{
    desc.IsDepthStencilReadOnly = false;
    var tex = new Texture(GraphicsDevice, desc); // non-read-only fallback
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs:818

            {
                dsvDescription.ViewDimension = DsvDimension.Texture2Darray;
                dsvDescription.Texture2DArray.ArraySize = (uint) ArraySize;
                dsvDescription.Texture2DArray.FirstArraySlice = 0;
                dsvDescription.Texture2DArray.MipSlice = 0;
            }
            else // Not a Texture Array or Texture Cube
            {
                dsvDescription.ViewDimension = DsvDimension.Texture2D;
                dsvDescription.Texture2D.MipSlice = 0;
            }

            if (MultisampleCount > MultisampleCount.None)
                dsvDescription.ViewDimension = DsvDimension.Texture2Dms;

            if (IsDepthStencilReadOnly)
            {
                if (!IsDepthStencilReadOnlySupported(GraphicsDevice))
                    throw new NotSupportedException("Cannot create a read-only Depth-Stencil View. Not supported on this device");

                dsvDescription.Flags = (uint) DsvFlag.Depth;
                if (HasStencil)
                    dsvDescription.Flags |= (uint) DsvFlag.Stencil;
            }

            ComPtr<ID3D11DepthStencilView> dsv = default;
            HResult result = NativeDevice.CreateDepthStencilView(NativeResource, in dsvDescription, ref dsv);

            if (result.IsFailure)
                result.Throw();

            return dsv;
        }

        /// <summary>
        ///   Converts the specified <see cref="TextureFlags"/> to Silk.NET's <see cref="BindFlag"/>.
        /// </summary>

View on GitHub (pinned to 96fad776d2)