-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Material, mesh, skin extraction optimization #17976
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
Material, mesh, skin extraction optimization #17976
Conversation
The reason for iterating over |
Isn't it impossible to remove #[derive(Component, ...)]
#[require(Transform, Visibility, VisibilityClass)]
pub struct Mesh3d(pub Handle<Mesh>); #[derive(Component, ...)]
#[require(InheritedVisibility, ViewVisibility)]
pub enum Visibility { ... } |
I don't think this should be blocked by #18514 or other solutions for these reasons:
|
7f0f2ca
to
5f9ca02
Compare
Unfortunately I do think this should be blocked on required component invariant enforcement. This is a win but at the price of a behavioral regression that will probably affect some users |
This won't cause a behavioral change because the worst case scenario is that |
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.
Sounds reasonable to me. I am trusting that this has no negative side effects other than the potential memory leak if those entities are not despawned. But I kind of expect we have a number of cases of that in the render world, just that they haven’t been significant enough for someone to do something about them yet.
Objective
The extraction systems for materials, meshes, and skins previously iterated over
RemovedComponents<ViewVisibility>
in addition to more specific variants likeRemovedComponents<MeshMaterial3d<M>>
. This caused each system to loop through and check many irrelevant despawned entities—sometimes multiple times. With many material types, this overhead added up and became noticeable in frames with many despawns.Solution
This PR removes superfluous
RemovedComponents
iteration forViewVisibility
andGlobalTransform
, ensuring that we only iterate over the most specificRemovedComponents
relevant to the system (e.g., material components, mesh components). This is guaranteed to match what the system originally collected.Before (red) / After (yellow):