Skip to content

Commit f20f019

Browse files
mockersftjamaan
authored andcommitted
don't run create_surfaces system if not needed (bevyengine#11720)
# Objective - Change set of systems as I made a mistake in bevyengine#11672 - Don't block main when not needed - Fixes bevyengine#11235 ## Solution - add a run condition so that the system won't run and block main if not needed
1 parent f6b5c9b commit f20f019

File tree

1 file changed

+19
-2
lines changed
  • crates/bevy_render/src/view/window

1 file changed

+19
-2
lines changed

crates/bevy_render/src/view/window/mod.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ impl Plugin for WindowRenderPlugin {
4343
.init_resource::<ExtractedWindows>()
4444
.init_resource::<WindowSurfaces>()
4545
.add_systems(ExtractSchedule, extract_windows)
46-
.add_systems(Render, prepare_windows.in_set(RenderSet::PrepareAssets))
47-
.add_systems(Render, create_surfaces.in_set(RenderSet::ManageViews));
46+
.add_systems(
47+
Render,
48+
create_surfaces
49+
.run_if(need_new_surfaces)
50+
.in_set(RenderSet::PrepareAssets),
51+
)
52+
.add_systems(Render, prepare_windows.in_set(RenderSet::ManageViews));
4853
}
4954
}
5055

@@ -419,6 +424,18 @@ pub fn prepare_windows(
419424
}
420425
}
421426

427+
pub fn need_new_surfaces(
428+
windows: Res<ExtractedWindows>,
429+
window_surfaces: Res<WindowSurfaces>,
430+
) -> bool {
431+
for window in windows.windows.values() {
432+
if !window_surfaces.configured_windows.contains(&window.entity) {
433+
return true;
434+
}
435+
}
436+
false
437+
}
438+
422439
/// Creates window surfaces.
423440
pub fn create_surfaces(
424441
// By accessing a NonSend resource, we tell the scheduler to put this system on the main thread,

0 commit comments

Comments
 (0)