From 4f4ee86deef1d5f87f3e22c4c1736d3b336640f0 Mon Sep 17 00:00:00 2001 From: james7132 Date: Thu, 8 Feb 2024 01:22:34 -0800 Subject: [PATCH 1/3] Cache the QueryState used to drop the swapchain TextureViews --- crates/bevy_render/src/renderer/mod.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 3fae24e1e477d..0c17050065c8f 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -13,7 +13,7 @@ use crate::{ settings::{WgpuSettings, WgpuSettingsPriority}, view::{ExtractedWindows, ViewTarget}, }; -use bevy_ecs::prelude::*; +use bevy_ecs::{prelude::*, system::SystemState}; use bevy_time::TimeSender; use bevy_utils::Instant; use std::sync::Arc; @@ -22,7 +22,10 @@ use wgpu::{ }; /// Updates the [`RenderGraph`] with all of its nodes and then runs it to render the entire frame. -pub fn render_system(world: &mut World) { +pub fn render_system( + world: &mut World, + state: &mut SystemState>>, +) { world.resource_scope(|world, mut graph: Mut| { graph.update(world); }); @@ -59,9 +62,8 @@ pub fn render_system(world: &mut World) { // Remove ViewTarget components to ensure swap chain TextureViews are dropped. // If all TextureViews aren't dropped before present, acquiring the next swap chain texture will fail. - let view_entities = world - .query_filtered::>() - .iter(world) + let view_entities = state.get(world) + .iter() .collect::>(); for view_entity in view_entities { world.entity_mut(view_entity).remove::(); From 45c3ddb0cda331a1df245743f245b75ed74bfed6 Mon Sep 17 00:00:00 2001 From: james7132 Date: Thu, 8 Feb 2024 02:17:59 -0800 Subject: [PATCH 2/3] Formatting --- crates/bevy_render/src/renderer/mod.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 0c17050065c8f..ab019a9d24113 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -14,6 +14,7 @@ use crate::{ view::{ExtractedWindows, ViewTarget}, }; use bevy_ecs::{prelude::*, system::SystemState}; +use bevy_tasks::ComputeTaskPool; use bevy_time::TimeSender; use bevy_utils::Instant; use std::sync::Arc; @@ -22,10 +23,7 @@ use wgpu::{ }; /// Updates the [`RenderGraph`] with all of its nodes and then runs it to render the entire frame. -pub fn render_system( - world: &mut World, - state: &mut SystemState>>, -) { +pub fn render_system(world: &mut World, state: &mut SystemState>>) { world.resource_scope(|world, mut graph: Mut| { graph.update(world); }); @@ -62,9 +60,7 @@ pub fn render_system( // Remove ViewTarget components to ensure swap chain TextureViews are dropped. // If all TextureViews aren't dropped before present, acquiring the next swap chain texture will fail. - let view_entities = state.get(world) - .iter() - .collect::>(); + let view_entities = state.get(world).iter().collect::>(); for view_entity in view_entities { world.entity_mut(view_entity).remove::(); } From d282ac8631132c531fa26862b4e48194ec828b7a Mon Sep 17 00:00:00 2001 From: james7132 Date: Thu, 8 Feb 2024 02:18:51 -0800 Subject: [PATCH 3/3] Whoops --- crates/bevy_render/src/renderer/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index ab019a9d24113..c645f0811f0f0 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -14,7 +14,6 @@ use crate::{ view::{ExtractedWindows, ViewTarget}, }; use bevy_ecs::{prelude::*, system::SystemState}; -use bevy_tasks::ComputeTaskPool; use bevy_time::TimeSender; use bevy_utils::Instant; use std::sync::Arc;