From 1323de7cd74ba7a6fe801e0fa47c357b7760b049 Mon Sep 17 00:00:00 2001 From: robtfm <50659922+robtfm@users.noreply.github.com> Date: Sat, 16 Mar 2024 04:49:16 +0000 Subject: [PATCH] stop retrying removed assets (#12505) # Objective assets that don't load before they get removed are retried forever, causing buffer churn and slowdown. ## Solution stop trying to prepare dead assets. --- crates/bevy_pbr/src/material.rs | 4 ++++ crates/bevy_render/src/render_asset.rs | 4 ++++ crates/bevy_sprite/src/mesh2d/material.rs | 4 ++++ crates/bevy_ui/src/render/ui_material_pipeline.rs | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 6939153c7fcb4..59d0e7b67bea7 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -934,6 +934,10 @@ pub fn prepare_materials( ) { let queued_assets = std::mem::take(&mut prepare_next_frame.assets); for (id, material) in queued_assets.into_iter() { + if extracted_assets.removed.contains(&id) { + continue; + } + match prepare_material( &material, &render_device, diff --git a/crates/bevy_render/src/render_asset.rs b/crates/bevy_render/src/render_asset.rs index 0b1686fbce641..0af7b877854dc 100644 --- a/crates/bevy_render/src/render_asset.rs +++ b/crates/bevy_render/src/render_asset.rs @@ -402,6 +402,10 @@ pub fn prepare_assets( let mut param = param.into_inner(); let queued_assets = std::mem::take(&mut prepare_next_frame.assets); for (id, extracted_asset) in queued_assets { + if extracted_assets.removed.contains(&id) { + continue; + } + match extracted_asset.prepare_asset(&mut param) { Ok(prepared_asset) => { render_assets.insert(id, prepared_asset); diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index 2b5772c686559..0b4a7be28c669 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -572,6 +572,10 @@ pub fn prepare_materials_2d( ) { let queued_assets = std::mem::take(&mut prepare_next_frame.assets); for (id, material) in queued_assets { + if extracted_assets.removed.contains(&id) { + continue; + } + match prepare_material2d( &material, &render_device, diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index 171cd04d958ea..1245cf3012f7a 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -691,6 +691,10 @@ pub fn prepare_ui_materials( ) { let queued_assets = std::mem::take(&mut prepare_next_frame.assets); for (id, material) in queued_assets { + if extracted_assets.removed.contains(&id) { + continue; + } + match prepare_ui_material( &material, &render_device,