Issue #1764: keep a failed upload out of the shared source

Record the out-of-memory failure when the staging buffer can't be allocated, and don't publish the zeroed buffer to SHARED_SOURCE when the render has failed, so a concurrent render can't reuse it.
This commit is contained in:
Antonio Sokic
2026-10-31 02:01:05 +01:00
parent 003ab49b5c
commit 35c7abb7cc
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -518,6 +518,10 @@ impl Gpu {
}
// (dropping the view schedules the copy)
drop(view);
} else {
// recorded now, not only when the error scope pops: the zeroed buffer must not be
// shared before then (`render::shared_source`)
fail(FailKind::OutOfMemory, "out of device memory: the upload's staging buffer couldn't be allocated".into());
}
// no view: the buffer couldn't be allocated (out of device memory). The error scope has recorded why and
// the render fails over to the CPU; allocating it again would only fail again (issue #1764)
+4
View File
@@ -466,6 +466,10 @@ fn shared_source(src: &Arc<Rgb32f>, upload: impl FnOnce() -> Buf) -> Arc<Buf> {
*g = None;
SOURCE_UPLOADS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
let buf = Arc::new(upload());
// a failed upload's buffer holds zeros: this render falls back, and no other may reuse it
if crate::ctx::failed() {
return buf;
}
*g = Some((Arc::downgrade(src), buf.clone()));
buf
}