stride3d/stride · error · NotSupportedException
The Depth-Stencil format
Error message
The Depth-Stencil format [{ViewFormat}] is not supported What it means
When creating a depth-stencil view, Stride validates the depth format by mapping it to a shader-resource pixel format; if ComputeShaderResourceFormatFromDepthFormat returns PixelFormat.None, the format is not a usable depth-stencil format on this backend and the view cannot be built. The NotSupportedException names the offending ViewFormat.
Solutions
- Use a proper depth format such as PixelFormat.D32_Float, D24_UNorm_S8_UInt, D16_UNorm, or D32_Float_S8X24_UInt for depth-stencil textures.
- Verify the ViewFormat on the TextureDescription before flagging it DepthStencil.
- If the depth texture comes from an asset, check that the importer/serialization did not change its PixelFormat.
Example fix
// before
var depth = Texture.New2D(GraphicsDevice, 1024, 1024, PixelFormat.R32_Float,
TextureFlags.DepthStencil);
// after
var depth = Texture.New2D(GraphicsDevice, 1024, 1024, PixelFormat.D32_Float,
TextureFlags.DepthStencil); Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<PixelFormat> DepthFormats = new()
{ PixelFormat.D16_UNorm, PixelFormat.D32_Float, PixelFormat.D24_UNorm_S8_UInt, PixelFormat.D32_Float_S8X24_UInt };
if ((desc.Flags & TextureFlags.DepthStencil) != 0 && !DepthFormats.Contains(desc.Format))
throw new InvalidOperationException($"{desc.Format} is not a depth format"); Type guard
bool IsDepthFormat(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 { var tex = Texture.New2D(gd, w, h, fmt, TextureFlags.DepthStencil); }
catch (NotSupportedException ex) when (ex.Message.Contains("Depth-Stencil format"))
{
// recreate with PixelFormat.D32_Float or D24_UNorm_S8_UInt
} Prevention
- Only pass D* PixelFormats to depth-stencil texture creation.
- Validate asset-declared depth formats at load time.
When it happens
Trigger: Creating a texture with TextureFlags.DepthStencil and a ViewFormat that is not a recognized depth format (e.g., a plain color format like R8G8B8A8_UNorm, or an exotic/unsupported depth format) — checked at the top of GetDepthStencilView during InitializeFromImpl.
Common situations: Passing a color PixelFormat to a depth texture constructor; loading a texture asset whose format was converted to a non-depth format; typos in format selection (R32_Float instead of D32_Float); platforms where the chosen depth format has no shader-resource mapping.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Cannot clear a stencil buffer without a Stencil Buffer…
- Cannot create a read-only Depth-Stencil View. Not supported…
- Shader Resource Views for Depth-Stencil Textures are not…
- Unsupported Depth Format
- Unsupported depth format
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/938528492eff7eca.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs:787
/// Gets a specific <see cref="ID3D11DepthStencilView"/> from the Texture.
/// </summary>
/// <param name="hasStencil">
/// When the method returns, contains a value indicating if the <see cref="ViewFormat"/> is a Depth format
/// that also contains Stencil data.
/// </param>
/// <returns>An <see cref="ID3D11DepthStencilView"/> for the Texture.</returns>
/// <exception cref="NotSupportedException">The Depth-Stencil format specified is not supported.</exception>
/// <exception cref="NotSupportedException">Cannot create a read-only Depth-Stencil View because the device does not support it.</exception>
private ComPtr<ID3D11DepthStencilView> GetDepthStencilView(out bool hasStencil)
{
hasStencil = false;
if (!IsDepthStencil)
return null;
// Check that the format is supported
if (ComputeShaderResourceFormatFromDepthFormat(ViewFormat) == PixelFormat.None)
throw new NotSupportedException($"The Depth-Stencil format [{ViewFormat}] is not supported");
// Setup the HasStencil flag
hasStencil = IsStencilFormat(ViewFormat);
// Create a Depth-Stencil View
var dsvDescription = new DepthStencilViewDesc
{
Format = ComputeDepthViewFormatFromTextureFormat(ViewFormat),
Flags = 0
};
if (ArraySize > 1)
{
dsvDescription.ViewDimension = DsvDimension.Texture2Darray;
dsvDescription.Texture2DArray.ArraySize = (uint) ArraySize;
dsvDescription.Texture2DArray.FirstArraySlice = 0;
dsvDescription.Texture2DArray.MipSlice = 0;
}View on GitHub (pinned to 96fad776d2)