Skip to content

Commit 40e234f

Browse files
agicquelamzmtdowling
authored andcommitted
winit-host: flush queued writes when the frame cannot be acquired
A Timeout or Occluded surface returned before any submit, leaving every write_buffer of the frame pending in the queue. While a window stays hidden or occluded that grows without bound (about 50 MB/s in a sprite scene: one staging buffer per write). Submitting an empty batch flushes them; Outdated/Lost do the same before reconfiguring.
1 parent 87bd7da commit 40e234f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎native/rust/winit-host/src/graphics.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,12 +1930,18 @@ impl Graphics {
19301930
CurrentSurfaceTexture::Success(frame) => (Some(frame), false),
19311931
CurrentSurfaceTexture::Suboptimal(frame) => (Some(frame), true),
19321932
CurrentSurfaceTexture::Timeout | CurrentSurfaceTexture::Occluded => {
1933-
return Ok(false)
1933+
// The frame's buffer writes are already queued. Submitting
1934+
// nothing still flushes them; returning without a submit
1935+
// leaves every write's staging buffer pending, and a hidden
1936+
// or occluded window then grows without bound.
1937+
self.queue.submit(std::iter::empty());
1938+
return Ok(false);
19341939
}
19351940
CurrentSurfaceTexture::Outdated | CurrentSurfaceTexture::Lost => {
19361941
// Both mean the surface no longer matches the window. Rebuilt
19371942
// here and drawn next frame, which is one dropped frame rather
1938-
// than a dead window.
1943+
// than a dead window. The queued writes are flushed as above.
1944+
self.queue.submit(std::iter::empty());
19391945
if let Some(surface) = &self.surface {
19401946
surface.configure(&self.device, &self.config);
19411947
}

0 commit comments

Comments
 (0)