Skip to content

Commit 2ec164d

Browse files
authored
Clear view attachments before resizing window surfaces (#15087)
# Objective - Fixes #15077 ## Solution - Clears `ViewTargetAttachments` resource every frame before `create_surfaces` system instead, which was previously done after `extract_windows`. ## Testing - Confirmed that examples no longer panic on window resizing with DX12 backend. - `screenshot` example keeps working after this change.
1 parent ff30848 commit 2ec164d

File tree

1 file changed

+9
-1
lines changed
  • crates/bevy_render/src/view

1 file changed

+9
-1
lines changed

crates/bevy_render/src/view/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ impl Plugin for ViewPlugin {
118118
render_app.add_systems(
119119
Render,
120120
(
121+
// `TextureView`s need to be dropped before reconfiguring window surfaces.
122+
clear_view_attachments
123+
.in_set(RenderSet::ManageViews)
124+
.before(create_surfaces),
121125
prepare_view_attachments
122126
.in_set(RenderSet::ManageViews)
123127
.before(prepare_view_targets)
@@ -814,7 +818,6 @@ pub fn prepare_view_attachments(
814818
cameras: Query<&ExtractedCamera>,
815819
mut view_target_attachments: ResMut<ViewTargetAttachments>,
816820
) {
817-
view_target_attachments.clear();
818821
for camera in cameras.iter() {
819822
let Some(target) = &camera.target else {
820823
continue;
@@ -839,6 +842,11 @@ pub fn prepare_view_attachments(
839842
}
840843
}
841844

845+
/// Clears the view target [`OutputColorAttachment`]s.
846+
pub fn clear_view_attachments(mut view_target_attachments: ResMut<ViewTargetAttachments>) {
847+
view_target_attachments.clear();
848+
}
849+
842850
pub fn prepare_view_targets(
843851
mut commands: Commands,
844852
clear_color_global: Res<ClearColor>,

0 commit comments

Comments
 (0)