-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Performance of Hidden Entities #190
Comments
Yeah theres definitely a lot of work to do on the performance front. I think Transform gpu buffer construction also plays a role in this. Off the top of my head, the clear improvements to be made are:
I think it makes sense to scope this issue to (1). |
I added a PR to resolve item 1 on @cart's list. A couple checks for
However, there does appear to be a larger issue to resolve here - on a whim, I despawned the entities instead of setting This is the same as what occurs when you remove the Will keep looking into this to see if I can find the root cause, but I'm not totally confident in my ability to do so ;) Any tips or assistance welcome! |
Fantastic! The remaining perf drop is almost certainly the GPU buffers not resizing when entities are removed. |
We dont want to resize them every time an entity is removed as that would be expensive. So we should probably use array management techniques similar to Vec implementations. |
You don't necessarily need to resize the buffers unless you're short of GPU memory, can just make sure next time you upload data you only upload as much data into the buffer as you have entities for, should definitely work out the problem, though I imagine this is what you're planning already probably? |
A user ran into this issue again today while testing hiding entities to perform tile map chunking: https://discord.com/channels/691052431525675048/743664267856838736/799944389023629322 Spawning and despawning the entities completely resulted in a 3x performance gain over toggling their visibility, which was very surprising to me. |
This should be greatly improved by #1492 and related PRs. |
Closing as frustum culling is now merged. |
We currently have 2 options to "hide" entities (stop them from rendering - i.e. if off-screen/out of camera field of view):
is_visible
field in theDraw
component to falseDraw
component from the entityI did some testing with a system to check if the entity was within my camera's view (2D camera with center origin):
I had to add a time check because the program panics if you delete
Draw
too early (it's a failed assert within wgpu related to removing abandoned assets).My Tests
Baseline: Rendering Everything
Running the system with those two lines commented out (exactly as shown above):
Test 1: Set
is_visible
to falseRunning the system with the
draw.is_visible = false;
line activeSetting
is_visible
to false upon creation provides the same resultsTest 2: Remove
Draw
component entirelyRunning the system with the
commands.remove_one::<Draw>(entity);
line activeRemoving other render-related components did not appear to change the fps at all.
The text was updated successfully, but these errors were encountered: