From bb7f521f91df4ce1b3f33fbb2efdf2ce26098c0b Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 11 Sep 2022 15:26:40 +0000 Subject: [PATCH] Ensure 2D phase items are sorted before batching (#5942) # 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. --- crates/bevy_core_pipeline/src/core_2d/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/bevy_core_pipeline/src/core_2d/mod.rs b/crates/bevy_core_pipeline/src/core_2d/mod.rs index 69db8d4ad4..6db7ef7665 100644 --- a/crates/bevy_core_pipeline/src/core_2d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_2d/mod.rs @@ -46,7 +46,10 @@ impl Plugin for Core2dPlugin { .init_resource::>() .add_system_to_stage(RenderStage::Extract, extract_core_2d_camera_phases) .add_system_to_stage(RenderStage::PhaseSort, sort_phase_system::) - .add_system_to_stage(RenderStage::PhaseSort, batch_phase_system::); + .add_system_to_stage( + RenderStage::PhaseSort, + batch_phase_system::.after(sort_phase_system::), + ); let pass_node_2d = MainPass2dNode::new(&mut render_app.world); let mut graph = render_app.world.resource_mut::();