Skip to content

Commit e4f3cc6

Browse files
authored
Merge pull request #523 from MeoMix/patch-2
Fix ambiguous `queue_material_tilemap_meshes` ordering
2 parents 25def41 + e53e52e commit e4f3cc6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/render/material.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use super::{
3030
chunk::{ChunkId, RenderChunk2dStorage},
3131
draw::DrawTilemapMaterial,
3232
pipeline::{TilemapPipeline, TilemapPipelineKey},
33+
prepare,
3334
queue::{ImageBindGroups, TilemapViewBindGroup},
3435
};
3536

@@ -127,7 +128,14 @@ where
127128
.add_systems(
128129
Render,
129130
(
130-
queue_material_tilemap_meshes::<M>.in_set(RenderSet::Queue),
131+
// Ensure `queue_material_tilemap_meshes` runs after `prepare::prepare` because `prepare` calls `commands.spawn` with `ChunkId`
132+
// and that data is then consumed by `queue_material_tilemap_mesh`. This is important because `prepare` is part of the `PrepareAssets`
133+
// set. Bevy is loose on its expectation of when systems in the `PrepareAssets` set execute (for performance) and only needs them
134+
// to run before the `Prepare` set (which is after Queue). This invites the possibility of an intermittent incorrect ordering dependent
135+
// on the scheduler.
136+
queue_material_tilemap_meshes::<M>
137+
.in_set(RenderSet::Queue)
138+
.after(prepare::prepare),
131139
bind_material_tilemap_meshes::<M>.in_set(RenderSet::PrepareBindGroups),
132140
),
133141
);

0 commit comments

Comments
 (0)