Commit 36c6f29
Lighting Should Only hold Vec<Entity> instead of TypeId<Vec<Entity>> (#14073)
# Objective
- After #13894, I noticed the performance of `many_lights `dropped from
120+ to 60+. I reviewed the PR but couldn't identify any mistakes. After
profiling, I discovered that `Hashmap::Clone `was very slow when its not
empty, causing `extract_light` to increase from 3ms to 8ms.
- Lighting only checks visibility for 3D Meshes. We don't need to
maintain a TypeIdMap for this, as it not only impacts performance
negatively but also reduces ergonomics.
## Solution
- use VisibleMeshEntities for lighint visibility checking.
## Performance
cargo run --release --example many_lights --features bevy/trace_tracy
name="bevy_pbr::light::check_point_light_mesh_visibility"}

system{name="bevy_pbr::render::light::extract_lights"}

## Migration Guide
> now `SpotLightBundle` , `CascadesVisibleEntities `and
`CubemapVisibleEntities `use VisibleMeshEntities instead of
`VisibleEntities`
---------
Co-authored-by: Alice Cecile <[email protected]>1 parent e13c72d commit 36c6f29
3 files changed
+36
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
48 | 59 | | |
49 | 60 | | |
50 | 61 | | |
51 | 62 | | |
52 | | - | |
| 63 | + | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
56 | | - | |
| 67 | + | |
57 | 68 | | |
58 | 69 | | |
59 | 70 | | |
60 | | - | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
64 | | - | |
| 75 | + | |
65 | 76 | | |
66 | 77 | | |
67 | 78 | | |
68 | | - | |
| 79 | + | |
69 | 80 | | |
70 | 81 | | |
71 | 82 | | |
| |||
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
78 | | - | |
| 89 | + | |
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
| |||
98 | 109 | | |
99 | 110 | | |
100 | 111 | | |
101 | | - | |
| 112 | + | |
102 | 113 | | |
103 | 114 | | |
104 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
103 | | - | |
| 102 | + | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
| |||
698 | 697 | | |
699 | 698 | | |
700 | 699 | | |
701 | | - | |
702 | | - | |
703 | | - | |
| 700 | + | |
704 | 701 | | |
705 | 702 | | |
706 | 703 | | |
| |||
709 | 706 | | |
710 | 707 | | |
711 | 708 | | |
712 | | - | |
| 709 | + | |
713 | 710 | | |
714 | 711 | | |
715 | 712 | | |
| |||
790 | 787 | | |
791 | 788 | | |
792 | 789 | | |
793 | | - | |
794 | 790 | | |
795 | 791 | | |
796 | 792 | | |
| |||
801 | 797 | | |
802 | 798 | | |
803 | 799 | | |
804 | | - | |
| 800 | + | |
805 | 801 | | |
806 | 802 | | |
807 | 803 | | |
| |||
833 | 829 | | |
834 | 830 | | |
835 | 831 | | |
836 | | - | |
| 832 | + | |
837 | 833 | | |
838 | 834 | | |
839 | 835 | | |
| |||
869 | 865 | | |
870 | 866 | | |
871 | 867 | | |
872 | | - | |
| 868 | + | |
873 | 869 | | |
874 | 870 | | |
875 | 871 | | |
| |||
940 | 936 | | |
941 | 937 | | |
942 | 938 | | |
943 | | - | |
944 | 939 | | |
945 | | - | |
| 940 | + | |
946 | 941 | | |
947 | 942 | | |
948 | 943 | | |
949 | | - | |
| 944 | + | |
950 | 945 | | |
951 | 946 | | |
952 | 947 | | |
953 | 948 | | |
954 | 949 | | |
955 | 950 | | |
956 | 951 | | |
957 | | - | |
| 952 | + | |
958 | 953 | | |
959 | 954 | | |
960 | 955 | | |
| |||
1015 | 1010 | | |
1016 | 1011 | | |
1017 | 1012 | | |
1018 | | - | |
| 1013 | + | |
1019 | 1014 | | |
1020 | 1015 | | |
1021 | | - | |
| 1016 | + | |
1022 | 1017 | | |
1023 | 1018 | | |
1024 | 1019 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
1174 | 1174 | | |
1175 | 1175 | | |
1176 | 1176 | | |
1177 | | - | |
| 1177 | + | |
1178 | 1178 | | |
1179 | 1179 | | |
1180 | 1180 | | |
| |||
1218 | 1218 | | |
1219 | 1219 | | |
1220 | 1220 | | |
1221 | | - | |
| 1221 | + | |
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
| |||
0 commit comments