stride3d/stride · error · NotSupportedException
Cannot create a Texture with format
Error message
Cannot create a Texture with format {Format} and multi-sample level {MultisampleCount}. The maximum supported level is {maxCount} What it means
Stride validates multisampled texture creation against the graphics device's capabilities: GraphicsDevice.Features[Format].MultisampleCountMax. If the requested MultisampleCount exceeds the maximum supported for the given pixel format on the current hardware, NotSupportedException is thrown.
Solutions
- Clamp MultisampleCount to GraphicsDevice.Features[Format].MultisampleCountMax before creating the texture.
- Query the device features at startup and pick the highest supported sample count.
- Fall back to a lower MSAA level or non-multisampled rendering when the max is 1.
Example fix
// before var desc = TextureDescription.New2D(w, h, fmt, TextureFlags.RenderTarget); desc.MultisampleCount = 16; var tex = new Texture(device).InitializeFrom(desc); // after int max = device.Features[fmt].MultisampleCountMax; var desc = TextureDescription.New2D(w, h, fmt, TextureFlags.RenderTarget); desc.MultisampleCount = Math.Min(16, max); var tex = new Texture(device).InitializeFrom(desc);
Defensive patterns
Strategy: validation
Validate before calling
int maxMsaa = device.Features[format].MultisampleCountMax;
if (maxMsaa < requestedCount)
requestedCount = maxMsaa; // clamp or refuse Type guard
static bool MsaaSupported(GraphicsDevice d, PixelFormat f, int count) => d.Features[f].MultisampleCountMax >= count;
Try / catch
try { tex = new Texture(device).InitializeFrom(desc); }
catch (NotSupportedException)
{
desc.MultisampleCount = device.Features[desc.Format].MultisampleCountMax;
tex = new Texture(device).InitializeFrom(desc);
} Prevention
- Never hard-code MSAA levels; always query Features per format.
- Test on your minimum-spec target GPU/backend.
- Expose MSAA level as a setting clamped at startup.
When it happens
Trigger: Creating a Texture with a MultisampleCount (e.g. 8x or 16x MSAA) greater than the device's per-format limit; running on hardware/drivers with lower MSAA support than the development machine.
Common situations: Hard-coded MSAA levels that work on desktop GPUs but fail on integrated/mobile GPUs; format-specific limits (some formats support fewer samples); switching between D3D11/D3D12/Vulkan backends.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Custom strides is not supported with packed PixelFormats
- The camera [ ] is disabled and can't be attached
- The camera [ ] is already attached
- The camera [ ] isn't attached
- Invalid Z slice index
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/4a513a14f542b4b2.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Texture.cs:529
if (ViewFlags == TextureFlags.None)
{
textureViewDescription.Flags = deviceDescription.Flags;
}
// Check that the Texture View flags are compatible with the parent Texture's flags
var filterViewFlags = (TextureFlags)((int)ViewFlags & (~DepthStencilReadOnlyFlags));
if ((Flags & filterViewFlags) != filterViewFlags)
{
throw new NotSupportedException(
$"Cannot create a Texture View with flags [{ViewFlags}] from the parent Texture with flags [{Flags}]. " +
$"The parent Texture must include all the flags defined by the Texture View");
}
if (IsMultiSampled)
{
var maxCount = GraphicsDevice.Features[Format].MultisampleCountMax;
if (maxCount < MultisampleCount)
throw new NotSupportedException(
$"Cannot create a Texture with format {Format} and multi-sample level {MultisampleCount}. " +
$"The maximum supported level is {maxCount}");
}
InitializeFromImpl(textureDatas);
return this;
}
/// <summary>
/// Initializes the Texture with no initial data.
/// </summary>
private void InitializeFromImpl() => InitializeFromImpl(dataBoxes: null);
/// <summary>
/// Performs platform-dependent initialization of the Texture.
/// </summary>
/// <param name="dataBoxes">View on GitHub (pinned to 96fad776d2)