stride3d/stride · error · NotSupportedException
This Depth-Stencil format is not supported
Error message
This Depth-Stencil format is not supported
What it means
Texture.CreateDepthTextureCompatible throws NotSupportedException when Texture.ComputeShaderResourceFormatFromDepthFormat returns PixelFormat.None, i.e. the texture IS depth-stencil but its depth format has no shader-resource-compatible equivalent. The library cannot create a samplable copy of that depth format and fails explicitly.
Solutions
- Use a depth format with a known shader-resource mapping (e.g. R32_Typeless/R32_Float depth) when creating the texture
- Check the mapped format first: PixelFormat f = Texture.ComputeShaderResourceFormatFromDepthFormat(fmt); if (f == PixelFormat.None) use an alternate technique (e.g. write depth to a color target)
- Add capability checks at startup and select the depth format accordingly
- Fall back to MRT depth-encoding if sampling the depth buffer directly is unsupported
Example fix
// before var depth = Texture.New2D(device, w, h, PixelFormat.R24_G8_Typeless, TextureFlags.DepthStencil); Texture copy = depth.CreateDepthTextureCompatible(); // throws if no SRV mapping // after var depth = Texture.New2D(device, w, h, PixelFormat.R32_Typeless, TextureFlags.DepthStencil | TextureFlags.ShaderResource); Texture copy = depth.CreateDepthTextureCompatible();
Defensive patterns
Strategy: validation
Validate before calling
var mapped = Texture.ComputeShaderResourceFormatFromDepthFormat(depthFormat);
if (mapped == PixelFormat.None)
Log.Error($"Depth format {depthFormat} has no shader-resource mapping; pick another format");
else
var copy = depthTexture.CreateDepthTextureCompatible(); Type guard
static bool DepthFormatSamplable(PixelFormat f) => Texture.ComputeShaderResourceFormatFromDepthFormat(f) != PixelFormat.None;
Try / catch
try { copy = texture.CreateDepthTextureCompatible(); }
catch (NotSupportedException) { /* fall back to depth encoded into a color target */ } Prevention
- Choose depth formats with known shader-resource mappings (R32_Typeless, R16_Typeless)
- Check GPU/feature-level format support at startup and select the depth format dynamically
- Avoid exotic depth-stencil formats (e.g. D32_S8) unless sampling support is verified
When it happens
Trigger: Calling CreateDepthTextureCompatible on a depth-stencil texture using a format with no shader-resource mapping (e.g. certain stencil-containing or feature-limited depth formats on some GPU/feature levels).
Common situations: Running on hardware/feature levels where D24S8 or similar lacks a typed shader-resource format; switching depth formats (e.g. to D32_S8) for precision and losing sampling support; targeting mobile or older GPUs with narrower format support.
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
- This Texture is not a valid Depth-Stencil Texture
- Depth-Stencil format
- Resizing transaction stack to a smaller size is not…
- Changing the panel from a user library type is currently…
- Grouping elements into a user library type isn't supported.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/af426bedf9c9f87f.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Texture.Extensions.cs:65
var viewDescription = texture.ViewDescription;
viewDescription.Flags = TextureFlags.DepthStencilReadOnly;
return texture.ToTextureView(viewDescription);
}
/// <summary>
/// Creates a Shader Resource View on a Depth-Stencil Texture.
/// </summary>
/// <param name="texture">The Texture to create a Depth-Stencil Texture View for.</param>
/// <returns>A new <see cref="Texture"/> representing the Texture View bound to <paramref name="texture"/>.</returns>
public static Texture CreateDepthTextureCompatible(this Texture texture)
{
if (!texture.IsDepthStencil)
throw new NotSupportedException("This Texture is not a valid Depth-Stencil Texture");
var description = texture.Description;
description.Format = Texture.ComputeShaderResourceFormatFromDepthFormat(description.Format); // TODO: review this
if (description.Format == PixelFormat.None)
throw new NotSupportedException("This Depth-Stencil format is not supported");
description.Flags = TextureFlags.ShaderResource;
return Texture.New(texture.GraphicsDevice, description);
}
/// <summary>
/// Verifies that a given <see cref="Texture"/> is a Render Target.
/// </summary>
/// <param name="texture"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static Texture EnsureRenderTarget(this Texture texture)
{
if (texture is not null && !texture.IsRenderTarget)
{
throw new ArgumentException("The Texture must be a Render Target", nameof(texture));
}
return texture;View on GitHub (pinned to 96fad776d2)