Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Merge commit '0e5f343faf56445ac4695adb832027ecdcf7c66b' into perf/windows-media-pipeline

Marcos Daniel Rivera Gonzalezfe2d3a33818d
diff --cc crates/rendering/src/frame_pipeline.rs
index 249d222df,cf5028200..458687ab3
--- a/crates/rendering/src/frame_pipeline.rs
+++ b/crates/rendering/src/frame_pipeline.rs
@@@ -1164,21 -1146,37 +1148,21 @@@ impl PendingNv12Readback
return Err(self.cancel());
};
- match wait_for_map(
- let start_time = Instant::now();
- let timeout_duration = gpu_buffer_wait_timeout(self.export_deadlines);
-
- loop {
- if readback_waited(start_time, self.frame_number) > timeout_duration {
- return Err(self.cancel());
- }
-
- match rx.try_recv() {
- Ok(result) => match result {
- Ok(()) => break,
- Err(error) => {
- self.unmap();
- return Err(RenderingError::BufferMapFailed(error));
- }
- },
- Err(oneshot::error::TryRecvError::Empty) => {
- device.poll(wgpu::PollType::Poll)?;
- // tokio's timer ticks in whole milliseconds, so even a
- // 100µs sleep outlasts a frame's GPU work and caps the
- // export at the timer rate; sleep only once a frame is slow.
- if start_time.elapsed() < NV12_READBACK_SPIN {
- tokio::task::yield_now().await;
- } else {
- tokio::time::sleep(std::time::Duration::from_millis(1)).await;
- }
- }
- Err(oneshot::error::TryRecvError::Closed) => {
- return Err(self.cancel());
- }
++ let completed = wait_for_submission(
+ device,
+ &submission,
- &mut rx,
- self.export_deadlines,
++ Instant::now(),
+ self.frame_number,
++ gpu_buffer_wait_timeout(self.export_deadlines),
+ )
- .await?
- {
- MapWait::Mapped => {}
- MapWait::Failed(error) => {
++ .await;
++ match (completed, rx.try_recv()) {
++ (true, Ok(Ok(()))) => {}
++ (_, Ok(Err(error))) => {
+ self.unmap();
+ return Err(RenderingError::BufferMapFailed(error));
}
- MapWait::Abandoned => return Err(self.cancel()),
++ _ => return Err(self.cancel()),
}
let buffer_slice = self.buffer.slice(..);