stride3d/stride · error · InvalidOperationException
Cannot generate more than 65535 indices on feature level HW…
Error message
Cannot generate more than 65535 indices on feature level HW <= 9.3
What it means
When a procedural primitive generates more than 65535 indices, a 32-bit index buffer is required. On GraphicsProfile.Level_9_3 or lower hardware, 32-bit indices are not supported, so Generate throws InvalidOperationException instead of producing a mesh that cannot render.
Solutions
- Reduce tessellation/subdivision parameters so the index count stays at or below 65535
- Raise the minimum GraphicsProfile to Level_10_0 in device creation and require 32-bit index support
- Split the primitive into multiple meshes/chunks each within the 16-bit index budget
Example fix
// before
var sphere = new SphereProceduralModel { Tessellation = 64 }; // >65535 indices, fails on Level_9_3
// after
var sphere = new SphereProceduralModel { Tessellation = 32 }; // stays within 65535 indices
// or request a higher profile when creating the device
var parameters = new GameParameters { RequiredGraphicsProfile = GraphicsProfile.Level_10_0 }; Defensive patterns
Strategy: validation
Validate before calling
if (indices.Length > 65535 && graphicsDevice.Features.CurrentProfile <= GraphicsProfile.Level_9_3)
throw new NotSupportedException("Reduce tessellation or require Level_10_0"); Type guard
static bool Supports32BitIndices(GraphicsDevice d) => d.Features.CurrentProfile > GraphicsProfile.Level_9_3;
Try / catch
try { primitive.Generate(services, model); }
catch (InvalidOperationException ex) when (ex.Message.Contains("65535")) {
primitive.Tessellation = Math.Max(1, primitive.Tessellation / 2); // regenerate smaller
} Prevention
- Check GraphicsProfile capability before generating large primitives
- Keep procedural tessellation within the 65535 index budget
- Set RequiredGraphicsProfile = Level_10_0 if high-detail primitives are mandatory
When it happens
Trigger: Generating a high-tessellation primitive (sphere, torus, etc.) whose vertex/index count exceeds 65535 while the target GraphicsDevice's CurrentProfile is Level_9_3 or below (old GPUs or forced low profile / feature level).
Common situations: Games targeting low-end or HiDef-limited devices; running on old hardware or an emulator that caps the graphics profile; users cranking tessellation parameters beyond 16-bit index limits.
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
- Invalid GeometricPrimitive
- Invalid GeometricPrimitive
- A texture with size [ ] already exist with the same output…
- Asked for " + i + " but no more than 10 default textures…
- Begin must be called before functionName
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/390b277d1f7b3a1d.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/ProceduralModels/PrimitiveProceduralModelBase.cs:171
if (indices.Length < 0xFFFF)
{
var indicesShort = new ushort[indices.Length];
for (int i = 0; i < indicesShort.Length; i++)
{
indicesShort[i] = (ushort)indices[i];
}
meshDraw.IndexBuffer = new IndexBufferBinding(Buffer.Index.New(graphicsDevice, indicesShort).RecreateWith(indicesShort), false, indices.Length);
if (needsTempDevice)
{
var indexData = BufferData.New(BufferFlags.IndexBuffer, indicesShort);
meshDraw.IndexBuffer = new IndexBufferBinding(indexData.ToSerializableVersion(), false, indices.Length);
}
}
else
{
if (graphicsDevice.Features.CurrentProfile <= GraphicsProfile.Level_9_3)
{
throw new InvalidOperationException("Cannot generate more than 65535 indices on feature level HW <= 9.3");
}
meshDraw.IndexBuffer = new IndexBufferBinding(Buffer.Index.New(graphicsDevice, indices).RecreateWith(indices), true, indices.Length);
if (needsTempDevice)
{
var indexData = BufferData.New(BufferFlags.IndexBuffer, indices);
meshDraw.IndexBuffer = new IndexBufferBinding(indexData.ToSerializableVersion(), true, indices.Length);
}
}
var vertexBuffer = Buffer.New(graphicsDevice, vertexBufferData, BufferFlags.VertexBuffer, GraphicsResourceUsage.Default);
meshDraw.VertexBuffers = [ new VertexBufferBinding(vertexBuffer.RecreateWith(vertexBufferData), layout, data.Vertices.Length) ];
if (needsTempDevice)
{
var vertexData = BufferData.New(BufferFlags.VertexBuffer, vertexBufferData);
meshDraw.VertexBuffers = [ new VertexBufferBinding(vertexData.ToSerializableVersion(), layout, data.Vertices.Length) ];
}
View on GitHub (pinned to 96fad776d2)