From 255ee070d11fe52bbc1f5ce43aaa4e7f8a228e03 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 30 Aug 2026 17:47:18 +0300 Subject: [PATCH] observe: nothing said whether the wallpaper draw's Store ever published for the plane it drew into Component: crates/reims-vgpu, plane draw census. Observation only. Pathway: x86 macOS / Linux Vulkan. Rail: macos-15. No guest-visible behavior changes. This adds two `store_routes` counters and the per-plane state that joins them. What could not be measured before. On rail macos-15 the desktop background comes up flat white on about two boots in three. Every boot-total differential run against that separates nothing -- across 24 boots that share one proven-identical binary, a white boot and a painted one have the same typed reasons at the same frequencies, the same `present_route` / `present_page_identity` / `type11_store_route` payloads, the same five or six `Composite` mids and the same page geometry. An exhaustive normalised diff of the guest's own logs, stack samples, `procs`, `ioreg` and `system_profiler` output separates them either. What is established: the guest issues the wallpaper draw on a white boot -- `plane_draw_multi_quad` 963 on a white boot against 734 on a painted one, more and not fewer -- the presented plane's own guest pages hold uniform `0xff`, and no door reports losing a seed (`load_seed_lost` 0, `present_unbacked` 0). And, measured this session on three of three boots where it could be asked: rebuilding the guest's wallpaper layer repairs the screen, while damaging the desktop with pointer motion never does. That is the expected shape -- macOS composites the background once and relies on it persisting -- and it says the loss is of one draw's result, not of a texture and not of a damage notification. boot zero-input pointer/dock desktop hover wallpaper rebuild lb-w1 WHITE 211.40 AMBIG 196.90 AMBIG 196.83 PAINTED 115.68 lb-w3 WHITE 228.50 WHITE 214.00 WHITE 213.93 PAINTED 115.68 lb-w4 WHITE 233.48 WHITE 222.69 WHITE 222.61 PAINTED 122.26 So the remaining question is a join no record could make: **did the multi-quad draw's Store publish for the plane it drew into?** A boot total cannot answer it, because the same plane also takes hundreds of six-vertex draws that publish normally, so the join has to be per plane and per draw shape. What this adds. `PLANE_MULTIQUAD_PENDING` holds one bit per plane -- "the last draw into it was the multi-quad one and nothing has published since". A multi-quad draw into a full-screen mapped plane arms it; `publish_surface_store`, which is the one place a Store becomes visible in a plane's guest pages, disarms it and counts `plane_multiquad_published`. A plane armed twice with no publish between counts `plane_multiquad_redrawn_unpublished` once, because two lost draws are the same observation as one until something publishes. Bounded by the number of live planes, which is the guest's swap chain (five or six); entries are removed on publish, so nothing accumulates. Reading it: compare `plane_multiquad_published` against `plane_draw_multi_quad` on a white boot and a painted one. Both are per-window `store_routes` values and must be summed across the boot, never read as a maximum. Cost: one extra uncontended mutex acquisition per draw into a mapped plane of at least 1024x1024, alongside the ring lock that path already takes. It does not run for ordinary draws. Verification actually run: cargo fmt --all and --check; clippy -D warnings on all three main arms (aarch64-apple-darwin backend-metal, host backend-vulkan,host-window, x86_64-unknown-linux-gnu backend-vulkan,host-window); the full reims-vgpu suite serially, 2302 passed / 0 failed / 1 ignored. Not verified: no boot has yet been run with these counters, so the measurement they exist for has not been taken. No conformance battery -- this changes no guest-visible behavior and adds no branch a guest can reach. --- crates/reims-vgpu/src/runtime/draw/mod.rs | 69 ++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/crates/reims-vgpu/src/runtime/draw/mod.rs b/crates/reims-vgpu/src/runtime/draw/mod.rs index cb5030824..ac9d5e6a0 100644 --- a/crates/reims-vgpu/src/runtime/draw/mod.rs +++ b/crates/reims-vgpu/src/runtime/draw/mod.rs @@ -4375,6 +4375,8 @@ pub(crate) fn publish_surface_store( height: u32, format: u16, ) { + #[cfg(feature = "backend-vulkan")] + note_plane_store_published(mapping_id); state.note_surface_composite(mapping_id); state.note_dense_frame_published(mapping_id, width, height); crate::runtime::scanout::note_front_buffer_writeback( @@ -4597,6 +4599,58 @@ pub(crate) static PLANE_DRAW_RING: std::sync::LazyLock< #[cfg(feature = "backend-vulkan")] const PLANE_DRAW_RING_DEPTH: usize = 24; +/// Planes whose most recent draw was the multi-quad one, and whether a Store +/// has published for them since. +/// +/// # The question this exists to answer +/// +/// On rail macos-15 the desktop background comes up flat white on about two +/// boots in three. Everything else composites correctly, and every boot-total +/// differential run against it separates nothing: the same typed reasons, the +/// same `store_routes`, the same surfaces, the same page geometry on a white +/// boot and a painted one. +/// +/// What *is* established: the guest issues the wallpaper draw on a white boot +/// (`plane_draw_multi_quad` 963 white against 734 painted -- more, not fewer), +/// the presented plane's own guest pages hold uniform `0xff`, and no door +/// reports losing a seed (`load_seed_lost` 0, `present_unbacked` 0). And on +/// three of three boots where pointer damage did not repair the screen, +/// rebuilding the guest's wallpaper layer did -- while damaging the desktop +/// with pointer motion never did, because macOS composites the background once +/// and then relies on it persisting. +/// +/// That narrows it to one question, which no existing record answers: **did the +/// multi-quad draw's Store publish for the plane it drew into?** A boot-total +/// count cannot answer it, because the same plane also receives hundreds of +/// six-vertex draws that publish normally; the join has to be per plane and per +/// draw shape. +/// +/// So this holds one bit per plane -- "the last draw into it was the multi-quad +/// one, and nothing has published since" -- and the counters below split the +/// multi-quad population by whether a publish followed. Bounded by the number +/// of live planes, which is the guest's swap chain (five or six), and entries +/// are removed when their plane publishes. +#[cfg(feature = "backend-vulkan")] +static PLANE_MULTIQUAD_PENDING: std::sync::LazyLock< + std::sync::Mutex>, +> = std::sync::LazyLock::new(|| std::sync::Mutex::new(std::collections::HashSet::new())); + +/// Note that a Store published for `mapping_id`, closing any multi-quad draw +/// waiting on it. +/// +/// Called from [`publish_surface_store`], which is the one place a Store +/// becomes visible in the plane's guest pages -- `note_present_backing` advances +/// there and it is what `present_unbacked` reads. +#[cfg(feature = "backend-vulkan")] +fn note_plane_store_published(mapping_id: u32) { + let mut pending = PLANE_MULTIQUAD_PENDING + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()); + if pending.remove(&mapping_id) { + crate::runtime::drain::note_store_route("plane_multiquad_published"); + } +} + /// Drain and format the remembered passes for one plane. #[cfg(feature = "backend-vulkan")] pub(crate) fn take_plane_draw_ring(mapping_id: u32) -> String { @@ -4632,11 +4686,24 @@ pub(crate) fn record_plane_draw(req: &DrawEncodeRequest) { // multi-quad draw. "Did the wallpaper draw reach this device at all" is then // a counter comparison between a white boot and a painted one, which no // record could answer before. - crate::runtime::drain::note_store_route(if req.vertex_count > 6 { + let multi_quad = req.vertex_count > 6; + crate::runtime::drain::note_store_route(if multi_quad { "plane_draw_multi_quad" } else { "plane_draw_single_quad" }); + // Arm the join. A multi-quad draw marks its plane; the next publish for that + // plane disarms it and counts. A plane armed twice without a publish in + // between counts once and says so, because two draws lost is the same + // observation as one until something publishes. + { + let mut pending = PLANE_MULTIQUAD_PENDING + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()); + if multi_quad && !pending.insert(color.mapping_id) { + crate::runtime::drain::note_store_route("plane_multiquad_redrawn_unpublished"); + } + } let shape = PlaneDrawShape::of(req); let mut ring = PLANE_DRAW_RING .lock()