bevy/crates/bevy_pbr/src
Brian Reavis d40c5b54ae
Material, mesh, skin extraction optimization (#17976)
# Objective

The extraction systems for materials, meshes, and skins previously
iterated over `RemovedComponents<ViewVisibility>` in addition to more
specific variants like `RemovedComponents<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.

<img width="1091" alt="Screenshot 2025-02-21 at 10 28 01 AM"
src="https://github.com/user-attachments/assets/63fec1c9-232c-45f6-9150-daf8751ecf85"
/>

## Solution

This PR removes superfluous `RemovedComponents` iteration for
`ViewVisibility` and `GlobalTransform`, ensuring that we only iterate
over the most specific `RemovedComponents` relevant to the system (e.g.,
material components, mesh components). This is guaranteed to match what
the system originally collected.

### Before (red) / After (yellow):
<img width="838" alt="Screenshot 2025-02-21 at 10 46 17 AM"
src="https://github.com/user-attachments/assets/0e06b06d-7e91-4da5-a919-b843eb442a72"
/>
Log plot to highlight the long tail that this PR is addressing.
2025-07-09 06:23:44 +00:00
..
atmosphere Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
decal bevy_light (#19991) 2025-07-07 00:07:38 +00:00
deferred bevy_light (#19991) 2025-07-07 00:07:38 +00:00
light_probe Move IrradianceVolume to bevy_light (#20000) 2025-07-07 20:11:43 +00:00
lightmap Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
meshlet Clean up several miscellaneous uses of weak_handle. (#19408) 2025-07-08 06:45:40 +00:00
prepass Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
render Material, mesh, skin extraction optimization (#17976) 2025-07-09 06:23:44 +00:00
ssao Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
ssr Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
volumetric_fog Clean up several miscellaneous uses of weak_handle. (#19408) 2025-07-08 06:45:40 +00:00
cluster.rs bevy_light (#19991) 2025-07-07 00:07:38 +00:00
components.rs move some Visibility stuff to bevy_camera::visibility (#19954) 2025-07-05 13:24:20 +00:00
extended_material.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
fog.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
lib.rs Move IrradianceVolume to bevy_light (#20000) 2025-07-07 20:11:43 +00:00
material_bind_groups.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
material.rs Material, mesh, skin extraction optimization (#17976) 2025-07-09 06:23:44 +00:00
mesh_material.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
parallax.rs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
pbr_material.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
wireframe.rs Allow calling add_render_graph_node on World. (#19912) 2025-07-02 14:56:18 +00:00