-
-
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
Retain RenderMaterialInstances
and RenderMeshMaterialIds
from frame to frame.
#16985
Retain RenderMaterialInstances
and RenderMeshMaterialIds
from frame to frame.
#16985
Conversation
to frame. This commit makes Bevy use change detection to only update `RenderMaterialInstances` and `RenderMeshMaterialIds` when meshes have been added, changed, or removed. `extract_mesh_materials`, the system that extracts these, now follows the pattern that `extract_meshes_for_gpu_building` established. This improves frame time of `many_cubes` from 3.9ms to approximately 3.1ms, which slightly surpasses the performance of Bevy 0.14.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice and simple. It's nice that we can finally take advantage of the retained world.
It's unfortunate that we need to duplicate this for 2d, but figuring out an abstraction for that is definitely future work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that in practice the query for Changed<ViewVisibility>
was firing every frame. It seems to be an issue in our lighting code see pcwalton#7.
@tychedelia Cherry-picked over, thanks! |
There are some fairly serious bugs that have required a rewrite of a good deal of this patch. |
Running another example test run; I'll merge this in if that comes up clean :) |
The colors in the examples in this PR seem messed up; are materials being batched correctly? See TheBevyFlock/bevy-example-runner#87 (comment) |
Hmm, I'm having trouble reproducing the failures. It may be some kind of race... |
OK, looks like that fixed the race. I'll look at the regressions. |
All of the failures look either like things that were broken already (the pre-existing wireframe problem having to do with the fact that it breaks the 1:1 entity:material relationship), or are false positives. So I think this is ready to go. |
This commit makes Bevy use change detection to only update
RenderMaterialInstances
andRenderMeshMaterialIds
when meshes have been added, changed, or removed.extract_mesh_materials
, the system that extracts these, now follows the pattern thatextract_meshes_for_gpu_building
established.This improves frame time of
many_cubes
from 3.9ms to approximately 3.1ms, which slightly surpasses the performance of Bevy 0.14.(Resubmitted from #16878 to clean up history.)