stride3d/stride · error · NotSupportedException
Multisample is only supported for 2D Textures
Error message
Multisample is only supported for 2D Textures
What it means
When creating an SRV for a texture array, multisampling is only representable for 2D textures (Texture2DMSArray). If the texture is multisampled but its Dimension is not Texture2D, the backend throws NotSupportedException because D3D12 has no MS texture-array view for 1D/3D dimensions.
Solutions
- Remove MultisampleCount (make the texture non-multisampled) for 1D/3D textures
- Change Dimension to Texture2D if MSAA is required
- Verify texture factory parameters (Dimension, MultisampleCount) before creating the texture
Example fix
// before var tex = Texture.New2D(device, 512, 512, PixelFormat.R8G8B8A8.UNorm, TextureFlags.ShaderResource, 1, TextureDimension.Texture3D); tex.MultisampleCount = 4; // after var tex = Texture.New2D(device, 512, 512, PixelFormat.R8G8B8A8.UNorm, TextureFlags.ShaderResource); // Dimension Texture2D with MS allowed
Defensive patterns
Strategy: validation
Validate before calling
if (desc.MultisampleCount > 1 && desc.Dimension != TextureDimension.Texture2D) throw new InvalidOperationException("Multisampling requires Texture2D"); Type guard
bool CanBeMultisampled(TextureDescription d) => d.MultisampleCount <= 1 || d.Dimension == TextureDimension.Texture2D;
Try / catch
try { texture = new Texture(device, desc); } catch (NotSupportedException) { desc.MultisampleCount = 1; texture = new Texture(device, desc); } Prevention
- Never set MultisampleCount > 1 on 1D/3D textures
- Centralize texture factory code to clamp MSAA by dimension
When it happens
Trigger: Initializing a multisampled Texture with Dimension Texture1D or Texture3D and a specific arrayOrDepthSlice (texture-array branch of InitializeFromImpl).
Common situations: Configuring MSAA on non-2D resources by mistake; porting code from APIs that silently ignore multisample counts on 1D/3D textures.
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
- Source Texture is not a MSAA Texture
- Expecting texture supporting UAV
- The Graphics Resource is a Texture, but its dimension is…
- A Texture Cube must have an ArraySize > 1
- Multisample is only supported for 2D Render Target Textures
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/5f89fb058152b518.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs:600
};
// Initialize for Texture Arrays or Texture Cube
if (ArraySize > 1)
{
// If Texture Cube
if (Dimension == TextureDimension.TextureCube && viewType == ViewType.Full)
{
srvDescription.ViewDimension = SrvDimension.Texturecube;
srvDescription.TextureCube.MipLevels = (uint) mipCount;
srvDescription.TextureCube.MostDetailedMip = (uint) mipIndex;
}
else // Texture array
{
if (IsMultiSampled)
{
if (Dimension != TextureDimension.Texture2D)
{
throw new NotSupportedException("Multisample is only supported for 2D Textures");
}
srvDescription.ViewDimension = SrvDimension.Texture2Dmsarray;
srvDescription.Texture2DMSArray.ArraySize = (uint) arrayCount;
srvDescription.Texture2DMSArray.FirstArraySlice = (uint) arrayOrDepthSlice;
}
else
{
srvDescription.ViewDimension = Dimension is TextureDimension.Texture2D or TextureDimension.TextureCube
? SrvDimension.Texture2Darray
: SrvDimension.Texture1Darray;
srvDescription.Texture2DArray.ArraySize = (uint) arrayCount;
srvDescription.Texture2DArray.FirstArraySlice = (uint) arrayOrDepthSlice;
srvDescription.Texture2DArray.MipLevels = (uint) mipCount;
srvDescription.Texture2DArray.MostDetailedMip = (uint) mipIndex;
}
}
}View on GitHub (pinned to 96fad776d2)