You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We create too many vertexbuffers, for example every single entity (yes, every entity. not just every model) gets its own vertexbuffer.
This is obviously very wasteful, any operation involving the graphicsdevice needs to be ran on the UI thread. This means that everytime we create or update a vertexbuffer, indexbuffer or texture we need queue that task up on the UI thread. This slows down the render/update loop a considerable amount, creating lag spikes or even causing the game to freeze completely.
The Solution
Entity & Item models
For models we could start using model instancing, this means we only create 1 vertexbuffer for every model. We can then use that same vertexbuffer for every instance of that model we need to draw. Exceptions to this would be when a player has unique geometry data. In this case we would still need to create a new buffer just for that player.
Chunks
Instead of creating a new vertexbuffer for each individual chunk we could also create 1 world vertexbuffer (Let's say we allocate 1gb of gpu memory) and allocate sections of that to each chunk. This does come with the overhead of having to keep track of allocated sections however. I'm also not sure what impact this will actually have on performance. This also does not solve the fact that we still need to send buffer updates to the gpu, it will however solve the issue of having to create a new vertexbuffer everytime the size of a chunks vertexbuffer increases (by placing blocks for example).
Another thing i have been thinking about is how we can keep track of updated vertices in a chunk, so when a user places a block for example we only send the new vertices of that block to the gpu instead of having to recalculate and resend the whole vertex array of that chunkcolumn to the gpu.
This discussion was converted from issue #105 on December 21, 2021 23:41.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The Issue
We create too many vertexbuffers, for example every single entity (yes, every entity. not just every model) gets its own vertexbuffer.
This is obviously very wasteful, any operation involving the graphicsdevice needs to be ran on the UI thread. This means that everytime we create or update a vertexbuffer, indexbuffer or texture we need queue that task up on the UI thread. This slows down the render/update loop a considerable amount, creating lag spikes or even causing the game to freeze completely.
The Solution
Entity & Item models
For models we could start using model instancing, this means we only create 1 vertexbuffer for every model. We can then use that same vertexbuffer for every instance of that model we need to draw. Exceptions to this would be when a player has unique geometry data. In this case we would still need to create a new buffer just for that player.
Chunks
Instead of creating a new vertexbuffer for each individual chunk we could also create 1 world vertexbuffer (Let's say we allocate 1gb of gpu memory) and allocate sections of that to each chunk. This does come with the overhead of having to keep track of allocated sections however. I'm also not sure what impact this will actually have on performance. This also does not solve the fact that we still need to send buffer updates to the gpu, it will however solve the issue of having to create a new vertexbuffer everytime the size of a chunks vertexbuffer increases (by placing blocks for example).
Another thing i have been thinking about is how we can keep track of updated vertices in a chunk, so when a user places a block for example we only send the new vertices of that block to the gpu instead of having to recalculate and resend the whole vertex array of that chunkcolumn to the gpu.
Beta Was this translation helpful? Give feedback.
All reactions