Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using unwrap in the pipelined rendering thread #9052

Merged
merged 1 commit into from
Jul 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions crates/bevy_render/src/pipelined_rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,29 @@ impl Plugin for PipelinedRenderingPlugin {
#[cfg(feature = "trace")]
let _span = bevy_utils::tracing::info_span!("render thread").entered();

let compute_task_pool = ComputeTaskPool::get();
loop {
// run a scope here to allow main world to use this thread while it's waiting for the render app
let mut render_app = ComputeTaskPool::get()
let sent_app = compute_task_pool
.scope(|s| {
s.spawn(async { app_to_render_receiver.recv().await.unwrap() });
s.spawn(async { app_to_render_receiver.recv().await });
})
.pop()
.unwrap();

#[cfg(feature = "trace")]
let _sub_app_span =
bevy_utils::tracing::info_span!("sub app", name = ?RenderApp).entered();
render_app.run();
render_to_app_sender.send_blocking(render_app).unwrap();
.pop();
let Some(Ok(mut render_app)) = sent_app else { break };

{
#[cfg(feature = "trace")]
let _sub_app_span =
bevy_utils::tracing::info_span!("sub app", name = ?RenderApp).entered();
render_app.run();
}

if render_to_app_sender.send_blocking(render_app).is_err() {
break;
}
}

bevy_utils::tracing::debug!("exiting pipelined rendering thread");
});
}
}
Expand Down