XNA VertexBuffer.SetData performance suggestions
Posted
by
CodeSpeaker
on Game Development
See other posts from Game Development
or by CodeSpeaker
Published on 2011-04-13T19:35:05Z
Indexed on
2011/06/26
16:31 UTC
Read the original article
Hit count: 214
xna-4.0
I have a 3d world in a grid layout where each grid cell contains its separate vertex and index buffer for the mesh/terrain of that cell.
When the player moves outside the boundaries of his cell, i dynamically load more cells in his walking direction based on his viewing distance. This triggers x number of vertex and indexbuffer initializations depending on how many cells that needs to be generated and causes the framerate to drop annoyingly during this time.
The generation of terrain data is handled in a separate thread and runs smoothly. The vertex and index buffers are added during the update cycle of the game loop.
I´ve tried batching the number of cells to be processed to avoid sending too much data at once into the buffers, which worked ok at a shorter viewing distance (about 9 cells to process), but not as well at greater distances with around 30 cells to process.
Any idea how i can optimize this?
© Game Development or respective owner