Skip to content

Commit

Permalink
Ensure 2D phase items are sorted before batching (#5942)
Browse files Browse the repository at this point in the history
# Objective

Without this we can inappropriately merge batches together without properly accounting for non-batch items between them, and the merged batch will then be sorted incorrectly later.

This change seems to reliably fix the issue I was seeing in #5919.

## Solution

Ensure the `batch_phase_system` runs after the `sort_phase_system`, so that batching can only look at actually adjacent phase items.
  • Loading branch information
asherkin committed Sep 11, 2022
1 parent 6f2cc0b commit bb7f521
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/bevy_core_pipeline/src/core_2d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ impl Plugin for Core2dPlugin {
.init_resource::<DrawFunctions<Transparent2d>>()
.add_system_to_stage(RenderStage::Extract, extract_core_2d_camera_phases)
.add_system_to_stage(RenderStage::PhaseSort, sort_phase_system::<Transparent2d>)
.add_system_to_stage(RenderStage::PhaseSort, batch_phase_system::<Transparent2d>);
.add_system_to_stage(
RenderStage::PhaseSort,
batch_phase_system::<Transparent2d>.after(sort_phase_system::<Transparent2d>),
);

let pass_node_2d = MainPass2dNode::new(&mut render_app.world);
let mut graph = render_app.world.resource_mut::<RenderGraph>();
Expand Down

1 comment on commit bb7f521

@sclickk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should really join these systems like I did here. Seems like a waste to iterate the RenderPhases twice.

Please sign in to comment.