Skip to content

Commit 7ce5abe

Browse files
authored
Make sure we submit work even if we visited a camera. (#20595)
Alternative fix to #20318. We have existing code making sure that we do work on a swapchain in `CameraDriverNode`. However, it's only protecting against the case where we have no cameras spawned. We also need to check that we actually did any rendering work, even if we have cameras in the scene. Tested on macOS.
1 parent 0d351f6 commit 7ce5abe

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crates/bevy_render/src/render_graph/camera_driver_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl Node for CameraDriverNode {
6363
// wgpu (and some backends) require doing work for swap chains if you call `get_current_texture()` and `present()`
6464
// This ensures that Bevy doesn't crash, even when there are no cameras (and therefore no work submitted).
6565
for (id, window) in world.resource::<ExtractedWindows>().iter() {
66-
if camera_windows.contains(id) {
66+
if camera_windows.contains(id) && render_context.has_commands() {
6767
continue;
6868
}
6969

crates/bevy_render/src/renderer/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ impl<'w> RenderContext<'w> {
509509
})
510510
}
511511

512+
pub(crate) fn has_commands(&mut self) -> bool {
513+
self.command_encoder.is_some() || !self.command_buffer_queue.is_empty()
514+
}
515+
512516
/// Creates a new [`TrackedRenderPass`] for the context,
513517
/// configured using the provided `descriptor`.
514518
pub fn begin_tracked_render_pass<'a>(

0 commit comments

Comments
 (0)