Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions crates/bevy_sprite_render/src/mesh2d/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,10 +969,6 @@ pub fn queue_material2d_meshes(
specialized_material_pipeline_cache: ResMut<SpecializedMaterial2dPipelineCache>,
mut mesh_instances_queued_this_iteration_scratch_space: Local<MainEntityHashSet>,
) {
if render_material_instances.is_empty() {
return;
}

for (view, visible_entities) in &views {
let Some(view_specialized_material_pipeline_cache) =
specialized_material_pipeline_cache.get(&view.retained_view_entity)
Expand Down Expand Up @@ -1023,6 +1019,14 @@ pub fn queue_material2d_meshes(
alpha_mask_phase.remove(*main_entity);
}

// With no entity using this material there is nothing to queue, but the
// dequeue above still has to run: it is the only thing that takes items
// of despawned entities out of the retained phases, and it has to run on
// the very frame the last such entity goes away.
if render_material_instances.is_empty() {
continue;
}

// Now iterate over all newly-visible entities and those that need
// specialization.
for (render_entity, visible_entity) in dirty_specializations.iter_to_queue(
Expand Down