-
I draw quite a few lines in my app, using the basic example from bevy as a starting point. Everything is alright if there aren't too many line entities, but the framerate drops substantially if I have ~2,400 line entities. Is quite unexpected given the performance possible with full meshes that contain lots and lots of polygons where I get the full 60 FPS (so same number of entities but with more complicated geometry). I haven't done any flamegraphs on this, I just know from turning lines on and off that they seem to kill the framerate. At the same time I also draw two dimensional meshes and they have a similar effect on the frame rate, but that can be a separate discussion. My main issue is the lines. Suppose one workaround I could try is to draw everything as a single Could someone point me in the right direction for how to remedy this? Do I need to somehow batch the line drawing shader? Have never coded shaders before. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It depends on your use case. Your code probably diverges a lot from the basic example you linked, so I have to make additional assumptions on how your code looks like to give any guess on why it slows down. It sounds like you have a single entity per line. Bevy has poor performance with large entity count (especially if they are rendered). As you mentioned, it would be better to have a single mesh to update rather than a bunch of meshes. Consider having a single resource for lines, push lines to that resource, and a system that updates a mesh each frame based on that resource. this is how the future 0.11 bevy debug line feature will work. In this case, you don't have to manipulate shader code, just be careful when building the mesh. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the reference, didn't know someone was working on such a feature already! I'll have to keep it in mind, and may have to port my line drawing code from being entity based over to debug line based. I'll keep it entity based for now though, as ECS is so convenient to use and don't have the resource to re-write at this point in time. |
Beta Was this translation helpful? Give feedback.
It depends on your use case. Your code probably diverges a lot from the basic example you linked, so I have to make additional assumptions on how your code looks like to give any guess on why it slows down.
It sounds like you have a single entity per line. Bevy has poor performance with large entity count (especially if they are rendered). As you mentioned, it would be better to have a single mesh to update rather than a bunch of meshes. Consider having a single resource for lines, push lines to that resource, and a system that updates a mesh each frame based on that resource. this is how the future 0.11 bevy debug line feature will work. In this case, you don't have to manipulate shader …