{"record":{"id":"3eca4e0065fe3186","repo":"stride3d/stride","slug":"cannot-generate-more-than-65535-indices-on-feature-level-hw","errorCode":null,"errorMessage":"Cannot generate more than 65535 indices on feature level HW <= 9.3","messagePattern":"Cannot generate more than 65535 indices on feature level HW <= 9\\.3","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/GeometricPrimitives/GeometricPrimitive.cs","lineNumber":96,"sourceCode":"            var indices = geometryMesh.Indices;\n\n            if (geometryMesh.IsLeftHanded)\n                ReverseWinding(vertices, indices);\n\n            if (indices.Length < 0xFFFF)\n            {\n                var indicesShort = new ushort[indices.Length];\n                for (int i = 0; i < indicesShort.Length; i++)\n                {\n                    indicesShort[i] = (ushort)indices[i];\n                }\n                IndexBuffer = Buffer.Index.New(graphicsDevice, indicesShort).RecreateWith(indicesShort).DisposeBy(this);\n            }\n            else\n            {\n                if (graphicsDevice.Features.CurrentProfile <= GraphicsProfile.Level_9_3)\n                {\n                    throw new InvalidOperationException(\"Cannot generate more than 65535 indices on feature level HW <= 9.3\");\n                }\n\n                IndexBuffer = Buffer.Index.New(graphicsDevice, indices).RecreateWith(indices).DisposeBy(this);\n                IsIndex32Bits = true;\n            }\n\n            // For now it will keep buffers for recreation.\n            // TODO: A better alternative would be to store recreation parameters so that we can reuse procedural code.\n            VertexBuffer = Buffer.Vertex.New(graphicsDevice, vertices).RecreateWith(vertices).DisposeBy(this);\n            VertexBufferBinding = new VertexBufferBinding(VertexBuffer, new T().GetLayout(), vertices.Length);\n\n            PipelineState.State.SetDefaults();\n            PipelineState.State.InputElements = VertexBufferBinding.Declaration.CreateInputElements();\n            PipelineState.State.PrimitiveType = PrimitiveQuad.PrimitiveType;\n        }\n\n        /// <summary>\n        /// Draws this <see cref=\"GeometricPrimitive\" />.","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/GeometricPrimitives/GeometricPrimitive.cs#L78-L114","documentation":"When a geometric primitive needs 32-bit indices (more than 65535 vertices/indices) the underlying feature level must support them. On GraphicsProfile.Level_9_3 or lower hardware, 32-bit index buffers are unavailable, so constructing such a primitive throws. This protects against creating index buffers the GPU cannot consume.","triggerScenarios":"Creating a GeometricPrimitive (e.g. GeometricPrimitive.Sphere/Plane with high tessellation) whose index count exceeds 65535 while graphicsDevice.Features.CurrentProfile <= GraphicsProfile.Level_9_3.","commonSituations":"Targeting low-end hardware, old GPUs, or software renderers limited to DirectX feature level 9.x; requesting very high tessellation/segment counts on primitives; running on devices (e.g. old mobile GPUs) where the app fell back to Level_9_3.","solutions":["Reduce primitive tessellation (fewer segments/subdivisions) so index count stays at or below 65535.","Require a higher GraphicsProfile: request Level_10_0 or above when creating the GraphicsDevice.","Check graphicsDevice.Features.CurrentProfile at startup and fall back to lower-detail meshes on Level_9_3 devices.","Split the mesh into multiple primitives each under 65535 indices."],"exampleFix":"// before\nvar sphere = new GeometricPrimitive(GraphicsDevice, SphereProceduralModel.Default { Tessellation = 256 });\n// after\nvar tessellation = GraphicsDevice.Features.CurrentProfile <= GraphicsProfile.Level_9_3 ? 32 : 128;\nvar sphere = new GeometricPrimitive(GraphicsDevice, SphereProceduralModel.Default { Tessellation = tessellation });","handlingStrategy":"validation","validationCode":"if (indices.Length > 65535 &&\n    graphicsDevice.Features.CurrentProfile <= GraphicsProfile.Level_9_3)\n    throw new NotSupportedException(\"32-bit indices unsupported at this profile\");","typeGuard":"bool Supports32BitIndices(GraphicsDevice d) => d.Features.CurrentProfile > GraphicsProfile.Level_9_3;","tryCatchPattern":"try { return new GeometricPrimitive(device, model); }\ncatch (InvalidOperationException) { return BuildLowDetailPrimitive(device); }","preventionTips":["Check Features.CurrentProfile before building high-tessellation meshes","Cap tessellation parameters at UI/asset level","Design LOD fallbacks for Level_9_3 devices"],"tags":["csharp","graphics","gpu-compatibility"],"backgroundTag":"unsupported-platform","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}