Readback bound honours the 32-bit limit, names the CPU path, fx_bench exits instead of panicking

This commit is contained in:
Dylan M. Taylor committed 2026-11-11 21:17:11 +00:00
1 parent 5131ccaba5
commit ceb8bfc5dd
3 files changed
+12 -4

No files matched your search

+7 -2
View File
@@ -59,8 +59,13 @@ pub fn render_to_vec_stats(
let rect = rect.intersect(&doc.bounds());
// This helper holds every staging buffer and the whole result at once (tests and tools): refuse
// a rectangle whose pixel vector alone would pass 4 GiB. Use `render_bands` for larger ones.
if u64::from(rect.width()) * u64::from(rect.height()) > MAX_VEC_READBACK_PIXELS {
return Err(Unsupported(format!("{}x{} is too large to read back in one piece; use render_bands", rect.width(), rect.height())));
let max_pixels = MAX_VEC_READBACK_PIXELS.min(isize::MAX as u64 / std::mem::size_of::<[f32; 4]>() as u64);
if u64::from(rect.width()) * u64::from(rect.height()) > max_pixels {
return Err(Unsupported(format!(
"{}x{} is too large to read back in one piece; use render_bands (8-bit documents) or the CPU compositor",
rect.width(),
rect.height()
)));
}
let mut staging: Vec<(Rect, wgpu::Buffer, u32)> = Vec::new();
let mut bpp = 16u32;
+1 -1
View File
@@ -320,5 +320,5 @@ fn one_piece_readback_refuses_a_canvas_it_cannot_hold() {
// 20000 x 20000 px = 6.4 GB of RGBA32F; refused before any buffer is made.
let doc = Document::with_background("huge", Size::new(20_000, 20_000), ColorMode::Rgb, SampleType::U8, Color::WHITE);
let e = render_to_vec(&mut comp, ctx.device(), ctx.queue(), &doc, doc.bounds()).unwrap_err();
assert!(e.0.contains("render_bands"), "{}", e.0);
assert!(e.0.contains("too large to read back"), "{}", e.0);
}
+4 -1
View File
@@ -239,7 +239,10 @@ fn main() {
let (w, h) = arg(&args, "--size").and_then(|s| s.split_once('x').and_then(|(a, b)| Some((a.parse().ok()?, b.parse().ok()?)))).unwrap_or((7360, 4912));
synthetic(w, h)
};
assert!(fits(&doc), "canvas {}x{} is over {MAX_BENCH_PIXELS} pixels", doc.size.width, doc.size.height);
if !fits(&doc) {
eprintln!("canvas {}x{} is over {MAX_BENCH_PIXELS} pixels", doc.size.width, doc.size.height);
return;
}
let full = doc.bounds();
println!("document {}x{} ({} layers)", doc.size.width, doc.size.height, doc.walk().len());
let mut g = gpu();