stride3d/stride · error · ArgumentNullException
vertexBufferData
Error message
vertexBufferData
What it means
The generic T[] overload of GenerateMultiTextureCoordinates throws ArgumentNullException('vertexBufferData') when the vertex data array is null. The array is pinned and scanned for TEXCOORD elements, so null data is unusable.
Solutions
- Ensure the vertex data array is allocated and populated before calling the helper.
- Add an explicit null/empty check with a clear error before the call.
- Fix the loading path that produced the null array.
Example fix
// before
var result = VertexHelper.GenerateMultiTextureCoordinates(declaration, vertices);
// after
if (vertices == null || vertices.Length == 0) throw new InvalidOperationException("Vertex data must be loaded first");
var result = VertexHelper.GenerateMultiTextureCoordinates(declaration, vertices); Defensive patterns
Strategy: validation
Validate before calling
if (vertexBufferData is null || vertexBufferData.Length == 0) throw new InvalidOperationException("Vertex data array must be loaded and non-empty"); Type guard
bool HasVertexData<T>(T[] data) where T : unmanaged => data is { Length: > 0 }; Try / catch
try { var r = VertexHelper.GenerateMultiTextureCoordinates(decl, data); } catch (ArgumentNullException ex) when (ex.ParamName == "vertexBufferData") { /* load mesh data first */ } Prevention
- Load vertex arrays before running vertex transformations
- Check content-load results for null before proceeding
- Keep buffer allocation and its consumers in the same initialization path
When it happens
Trigger: Calling VertexHelper.GenerateMultiTextureCoordinates<T>(declaration, (T[])null) — e.g. a mesh whose vertex buffer array was never allocated or was set to null by a failed load.
Common situations: Mesh import returned no vertex data; array field default-initialized; asynchronous content loading finished out of order.
Related errors
- vertexDeclaration
- The relativePath argument is null or empty
- Invalid length for FourCC
- Invalid Z slice index
- The length of the destination data buffer is larger than…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/19cf822a3adab73c.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/VertexHelper.cs:38
/// <summary>
/// Generates multi texture coordinates for an existing vertex buffer. See remarks.
/// </summary>
/// <param name="vertexDeclaration">The vertex declaration.</param>
/// <param name="vertexBufferData">The vertex buffer data.</param>
/// <param name="maxTexcoord">The maximum texcoord.</param>
/// <returns>A new vertex buffer with additional texture coordinates.</returns>
/// <exception cref="System.ArgumentNullException">
/// vertexDeclaration
/// or
/// vertexBufferData
/// </exception>
/// <remarks>The original vertex buffer must contain at least a TEXCOORD[0-9] attribute in order for this method to work.
/// This method will copy the value of the first existing TEXCOORD found in the vertex buffer to the newly created TEXCOORDS.</remarks>
public static unsafe VertexTransformResult GenerateMultiTextureCoordinates<T>(VertexDeclaration vertexDeclaration, T[] vertexBufferData, int maxTexcoord = 9) where T : unmanaged
{
if (vertexDeclaration == null) throw new ArgumentNullException("vertexDeclaration");
if (vertexBufferData == null) throw new ArgumentNullException("vertexBufferData");
var vertexStride = Unsafe.SizeOf<T>();
fixed (void* vertexBufferPtr = vertexBufferData)
return GenerateMultiTextureCoordinates(vertexDeclaration, (nint)vertexBufferPtr, vertexBufferData.Length, 0, vertexStride, maxTexcoord);
}
/// <summary>
/// Generates multi texture coordinates for an existing vertex buffer. See remarks.
/// </summary>
/// <param name="vertexDeclaration">The vertex declaration.</param>
/// <param name="vertexBufferData">The vertex buffer data.</param>
/// <param name="vertexStride">The vertex stride.</param>
/// <param name="maxTexcoord">The maximum texcoord.</param>
/// <returns>A new vertex buffer with additional texture coordinates.</returns>
/// <exception cref="System.ArgumentNullException">
/// vertexDeclaration
/// or
/// vertexBufferData
/// </exception>View on GitHub (pinned to 96fad776d2)