Skip to content

Commit

Permalink
stop retrying removed assets (bevyengine#12505)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
robtfm authored Mar 16, 2024
1 parent 3a83f4e commit 1323de7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,10 @@ pub fn prepare_materials<M: Material>(
) {
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,
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_render/src/render_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ pub fn prepare_assets<A: RenderAsset>(
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);
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_sprite/src/mesh2d/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ pub fn prepare_materials_2d<M: Material2d>(
) {
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,
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_ui/src/render/ui_material_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ pub fn prepare_ui_materials<M: UiMaterial>(
) {
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,
Expand Down

0 comments on commit 1323de7

Please sign in to comment.