observe: the field witness bracketed the defect by 7000 presents, and the pass state it needed was unrecorded

Component: reims-vgpu runtime (scanout present boundary, Vulkan draw encode).
Pathway: x86 macOS / Linux Vulkan. Rail: macos-15.

The blank desktop field is a transition, not a state: a plane's field reads
black for the whole early boot, then one composite makes it wallpaper or makes
it a uniform 0xff field, and it never moves again. The heartbeat witness could
only bracket that moment by its own spacing, and the spacing that keeps a
heartbeat cheap is what makes the bracket useless -- the first sighting of the
white field sat about 7 000 presents after the last sighting of the black one.

Contract: none changed. Both records are observations; neither alters a
guest-visible decision.

Behavior:

- `note_present_field_witness` now samples every present and reports when the
  answer changes, keeping the heartbeat beside it so a field that never changes
  still says so and a reader can tell "nothing changed" from "nothing looked".
  The four patch verdicts are folded into one word so the comparison is a
  compare and not a string diff, and the last pattern is kept per mapping id --
  two planes of one swap chain hold different frames, and a shared slot would
  report every alternation between them as a change. Cost is unchanged at 256
  texel reads a present; only the emission rule moved.

- `compositor_plane_pass` records what a pass declares for a full-screen plane:
  load action, clear colour, whether a seed was served and through which door.
  A flat field is what a CLEAR leaves behind and `exec::finish_stream` applies a
  pass's clear whenever the pass will not draw, but nothing said what colour any
  of these passes clears to, so "the field is this pass's clear" and "the field
  is something else" could not be told apart. Latched per (mapping, pipeline,
  load action, seed outcome); full-screen planes only, since a scratch offscreen
  answers a different question and there are thousands of them.

  It is placed where the load action is resolved rather than where it is
  decoded: this rail's requests do not pass through the MRT builder, and a first
  placement there produced no output on a live boot.

What it already establishes, and it rules a hypothesis out: every full-screen
compositor pass on this rail clears to [0,0,0,1] or [0,0,0,0] and reports
seed=served door=mapping. The uniform 0xff field is therefore not one of these
passes' clears, which is what the record was added to test.

Verified: cargo fmt --all and --check; clippy clean on all three main arms, each
-D warnings; the serial Rust suite, 2387 passed, 0 failed; and live macos-15
boots on the x86/PCI rail confirming both records emit, that the witness fires
on change, and that the plane-pass census reaches this rail's path.

Not verified: no arm64 pathway, no Metal backend tests (Linux host), no
conformance battery -- no guest-visible behavior changed, so there is no
candidate transition to score.
This commit is contained in:
Anees Iqbal committed 2026-08-30 12:38:25 +03:00
1 parent 6bab0bd6b6
commit b7326489db
3 files changed
+100 -5

No files matched your search

