Efficiently filling the vertex buffer

Hi fellow devs,

I wonder what’s the most efficient way of filling the vertex buffer? I used one big buffer but filled it with a for loop iterating over thousands of meshes and calling VertexBuffer::SetData for each of them with an offset.

This was very slow. Then I tried to set the whole thing at once with about 512MiB of data. That was much faster. So I guess setting it in large chunks would be the best way to go. But where is the limit? What would be a good chunk size? What would be a good vertex buffer size?

Hope you’ve got some ideas : )

Cheers,
Georg

PS: Here are the resource limits in DX11.

Please do not ask in other topics about this. If anyone knows what to do, they will answer in the topic you created.

My vertices have a stride of 32 Byte. The Model is about 500MB large. If I can use Vertex Buffers of 128MB each, that means each buffer can store 4,000,000 vertices, right?

What I did now is filling vertex buffers of max. 128 MB each and thereby slicing up the main mesh. To make it as fast as I could get it, I created the vertex arrays with ArrayPools and SIMD and then drew the vertex buffers with one draw call per buffer.

If you can think of a better solution, please let me know : )

for( var i = 0; i < _VertexBuffers.Length; i++ )
{
  GraphicsDevice.SetVertexBuffer( _VertexBuffers[ i ] );
  GraphicsDevice.Indices = _IndexBuffers[ i ];

  GraphicsDevice.DrawIndexedPrimitives(
    PrimitiveType.TriangleList,
    0,
    0,
    _Slices[ i ].PrimitiveCount );
}