From 96bb2b8fe1ed204e55a2e223faec8f0cee18901c Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 14:32:35 -0800 Subject: [PATCH] conformance: the ledger's typed reasons, "not built yet" and "no stream uses it yet", counted on every replay The planner allows two reasons for the rt ledger's refusal rows, provided they are the ledger's own vocabulary and not text typed per row: - `refused: not built yet ()`: a feature the streams use that a lane is building (multisample, depth attachments, tessellation, ICB pipeline states, points, the identity refusals). The lane is named on the row, and the landing that builds the feature deletes it. - `refused: no stream uses it yet ()`: a call that replay's census found no stream using. The row names the census run. The day a census finds a use, the reason becomes "not built yet" with a lane. known_gaps::Reason holds them. A row states one at the head of its waiting-on field. KnownGap::reason reads it, and parse refuses a head that names the vocabulary without its lane or census run. Every other row's reason stays its own words. known_gaps::open_work counts the rows by lane and by census run, and `conformance replay` prints that line on every run, green or red: the not-built-yet count is the cutover's remaining work, and it must be zero at the cutover. Test: the_ledger_s_typed_reasons_parse_and_count. Both reasons parse with their names, a row in words stays words, the count line sums by name, and a head without its name, or with an empty one, is refused. --- .../src/bin/conformance.rs | 6 ++ .../src/known_gaps.rs | 100 +++++++++++++++++- crates/metal2vulkan-conformance/src/tests.rs | 48 +++++++++ 3 files changed, 153 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan-conformance/src/bin/conformance.rs b/crates/metal2vulkan-conformance/src/bin/conformance.rs index c7f36a760..6bec16181 100644 --- a/crates/metal2vulkan-conformance/src/bin/conformance.rs +++ b/crates/metal2vulkan-conformance/src/bin/conformance.rs @@ -213,6 +213,12 @@ fn command() -> Result { ), }; let unexpected = report.unexpected(&ledger); + // The ledger's typed reasons, counted on every run: the rows not built yet are the + // cutover's remaining work, and the count is printed whether or not the run is green. + println!( + "\n{}", + metal2vulkan_conformance::known_gaps::open_work(&ledger, file) + ); // The cost half is a gate of its own, so it has its own line in the exit status: a // count going over its bound is never a conformance difference, and a conformance // difference is never a cost result. Both must hold for the run to be green. diff --git a/crates/metal2vulkan-conformance/src/known_gaps.rs b/crates/metal2vulkan-conformance/src/known_gaps.rs index 0f56e58d6..79f1a67ed 100644 --- a/crates/metal2vulkan-conformance/src/known_gaps.rs +++ b/crates/metal2vulkan-conformance/src/known_gaps.rs @@ -46,11 +46,19 @@ //! //! A row is held only against the cases a run selected, so replaying one case does not read every //! other row as fixed. +//! +//! # Typed reasons +//! +//! Two reasons are the ledger's own vocabulary ([`Reason`]), stated at the head of a row's last +//! field: `refused: not built yet ()`, a feature the streams use that a lane is building, +//! and `refused: no stream uses it yet ()`, a call replay's census found no stream +//! using. Every replay prints their counts ([`open_work`]): the rows not built yet are the +//! cutover's remaining work. use crate::case::Venue; use crate::replay::Replayed; use crate::verdict::Verdict; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; /// The committed ledger, compiled in so the check needs no path and no filesystem: a replay run /// inside a container reads the same rows as one on this Mac. @@ -131,6 +139,13 @@ pub struct KnownGap { } impl KnownGap { + /// The reason the row states, where the ledger's vocabulary names it ([`Reason`]): its + /// waiting-on field's head. [`parse`] refuses a malformed head, so a row read from a ledger + /// that names no vocabulary reason is its own words. + pub fn reason(&self) -> Reason { + Reason::of(&self.waiting_on).unwrap_or(Reason::Words) + } + /// What identifies the row within a venue: the case, the verdict it expects, the site and the /// answer there. fn key(&self) -> (&str, Expects, &str, &str) { @@ -157,6 +172,87 @@ impl KnownGap { } } +/// The head of a row waiting on a feature the streams use that a lane is building: the lane follows +/// in parentheses. +const NOT_BUILT_YET: &str = "refused: not built yet"; + +/// The head of a row waiting on a call no stream uses: the census run that found none follows in +/// parentheses. +const NO_STREAM_USES_IT: &str = "refused: no stream uses it yet"; + +/// Why a row is open, where the ledger's vocabulary names it: the head of its waiting-on field, +/// which the replay counts ([`open_work`]). Every other row's reason is its own words. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum Reason { + /// `refused: not built yet ()`: a feature the streams use that `lane` is building. The + /// landing that builds it deletes the row. Their count is the cutover's remaining work, and it + /// is zero at the cutover. + NotBuiltYet { lane: String }, + /// `refused: no stream uses it yet ()`: a call the census run `census` of replay's + /// streams found no stream using. The day a census finds a use, the row's reason becomes + /// [`Reason::NotBuiltYet`] with its lane. + NoStreamUsesIt { census: String }, + /// The row's own words: a device's own answer, what Metal does not document, and the like. + Words, +} + +impl Reason { + /// The reason `waiting_on` states at its head, or why a head that names the vocabulary is + /// malformed: a reason without its parenthesis, or with an empty one. + fn of(waiting_on: &str) -> Result { + let heads: [(&str, fn(String) -> Reason); 2] = [ + (NOT_BUILT_YET, |lane| Reason::NotBuiltYet { lane }), + (NO_STREAM_USES_IT, |census| Reason::NoStreamUsesIt { + census, + }), + ]; + for (head, make) in heads { + let Some(rest) = waiting_on.strip_prefix(head) else { + continue; + }; + let named = (rest.strip_prefix(" (")) + .and_then(|rest| rest.split_once(')')) + .map(|(named, _)| named.trim()) + .filter(|named| !named.is_empty()); + let why = || format!("a row waiting on \"{head}\" names who: \"{head} ()\""); + return named.map(|named| make(named.to_owned())).ok_or_else(why); + } + Ok(Reason::Words) + } +} + +/// What `ledger`'s typed reasons count, as one line of a replay's report: its rows not built yet +/// by lane, which is the cutover's remaining work, and its rows no stream uses by census run. +pub fn open_work(ledger: &[KnownGap], file: &str) -> String { + let mut lanes = BTreeMap::::new(); + let mut censuses = BTreeMap::::new(); + for row in ledger { + match row.reason() { + Reason::NotBuiltYet { lane } => *lanes.entry(lane).or_default() += 1, + Reason::NoStreamUsesIt { census } => *censuses.entry(census).or_default() += 1, + Reason::Words => {} + } + } + let each = |counted: &BTreeMap| match counted.is_empty() { + true => String::new(), + false => { + let named: Vec = counted + .iter() + .map(|(name, n)| format!("{name} {n}")) + .collect(); + format!(" ({})", named.join(", ")) + } + }; + format!( + "{file}: {} row(s) not built yet{}, the cutover's remaining work; {} row(s) no stream \ + uses yet{}", + lanes.values().sum::(), + each(&lanes), + censuses.values().sum::(), + each(&censuses), + ) +} + /// Why a run is not what the ledger expects. Each of these fails the run. #[derive(Clone, Debug, PartialEq)] pub enum Expectation { @@ -294,6 +390,8 @@ pub fn parse(text: &str) -> Result, String> { what Metal does, what we do instead, and where the fix belongs" )); } + Reason::of(waiting_on.trim()) + .map_err(|why| format!("known-gaps.tsv line {at}: {case}: {why}"))?; rows.push(KnownGap { case: case.trim().to_owned(), venue: venue.trim().to_owned(), diff --git a/crates/metal2vulkan-conformance/src/tests.rs b/crates/metal2vulkan-conformance/src/tests.rs index 1fd918102..1b8863fd6 100644 --- a/crates/metal2vulkan-conformance/src/tests.rs +++ b/crates/metal2vulkan-conformance/src/tests.rs @@ -7954,3 +7954,51 @@ fn a_refusal_of_what_the_device_offers_is_the_runtime_s() { Feature::SampleRateShading ))); } + +/// The ledger's two typed reasons parse from a row's waiting-on head with the lane or census run +/// they name, a head without its name is refused, and the count line sums each by name. +#[test] +fn the_ledger_s_typed_reasons_parse_and_count() { + use crate::known_gaps::{open_work, parse, Reason}; + let row = |waiting_on: &str| format!("a-case\t*\trefused\tcase/site\tErr(X)\t{waiting_on}\n"); + let text = [ + row("refused: not built yet (render). The pipeline's multisample state."), + row("refused: not built yet (render)"), + row("refused: not built yet (identity)"), + row("refused: no stream uses it yet (census-1)"), + row("The device's own answer (rule 1)."), + ] + .concat(); + let ledger = parse(&text).expect("the rows parse"); + let reasons: Vec = ledger.iter().map(|known| known.reason()).collect(); + assert_eq!( + reasons, + [ + Reason::NotBuiltYet { + lane: "render".to_owned() + }, + Reason::NotBuiltYet { + lane: "render".to_owned() + }, + Reason::NotBuiltYet { + lane: "identity".to_owned() + }, + Reason::NoStreamUsesIt { + census: "census-1".to_owned() + }, + Reason::Words, + ] + ); + assert_eq!( + open_work(&ledger, "known-gaps-rt.tsv"), + "known-gaps-rt.tsv: 3 row(s) not built yet (identity 1, render 2), the cutover's \ + remaining work; 1 row(s) no stream uses yet (census-1 1)" + ); + for malformed in [ + "refused: not built yet", + "refused: no stream uses it yet ()", + ] { + let refused = parse(&row(malformed)).expect_err(malformed); + assert!(refused.contains("names who"), "{refused}"); + } +}