From 1cf923d5e0274ad6a5231d8b913cf4a7038d14a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 5 Feb 2024 15:47:21 +0100 Subject: [PATCH 1/2] change set for systems --- crates/bevy_render/src/view/window/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/src/view/window/mod.rs b/crates/bevy_render/src/view/window/mod.rs index d10e354a17316..21e5d33c4c1d8 100644 --- a/crates/bevy_render/src/view/window/mod.rs +++ b/crates/bevy_render/src/view/window/mod.rs @@ -43,8 +43,8 @@ impl Plugin for WindowRenderPlugin { .init_resource::() .init_resource::() .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.in_set(RenderSet::PrepareAssets)) + .add_systems(Render, prepare_windows.in_set(RenderSet::ManageViews)); } } From 9050a6cd3b89ecf44e32282c3e50c57ffd337874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 5 Feb 2024 15:52:01 +0100 Subject: [PATCH 2/2] add run condition --- crates/bevy_render/src/view/window/mod.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/view/window/mod.rs b/crates/bevy_render/src/view/window/mod.rs index 21e5d33c4c1d8..4c324c21933ee 100644 --- a/crates/bevy_render/src/view/window/mod.rs +++ b/crates/bevy_render/src/view/window/mod.rs @@ -43,7 +43,12 @@ impl Plugin for WindowRenderPlugin { .init_resource::() .init_resource::() .add_systems(ExtractSchedule, extract_windows) - .add_systems(Render, create_surfaces.in_set(RenderSet::PrepareAssets)) + .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, + window_surfaces: Res, +) -> 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,