+47
View File
@@ -4424,6 +4424,53 @@ pub fn encode_icb_execute_and_writeback<M: HostMemory + HostOps>(
EncodeStatus::NoMetal("icb_exec_no_metal_build")
}
/// What a pass declares for a full-screen compositor plane: its load action and,
/// when it clears, the colour it clears to.
///
/// On the macos-15 rail a boot's desktop background is sometimes a flat field in
/// the plane's own guest pages, with one rectangle of correct wallpaper in it.
/// A flat field is what a CLEAR leaves behind, and `exec::finish_stream` applies
/// a pass's clear whenever the pass will not draw — but no record said what
/// colour any of these passes clears to, so "the field is this pass's clear" and
/// "the field is something else entirely" could not be told apart.
///
/// Latched per `(mapping, pipeline, load action)`: a compositor re-runs the same
/// pass on the same plane every frame, and the interesting reading is which
/// declarations exist at all, which is a small set.
///
/// Full-screen planes only. A pass over a scratch offscreen answers a different
/// question and there are thousands of them.
pub(crate) fn note_compositor_plane_pass(
color: &ColorRtRequest,
width: u32,
height: u32,
pipeline_ref: u32,
seed_served: bool,
seed_door: &str,
) {
let (mapping_id, load_action, clear_color) =
(color.mapping_id, color.load_action, &color.clear_color);
if mapping_id == 0 || width < 1024 || height < 1024 {
return;
}
let disc = (u64::from(mapping_id) << 40)
| (u64::from(pipeline_ref) << 9)
| (u64::from(load_action & 0xff) << 1)
| u64::from(seed_served);
if !crate::observe::first_sight("compositor_plane_pass", disc) {
return;
}
crate::observe::off(format!(
"compositor_plane_pass mid={mapping_id} {width}x{height} pipe={pipeline_ref} \
load={load_action:#x} clear=[{:.3},{:.3},{:.3},{:.3}] seed={} door={seed_door}",
clear_color[0],
clear_color[1],
clear_color[2],
clear_color[3],
if seed_served { "served" } else { "empty" }
));
}
/// Resolve color texture ref → mapping geometry for a draw request.
#[allow(
clippy::too_many_arguments,
@@ -8094,6 +8094,18 @@ fn try_metal2vulkan_draw<M: HostMemory + HostOps>(
// independently driven x86/Vulkan boots: 1 558, 395 and 295
// colour LOAD seed resolutions, and 0 serves plus 0 misses
// at that door in every one.
// What this pass declares for a full-screen compositor
// plane, recorded where the load action has been resolved
// rather than where it was decoded — the request builder
// this rail takes does not pass through the MRT path.
crate::runtime::draw::note_compositor_plane_pass(
c0,
w,
h,
req.pipeline_ref,
target_rgba8.is_some() || target_guest_seed.is_some(),
seed_door,
);
if matches!(declared, LoadAction::DontCare) {
// The widened arm's own instrument, and it is a counter
// rather than the latched line below it. DontCare now
+41 -5
View File
@@ -1351,6 +1351,14 @@ const FIELD_PATCHES: [(f32, f32); 4] = [(0.10, 0.22), (0.10, 0.72), (0.90, 0.22)
/// this witness.
const FIELD_PATCH_SIDE: u32 = 8;
/// The last field pattern reported for each presented plane, so the witness can
/// report a change rather than a sample. Keyed by mapping id: two planes of one
/// swap chain hold different frames and a shared slot would report every
/// alternation between them as a change.
static FIELD_WITNESS_LAST: std::sync::LazyLock<
std::sync::Mutex<std::collections::HashMap<u32, u32>>,
> = std::sync::LazyLock::new(|| std::sync::Mutex::new(std::collections::HashMap::new()));
/// Presents between samples once the power-of-two spacing has opened up.
const FIELD_WITNESS_STRIDE: u64 = 64;
@@ -1404,6 +1412,19 @@ pub fn note_present_field_witness<M: HostMemory>(
if mapping_id == 0 || !scanout_extent_ok(width, height) {
return;
}
// Sampled on every present, reported only when the answer changes.
//
// The defect this exists for is a *transition*: the plane's field is black
// for the whole early boot, then one composite makes it wallpaper or makes
// it a uniform 0xff field, and it never moves again. A heartbeat can only
// bracket that moment by however wide its spacing happens to be, and the
// spacing that keeps a heartbeat cheap is exactly what makes the bracket
// useless — the first sighting of the white field sat 7 000 presents after
// the last sighting of the black one. Emitting on change costs the same 256
// texel reads and names the present itself.
//
// The heartbeat is kept beside it so a field that never changes still says
// so, and so a reader can tell "nothing changed" from "nothing looked".
// Power-of-two spacing for the early boot, and a fixed stride after it.
// Power-of-two alone is readable from the first present onward and bounded
// by log2 of the present count (`maybe_log_capture_sampling`'s reason), but
@@ -1413,9 +1434,7 @@ pub fn note_present_field_witness<M: HostMemory>(
// steady rate there and costs a bounded ~1 line/s at this rail's present
// rate.
let seq = state.present.present_epoch.saturating_add(1);
if !seq.is_power_of_two() && !seq.is_multiple_of(FIELD_WITNESS_STRIDE) {
return;
}
let heartbeat = seq.is_power_of_two() || seq.is_multiple_of(FIELD_WITNESS_STRIDE);
let Some((window, format, map_gen, epoch)) = state.mappings.get(&mapping_id).map(|m| {
let format = if m.format == 0 {
pixel_format::MTL_FORMAT_BGRA8_UNORM
@@ -1462,6 +1481,7 @@ pub fn note_present_field_witness<M: HostMemory>(
let page = state.page_size();
let mut report = String::new();
let mut blank = 0u32;
let mut verdicts: Vec<u8> = Vec::with_capacity(FIELD_PATCHES.len());
for (i, (fx, fy)) in FIELD_PATCHES.iter().enumerate() {
let cx = (width as f32 * fx) as u32;
let cy = (height as f32 * fy) as u32;
@@ -1497,6 +1517,7 @@ pub fn note_present_field_witness<M: HostMemory>(
// pale wallpaper. Uniform-and-dark is equally a field nothing wrote, so
// the count is of unpainted patches and the verdict names which kind.
let verdict = field_patch_verdict(mean, sd);
verdicts.push(verdict.as_bytes()[0]);
if verdict != "painted" {
blank += 1;
}
@@ -1505,9 +1526,24 @@ pub fn note_present_field_witness<M: HostMemory>(
}
report.push_str(&format!("{verdict}:{mean:.0}/{sd:.0}"));
}
// The four verdicts as one word, so "did this plane's field change" is a
// comparison and not a string diff.
let pattern = verdicts
.iter()
.fold(0u32, |acc, v| (acc << 8) | u32::from(*v));
let changed = {
let mut last = FIELD_WITNESS_LAST
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner());
last.insert(mapping_id, pattern) != Some(pattern)
};
if !changed && !heartbeat {
return;
}
crate::observe::off(format!(
"present_field_witness mid={mapping_id} {width}x{height} map_gen={map_gen} \
epoch={epoch} seq={seq} unpainted={blank}/4 patches=[{report}] \
(guest pages, no settle)"
epoch={epoch} seq={seq} why={} unpainted={blank}/4 patches=[{report}] \
(guest pages, no settle)",
if changed { "changed" } else { "heartbeat" }
));
}