don't run create_surfaces system if not needed (#11720)

# Objective

- Change set of systems as I made a mistake in #11672 
- Don't block main when not needed
- Fixes #11235 

## Solution

- add a run condition so that the system won't run and block main if not
needed
This commit is contained in:
François 2024-02-05 22:33:46 +01:00 committed by GitHub
parent 312df3cec7
commit e927756d72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,8 +43,13 @@ impl Plugin for WindowRenderPlugin {
.init_resource::<ExtractedWindows>()
.init_resource::<WindowSurfaces>()
.add_systems(ExtractSchedule, extract_windows)
.add_systems(Render, prepare_windows.in_set(RenderSet::PrepareAssets))
.add_systems(Render, create_surfaces.in_set(RenderSet::ManageViews));
.add_systems(
Render,
create_surfaces
.run_if(need_new_surfaces)
.in_set(RenderSet::PrepareAssets),
)
.add_systems(Render, prepare_windows.in_set(RenderSet::ManageViews));
}
}
@ -419,6 +424,18 @@ pub fn prepare_windows(
}
}
pub fn need_new_surfaces(
windows: Res<ExtractedWindows>,
window_surfaces: Res<WindowSurfaces>,
) -> bool {
for window in windows.windows.values() {
if !window_surfaces.configured_windows.contains(&window.entity) {
return true;
}
}
false
}
/// Creates window surfaces.
pub fn create_surfaces(
// By accessing a NonSend resource, we tell the scheduler to put this system on the main thread,