Skip to content

Commit ddb512f

Browse files
initial pass at sorted-and-binned render phase items and resources, including rc non-mesh fixes
1 parent 49ab2c4 commit ddb512f

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

release-content/0.14/migration-guides/12453_Improve_performance_by_binning_together_opaque_items_inste.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

release-content/0.14/migration-guides/13277_Make_render_phases_render_world_resources_instead_of_compo.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Usage of `PhaseItem` has been split into `BinnedPhaseItem` and `SortedPhaseItem`. If you have custom `PhaseItem`s you will need to choose one of the new types. Notably some phases _must_ be Sorted (such as Transparent and Transmissive), while others can be Binned. Effectively Sorted is "what Bevy did before" and Binned is new, and the point of this change is to avoid sorting when possible for improved performance.
2+
3+
If you're looking for a quick migration, consider picking [`SortedPhaseItem`](https://docs.rs/bevy/0.14.0-rc.4/bevy/render/render_phase/trait.SortedPhaseItem.html) which requires the fewest code changes.
4+
5+
If you're looking for higher performance (and your phase doesn’t require sorting) you may want to pick [`BinnedPhaseItem`](https://docs.rs/bevy/0.14.0-rc.4/bevy/render/render_phase/trait.BinnedPhaseItem.html). Notably bins are populated based on `BinKey` and everything in the same bin is potentially batchable.
6+
7+
If you are only consuming these types, then a `Query` for a type like `&mut RenderPhase<Transparent2d>` will become a `Resource` as such:
8+
9+
```rust
10+
mut transparent_render_phases: ResMut<ViewSortedRenderPhases<Transparent2d>>
11+
```
12+
13+
`ViewSortedRenderPhases` and `ViewBinnedRenderPhases` are used in accordance with which phase items you're trying to access (sorted or binned).
14+
15+
Examples of [`SortedPhaseItems`s](https://docs.rs/bevy/0.14.0-rc.4/bevy/render/render_phase/trait.SortedPhaseItem.html#implementors):
16+
17+
- Transmissive3d
18+
- Transparent2d
19+
- Transparent3d
20+
- TransparentUi
21+
22+
Examples of [`BinnedPhaseItem`s](https://docs.rs/bevy/0.14.0-rc.4/bevy/render/render_phase/trait.BinnedPhaseItem.html#implementors) include:
23+
24+
- Opaque3d
25+
- Opaque3dPrepass
26+
- Opaque3dDeferred
27+
- AlphaMask3d
28+
- AlphaMask3dPrepass
29+
- AlphaMask3dDeferred
30+
- [Shadow](https://docs.rs/bevy/0.14.0-rc.4/bevy/pbr/struct.Shadow.html)
31+
32+
If you do not have a mesh (such as for GPU-driven particles or procedural generation) and want to use the new binned behavior, the [`BinnedRenderPhase`](https://docs.rs/bevy/0.14.0-rc.4/bevy/render/render_phase/struct.BinnedRenderPhase.html) includes a new `non_mesh_items` collection which correlates with a new [`BinnedRenderPhaseType`](https://docs.rs/bevy/0.14.0-rc.4/bevy/render/render_phase/struct.BinnedRenderPhase.html). This type is used when [add](https://docs.rs/bevy/0.14.0-rc.4/bevy/render/render_phase/struct.BinnedRenderPhase.html#method.add)ing items to the `BinnedRenderPhase`.
33+
34+
It may be additionally useful to checkout the new [custom_phase_item example](https://github.com/bevyengine/bevy/blob/5876352206d1bcea792825bf013eb212383b73d6/examples/shader/custom_phase_item.rs) which details some of the new APIs.

0 commit comments

Comments
 (0)