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.
This commit is contained in:
akimakinai 2024-10-01 01:58:04 +09:00 committed by GitHub
parent ff308488fe
commit 2ec164d279
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -118,6 +118,10 @@ impl Plugin for ViewPlugin {
render_app.add_systems(
Render,
(
// `TextureView`s need to be dropped before reconfiguring window surfaces.
clear_view_attachments
.in_set(RenderSet::ManageViews)
.before(create_surfaces),
prepare_view_attachments
.in_set(RenderSet::ManageViews)
.before(prepare_view_targets)
@ -814,7 +818,6 @@ pub fn prepare_view_attachments(
cameras: Query<&ExtractedCamera>,
mut view_target_attachments: ResMut<ViewTargetAttachments>,
) {
view_target_attachments.clear();
for camera in cameras.iter() {
let Some(target) = &camera.target else {
continue;
@ -839,6 +842,11 @@ pub fn prepare_view_attachments(
}
}
/// Clears the view target [`OutputColorAttachment`]s.
pub fn clear_view_attachments(mut view_target_attachments: ResMut<ViewTargetAttachments>) {
view_target_attachments.clear();
}
pub fn prepare_view_targets(
mut commands: Commands,
clear_color_global: Res<ClearColor>,