mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-01 14:07:34 -06:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user