stride3d/stride · error · NotSupportedException
Multi-sampling is only supported for 2D Textures
Error message
Multi-sampling is only supported for 2D Textures
What it means
When building a shader resource view for a multi-sampled texture array on D3D11, the code checks that the texture dimension is Texture2D. Multi-sample resources in Direct3D only exist as 2D textures, so requesting an MS SRV for a 1D or 3D array texture throws NotSupportedException.
Solutions
- Set MultisampleCount to 1 (non-multi-sampled) for non-2D textures.
- Change the texture dimension to Texture2D if multi-sampling is required.
- Sanitize the TextureDescription in a helper that clears MSAA flags for non-2D dimensions before creating textures.
Example fix
// before
var desc = new TextureDescription { Dimension = TextureDimension.Texture3D, MultisampleCount = 4 };
// after
var desc = new TextureDescription { Dimension = TextureDimension.Texture3D, MultisampleCount = 1 }; Defensive patterns
Strategy: validation
Validate before calling
if (desc.MultisampleCount > 1 && desc.Dimension != TextureDimension.Texture2D)
desc.MultisampleCount = 1; // or reject the description
var tex = new Texture(device, desc); Type guard
static bool IsMsaaValid(TextureDescription d) => d.MultisampleCount <= 1 || d.Dimension == TextureDimension.Texture2D;
Try / catch
try { tex = new Texture(device, desc); }
catch (NotSupportedException ex) when (ex.Message.Contains("Multi-sampling")) { desc.MultisampleCount = 1; tex = new Texture(device, desc); } Prevention
- Clear MultisampleCount whenever the texture dimension is not Texture2D
- Sanitize descriptions in a single factory function
- Add asserts for MSAA/dimension consistency in texture creation helpers
When it happens
Trigger: Texture created with MultisampleCount > 1, an array slice range (TextureDimension.Texture1D or Texture3D array), while InitializeFromImpl builds the SRV via GetShaderResourceView.
Common situations: Copying a description from a 2D MSAA texture and changing only the dimension; generator code that sets MultisampleCount unconditionally; MSAA flags left enabled on 3D volume textures.
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
- Expecting a Texture supporting UAV
- Creating a texture from a SRV with dimension
- The options specified for the Texture are not valid.
- Texture Cubes must have an array size greater than 1
- . is not supported for Render Targets
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/58ba19c8dd0b67d5.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs:516
var srvDescription = new ShaderResourceViewDesc { Format = ComputeShaderResourceViewFormat() };
// Initialize for Texture Array or Texture Cube
if (ArraySize > 1)
{
if (ViewDimension == TextureDimension.TextureCube)
{
srvDescription.ViewDimension = D3DSrvDimension.D3D101SrvDimensionTexturecube;
srvDescription.TextureCube.MipLevels = (uint) mipCount;
srvDescription.TextureCube.MostDetailedMip = (uint) mipIndex;
}
else // Regular Texture Array
{
if (IsMultiSampled)
{
if (Dimension != TextureDimension.Texture2D)
{
throw new NotSupportedException("Multi-sampling is only supported for 2D Textures");
}
srvDescription.ViewDimension = D3DSrvDimension.D3D101SrvDimensionTexture2Dmsarray;
srvDescription.Texture2DMSArray.ArraySize = (uint) arrayCount;
srvDescription.Texture2DMSArray.FirstArraySlice = (uint) arrayOrDepthSlice;
}
else // Not multi-sampled
{
if (ViewDimension == TextureDimension.Texture2D)
{
srvDescription.ViewDimension = D3DSrvDimension.D3D101SrvDimensionTexture2Darray;
srvDescription.Texture2DArray.ArraySize = (uint) arrayCount;
srvDescription.Texture2DArray.FirstArraySlice = (uint) arrayOrDepthSlice;
srvDescription.Texture2DArray.MipLevels = (uint) mipCount;
srvDescription.Texture2DArray.MostDetailedMip = (uint) mipIndex;
}
else if (ViewDimension != TextureDimension.Texture1D)
{View on GitHub (pinned to 96fad776d2)