stride3d/stride · error · ArgumentException
Need at least 1 MeshDrawData.
Error message
Need at least 1 MeshDrawData.
What it means
MeshDraw.MergeDrawData combines multiple MeshDraw instances into one, which is meaningless for an empty list, so it throws ArgumentException ('meshDrawDatas') when Count == 0. At least one MeshDrawData is required for the merge to produce output.
Solutions
- Check meshDrawDatas.Count > 0 before calling MergeDrawData
- Skip the merge/GroupDrawData path for empty groups
- Fix upstream filtering that produced an empty mesh list
Example fix
// before var merged = MeshDraw.MergeDrawData(meshDraws, can32BitIndex); // after if (meshDraws.Count == 0) return null; var merged = MeshDraw.MergeDrawData(meshDraws, can32BitIndex);
Defensive patterns
Strategy: validation
Validate before calling
if (meshDrawDatas == null || meshDrawDatas.Count == 0) return null; var merged = MeshDraw.MergeDrawData(meshDrawDatas, can32BitIndex);
Type guard
static bool Mergeable(IList<MeshDraw> list) => list != null && list.Count > 0;
Try / catch
try { var merged = MeshDraw.MergeDrawData(meshDrawDatas, can32BitIndex); } catch (ArgumentException) { /* empty input list */ } Prevention
- Early-return from group/batching code when no meshes were collected
- Assert non-empty collections at group boundaries
When it happens
Trigger: Passing an empty IList<MeshDraw> to MergeDrawData, typically via GroupDrawData with a group that produced no meshes.
Common situations: Mesh grouping/culling pipelines where a material or draw group ends up with zero entries due to filtering, then is merged unconditionally.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Can only merge simple MeshDrawData.
- The queue is empty
- cannot be empty.
- RenderView is null. Please make sure you have your camera…
- Unsupported depth format
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/663bbb18c352ca6c.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Extensions/MergeExtensions.cs:24
using System.Runtime.InteropServices;
using Stride.Core;
using Stride.Graphics;
using Stride.Graphics.Data;
using Stride.Rendering;
namespace Stride.Extensions
{
public static class MergeExtensions
{
/// <summary>
/// Transform a vertex buffer positions, normals, tangents and bitangents using the given matrix.
/// </summary>
/// <param name="meshDrawDatas">The mesh draw datas.</param>
/// <param name="can32BitIndex">A flag stating if 32 bit index buffers.</param>
public static unsafe MeshDraw MergeDrawData(IList<MeshDraw> meshDrawDatas, bool can32BitIndex)
{
if (meshDrawDatas.Count == 0)
throw new ArgumentException("Need at least 1 MeshDrawData.", "meshDrawDatas");
if (meshDrawDatas.Count == 1)
return meshDrawDatas[0];
// Check that vertex buffer declarations are matching
var firstMeshDrawData = meshDrawDatas[0];
if (!firstMeshDrawData.IsSimple())
throw new InvalidOperationException("Can only merge simple MeshDrawData.");
var firstVertexBuffer = firstMeshDrawData.VertexBuffers[0];
var hasIndexBuffer = IsIndexed(meshDrawDatas);
int totalVertexCount = 0;
int totalIndexCount = 0;
//TODO: extend to non-simple vertex declarations, fill with default values it missing declarations etc. ?
for (int i = 0; i < meshDrawDatas.Count; i++)
{View on GitHub (pinned to 96fad776d2)