From 89e59ddc54a063e655e9b3e85bcaa549cb8ba94e Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 23 Oct 2026 12:19:07 +0300 Subject: [PATCH] Give the suite a handler's own wait and a shared event's rising value The steps this packet landed as, in order: - Pin the three waits Metal does not come back from - Take Metal's own answers for a shared event's rising value - Keep Rustdoc clean in the handler-wait case module - Count a never-returned row among the answers from another chip Content: the tree of `development` at f37e7ae90a, unchanged. --- ...ndler-waits-completed-until-completed.json | 99 +++++++ ...ndler-waits-scheduled-until-completed.json | 99 +++++++ ...ndler-waits-scheduled-until-scheduled.json | 99 +++++++ .../recordings/shared-event-rising-value.json | 211 +++++++++++++++ crates/metal2vulkan-conformance/src/case.rs | 32 +++ crates/metal2vulkan-conformance/src/cases.rs | 6 + .../src/cases/handler_waits.rs | 256 ++++++++++++++++++ .../src/cases/shared_events.rs | 97 +++++++ .../src/handler_waits.rs | 116 ++++++++ crates/metal2vulkan-conformance/src/lib.rs | 2 + .../src/metal_side.rs | 65 ++++- .../metal2vulkan-conformance/src/recording.rs | 26 +- crates/metal2vulkan-conformance/src/replay.rs | 4 +- .../src/runtime_side.rs | 102 +++++++ .../src/shared_events.rs | 79 ++++++ .../metal2vulkan-conformance/src/validated.rs | 10 + 16 files changed, 1293 insertions(+), 10 deletions(-) create mode 100644 crates/metal2vulkan-conformance/recordings/handler-waits-completed-until-completed.json create mode 100644 crates/metal2vulkan-conformance/recordings/handler-waits-scheduled-until-completed.json create mode 100644 crates/metal2vulkan-conformance/recordings/handler-waits-scheduled-until-scheduled.json create mode 100644 crates/metal2vulkan-conformance/recordings/shared-event-rising-value.json create mode 100644 crates/metal2vulkan-conformance/src/cases/handler_waits.rs create mode 100644 crates/metal2vulkan-conformance/src/cases/shared_events.rs create mode 100644 crates/metal2vulkan-conformance/src/handler_waits.rs create mode 100644 crates/metal2vulkan-conformance/src/shared_events.rs diff --git a/crates/metal2vulkan-conformance/recordings/handler-waits-completed-until-completed.json b/crates/metal2vulkan-conformance/recordings/handler-waits-completed-until-completed.json new file mode 100644 index 000000000..011972281 --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/handler-waits-completed-until-completed.json @@ -0,0 +1,99 @@ +{ + "format": 1, + "case": "handler-waits-completed-until-completed", + "suite_version": 1, + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": { + "never_returned": { + "from": "metal2vulkan-validation runtime_lane::handler_waits, waits_from_a_command_buffer_s_own_handlers_answer_at_once", + "call": "addCompletedHandler/waitUntilCompleted" + } + }, + "device": "apple-m4", + "runs": 1, + "outcomes": [ + { + "runs": 1, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "wait", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "d72de2436a59cd01cd657b031240a6a9db04c26b0409b021224a418b52d20ae4" + } + } + }, + { + "name": "command-buffer", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "d490f85e91dad7f435df667667005be4da495cc9176f4797331a937872cefbc3" + } + } + } + ] + }, + { + "name": "addCompletedHandler/waitUntilCompleted", + "observed": { + "value": { + "nothing": "never_returned" + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "not_run" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/handler-waits-scheduled-until-completed.json b/crates/metal2vulkan-conformance/recordings/handler-waits-scheduled-until-completed.json new file mode 100644 index 000000000..3a7035f76 --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/handler-waits-scheduled-until-completed.json @@ -0,0 +1,99 @@ +{ + "format": 1, + "case": "handler-waits-scheduled-until-completed", + "suite_version": 1, + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": { + "never_returned": { + "from": "metal2vulkan-validation runtime_lane::handler_waits, waits_from_a_command_buffer_s_own_handlers_answer_at_once", + "call": "addScheduledHandler/waitUntilCompleted" + } + }, + "device": "apple-m4", + "runs": 1, + "outcomes": [ + { + "runs": 1, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "wait", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ecabd284d14e5f0d60fab6516fabb2508f52eb8ef3eb4ff7889c4e0eeeefe541" + } + } + }, + { + "name": "command-buffer", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "d490f85e91dad7f435df667667005be4da495cc9176f4797331a937872cefbc3" + } + } + } + ] + }, + { + "name": "addScheduledHandler/waitUntilCompleted", + "observed": { + "value": { + "nothing": "never_returned" + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "not_run" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/handler-waits-scheduled-until-scheduled.json b/crates/metal2vulkan-conformance/recordings/handler-waits-scheduled-until-scheduled.json new file mode 100644 index 000000000..eee13e9f1 --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/handler-waits-scheduled-until-scheduled.json @@ -0,0 +1,99 @@ +{ + "format": 1, + "case": "handler-waits-scheduled-until-scheduled", + "suite_version": 1, + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": { + "never_returned": { + "from": "metal2vulkan-validation runtime_lane::handler_waits, waits_from_a_command_buffer_s_own_handlers_answer_at_once", + "call": "addScheduledHandler/waitUntilScheduled" + } + }, + "device": "apple-m4", + "runs": 1, + "outcomes": [ + { + "runs": 1, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "wait", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "276eeb6969e8b0e411c80fd01f5ee00fe7c32b94a32745d877b023302ef3ef82" + } + } + }, + { + "name": "command-buffer", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "d490f85e91dad7f435df667667005be4da495cc9176f4797331a937872cefbc3" + } + } + } + ] + }, + { + "name": "addScheduledHandler/waitUntilScheduled", + "observed": { + "value": { + "nothing": "never_returned" + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "not_run" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/shared-event-rising-value.json b/crates/metal2vulkan-conformance/recordings/shared-event-rising-value.json new file mode 100644 index 000000000..3d3e407c7 --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/shared-event-rising-value.json @@ -0,0 +1,211 @@ +{ + "format": 1, + "case": "shared-event-rising-value", + "suite_version": 1, + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": "metal_run", + "device": "Apple M3 Max", + "runs": 3, + "outcomes": [ + { + "runs": 3, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "label", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "42ae984671b4be2a00ba84afac4613d28c462c2a2f869cd27f2860351f8b5668" + } + } + }, + { + "name": "host-sets", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "54373e62517bcc41fba89fac4b9a8f42fd67996719600607a68fcdb772f283b8" + } + } + }, + { + "name": "gpu-signals", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ccc0b60854286198c25702db8a8d08387e4d2d3b198cc8218b543c5030249963" + } + } + }, + { + "name": "host-waits-for", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "c0dc12cf03e40dfbeabdfb14fbd68710b3cdd28707cab5d20bf921fec4f8e896" + } + } + }, + { + "name": "wait-bound-millis", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "a111f275cc2e7588000001d300a31e76336d15b9d314cd1a1d8f3d3556975eed" + } + } + } + ] + }, + { + "name": "rising-value", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "label", + "observed": { + "value": { + "variant": { + "name": "Some", + "payload": { + "lines": [ + "conformance-rising-value" + ] + } + } + } + } + }, + { + "name": "signaled-value/new", + "observed": { + "value": { + "uint": 0 + } + } + }, + { + "name": "signaled-value/after-host-sets", + "observed": { + "value": { + "uint": 5 + } + } + }, + { + "name": "signaled-value/after-gpu-signal-0-of-3", + "observed": { + "value": { + "uint": 5 + } + } + }, + { + "name": "signaled-value/after-gpu-signal-1-of-5", + "observed": { + "value": { + "uint": 5 + } + } + }, + { + "name": "wait-until-signaled-value/3", + "observed": { + "value": { + "bool": true + } + } + }, + { + "name": "wait-until-signaled-value/5", + "observed": { + "value": { + "bool": true + } + } + }, + { + "name": "wait-until-signaled-value/6", + "observed": { + "value": { + "bool": false + } + } + }, + { + "name": "signaled-value/after-gpu-signal-of-u64-max", + "observed": { + "value": { + "uint": 18446744073709551615 + } + } + }, + { + "name": "wait-until-signaled-value/u64-max", + "observed": { + "value": { + "bool": true + } + } + } + ] + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "ran" + } + ] +} diff --git a/crates/metal2vulkan-conformance/src/case.rs b/crates/metal2vulkan-conformance/src/case.rs index 47754d70c..7f6a9bff7 100644 --- a/crates/metal2vulkan-conformance/src/case.rs +++ b/crates/metal2vulkan-conformance/src/case.rs @@ -868,6 +868,38 @@ pub trait Side { let _ = work; Err(Failure::unavailable("render")) } + + /// What a wait made from a command buffer's own handler, for that same command buffer, + /// answered ([`crate::handler_waits`]). + /// + /// The whole experiment is one call because the fact it observes is only visible from inside a + /// handler: a command buffer is made with one small fill, the handler `wait.from` names makes + /// the wait `wait.wait` names on it, and the answer comes back on a channel. The answer is a + /// [`Value`]: `Ok` where the wait returned, the typed error where it did not. + /// + /// **Metal has no side here, deliberately.** Metal does not come back from this call — the + /// probe that measured it ended with it — so [`crate::metal_side::MetalSide`] leaves this + /// default in place and must go on leaving it. A case over it says + /// [`MetalSource::did_not_return`] and record mode refuses the row before anything is encoded. + /// + /// Our own leg cannot hang: the runtime refuses the wait at once, so the handler returns and + /// the command buffer completes, and the side waits for it with a bound. + fn handler_wait(&mut self, wait: crate::handler_waits::OwnWait) -> Answer { + let _ = wait; + Err(Failure::unavailable("handler_wait")) + } + + /// What a shared event's value did, by the rising-value probe ([`crate::shared_events`]): + /// `newSharedEvent`, its label, the host's sets, two GPU signals, three host waits, and a + /// signal of `u64::MAX`. + /// + /// One call rather than a dozen, because the facts are a **sequence** — a value that did not + /// fall when a lower one was set — and a case cannot state that as independent calls whose + /// order nothing fixes. + fn shared_event_rises(&mut self, label: &str) -> Answer { + let _ = label; + Err(Failure::unavailable("shared_event_rises")) + } } /// A tile render pipeline a case makes: `MTLTileRenderPipelineDescriptor`'s facts the cases state. diff --git a/crates/metal2vulkan-conformance/src/cases.rs b/crates/metal2vulkan-conformance/src/cases.rs index c6625a6c5..fecac16e6 100644 --- a/crates/metal2vulkan-conformance/src/cases.rs +++ b/crates/metal2vulkan-conformance/src/cases.rs @@ -31,6 +31,7 @@ pub mod extended_range_planes; pub mod extended_range_targets; pub mod extended_range_two_planes; pub mod half_write_nans; +pub mod handler_waits; pub mod heap_metal_sizes; pub mod indirect_private_types; pub mod math_routines; @@ -43,6 +44,7 @@ pub mod pixel_samplers; pub mod rate_maps; pub mod rgb10a2_srgb; pub mod sample_fills; +pub mod shared_events; pub mod stage_in_regions; pub mod surface_fills; pub mod texture_accesses; @@ -133,6 +135,10 @@ pub fn all() -> Vec> { for case in textures::all() { cases.push(Box::new(case)); } + for case in handler_waits::all() { + cases.push(Box::new(case)); + } + cases.push(Box::new(shared_events::rising_value())); cases } diff --git a/crates/metal2vulkan-conformance/src/cases/handler_waits.rs b/crates/metal2vulkan-conformance/src/cases/handler_waits.rs new file mode 100644 index 000000000..396e049c4 --- /dev/null +++ b/crates/metal2vulkan-conformance/src/cases/handler_waits.rs @@ -0,0 +1,256 @@ +//! The three waits Metal does not come back from: a command buffer's own handler waiting for the +//! transition it is itself inside. +//! +//! A command buffer's scheduled and completed handlers run on threads of Metal's own, and a wait +//! made from one of them **for that same command buffer** is a wait for a transition the handler is +//! in the middle of. Metal does not detect it. The call does not return, the handler's thread stays +//! inside it, and the command buffer whose handler it is can never reach the state the wait is for. +//! +//! So there is no value here and no behaviour: three cases, each one site, each holding the single +//! fact there is — Metal never came back — against our typed refusal at the same site. That is +//! [`Verdict::MetalNeverReturned`](crate::verdict::Verdict::MetalNeverReturned), which is settled +//! before any allowance is consulted, so a case can neither loosen its way into it nor out of the +//! divergence it becomes if we ever answer where Metal did not. +//! +//! # Nothing of this runs on Metal, ever +//! +//! [`crate::metal_side::MetalSide`] does not implement +//! [`Side::handler_wait`] and must not: the call it would make is +//! the call that takes Metal's process with it. Record mode refuses these three rows before +//! anything is encoded ([`crate::case::MetalSource::forbidden`]), and their recordings are written +//! by hand from the probe that died, through [`crate::record::never_returned`] — the only way such +//! an answer is built. A test here holds each committed file to exactly what that function builds +//! from the case's own stated transcript, so a recording cannot drift from the case that states it. +//! +//! Our own leg is safe and bounded both ways: the runtime refuses the wait at once, so the handler +//! returns, the command buffer completes, and the case's own thread waits for that completion with +//! a bound. +//! +//! # What is deliberately not here +//! +//! A **completed** handler's `waitUntilScheduled` is the fourth combination, and the probe says +//! Metal returns from it, scheduling having already happened. It is left out: running it on Metal +//! would stake a record run on that prose, and the suite's standing rule against a shape that may +//! not come back does not bend for a sentence. The runtime's `Ok(())` there stays a `runtime_lane` +//! assertion. +//! +//! The runtime's **bounded** wait (`wait_until_completed_for`) is left out too, for a different +//! reason: Metal has no bounded wait, so its `TimedOut` is not a Metal fact and there is nothing +//! for a conformance case to compare it against. + +use crate::case::{Abort, Case, Input, MetalSource, Side}; +use crate::handler_waits::{HandlerKind, OwnWait, WaitKind}; +use crate::replay::NOTICES_SITE; +use crate::transcript::{Node, Observed, Sites, Transcript}; + +/// Where the probe that died is written down. +const PROBED_IN: &str = "metal2vulkan-validation runtime_lane::handler_waits, \ + waits_from_a_command_buffer_s_own_handlers_answer_at_once"; + +/// The chip the probe died on, as the suite names it. +/// +/// It is not this round's oracle, and it cannot become one: making the call is what ends the +/// process, so these three rows can no more be re-taken here than there. +/// [`crate::recording::Provenance::NeverReturned`] holds no chip — a row with no value has no +/// measurement to attribute — so it goes in [`crate::recording::Answer::device`], which +/// [`crate::recording::Answer::measured_elsewhere`] reads, and the report counts these rows among +/// the answers that did not come from this round's oracle. +const PROBED_ON: &str = crate::recording::APPLE_M4; + +/// The runs behind the answer: the probe made the call once and did not come back from it. +const PROBE_RUNS: u32 = 1; + +/// The command buffer every one of these cases makes, as the input fingerprint names it. One blit +/// filling the first 64 bytes of a shared buffer, committed once: the smallest piece of work that +/// has both transitions to wait for. +const COMMAND_BUFFER: &[u8] = b"one blit filling 64 bytes with 0x11, committed once"; + +/// A case over one wait a handler makes for its own command buffer. +pub struct OwnHandlerWait { + name: &'static str, + wait: OwnWait, + says: &'static str, +} + +/// The three cases: every handler-and-wait pair the probe found Metal does not return from. +pub fn all() -> Vec { + vec![ + OwnHandlerWait { + name: SCHEDULED_UNTIL_COMPLETED, + wait: OwnWait::new(HandlerKind::Scheduled, WaitKind::UntilCompleted), + says: "a scheduled handler's wait for its own command buffer's completion never \ + returns: Metal does not detect it, the handler's thread stays inside the call, \ + and the command buffer whose handler it is cannot complete while it is there", + }, + OwnHandlerWait { + name: SCHEDULED_UNTIL_SCHEDULED, + wait: OwnWait::new(HandlerKind::Scheduled, WaitKind::UntilScheduled), + says: "a scheduled handler's wait for its own command buffer's scheduling never \ + returns: the transition it waits for is the one it is itself inside", + }, + OwnHandlerWait { + name: COMPLETED_UNTIL_COMPLETED, + wait: OwnWait::new(HandlerKind::Completed, WaitKind::UntilCompleted), + says: "a completed handler's wait for its own command buffer's completion never \ + returns: the transition it waits for is the one it is itself inside", + }, + ] +} + +/// A scheduled handler waiting for its own command buffer to complete. +pub const SCHEDULED_UNTIL_COMPLETED: &str = "handler-waits-scheduled-until-completed"; + +/// A scheduled handler waiting for its own command buffer to be scheduled. +pub const SCHEDULED_UNTIL_SCHEDULED: &str = "handler-waits-scheduled-until-scheduled"; + +/// A completed handler waiting for its own command buffer to complete. +pub const COMPLETED_UNTIL_COMPLETED: &str = "handler-waits-completed-until-completed"; + +impl OwnHandlerWait { + /// The transcript the probe that died states: the one site, holding the negative fact. + /// + /// A site that is **present and negative** is the whole point. Leaving it out would let the row + /// read as a pass, which is exactly the hazard the record kind exists for: "Metal never + /// returned" and "nobody looked" must not print the same. + pub fn stated_transcript(&self) -> Result { + let mut sites = Sites::new(); + sites.push(crate::case::inputs_node(&self.inputs()?)); + sites.push(crate::handler_waits::never_returned(self.wait.site())); + sites.notices(NOTICES_SITE, &[] as &[&str]); + Ok(sites.finish()) + } + + /// The whole answer the case's recording holds, built the only way such an answer may be built + /// ([`crate::record::never_returned`]). + /// + /// The case states its own recording, rather than a file stating it: that is what makes a + /// hand-written recording checkable. A test holds the committed file to this, and the file was + /// first written from it. + pub fn stated_answer(&self) -> Result { + let MetalSource::DidNotReturn { from, call, .. } = self.metal_source() else { + return Err(format!( + "{}: its Metal source is not a call Metal left", + self.name + )); + }; + Ok(crate::record::never_returned( + metal2vulkan_runtime::MetalLevel::NEWEST, + from, + call, + PROBED_ON, + PROBE_RUNS, + self.stated_transcript()?, + )) + } +} + +impl Case for OwnHandlerWait { + fn name(&self) -> &'static str { + self.name + } + + fn metal_source(&self) -> MetalSource { + MetalSource::did_not_return(PROBED_IN, self.wait.site(), self.says) + } + + fn inputs(&self) -> Result, String> { + Ok(vec![ + Input::bytes("wait", &self.wait.words()), + Input::bytes("command-buffer", COMMAND_BUFFER), + ]) + } + + fn carried_transcript(&self) -> Result, String> { + Ok(Some((PROBE_RUNS, self.stated_transcript()?))) + } + + fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> { + let at = self.wait.site(); + // Both arms emit the same site, because the site is what the comparison settles on: a + // typed error there is the row's pass, and any answer at all is a divergence. + match side.handler_wait(self.wait) { + Ok(value) => sites.push(Node::leaf(at, Observed::value(value))), + Err(failure) => sites.push(Node::leaf(at, Observed::value(failure.value))), + } + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::recording::{self, Provenance, Recording, Validated}; + + /// Each committed recording is exactly what [`crate::record::never_returned`] builds from the + /// case's own stated answer. + /// + /// The files are written by hand because the shape cannot be run, which is precisely why they + /// need tying down: without this, a hand-written file could say anything, and a change to the + /// case's sites or inputs would leave it stale in silence. + #[test] + fn every_recording_is_the_answer_its_case_states() { + for case in all() { + let stated = + Recording::new(case.name(), Vec::new(), vec![case.stated_answer().unwrap()]); + let committed = + recording::read(case.name()).unwrap_or_else(|why| panic!("{}: {why}", case.name())); + assert_eq!( + committed, + stated, + "{}: its committed recording is not the answer the case states", + case.name() + ); + } + } + + /// Every one of them says Metal never returned, and says that Metal's validation layer was + /// never asked either. + #[test] + fn every_answer_names_the_call_and_claims_no_validated_fact() { + for case in all() { + let answer = case.stated_answer().unwrap(); + assert_eq!( + answer.provenance, + Provenance::NeverReturned { + from: PROBED_IN.to_owned(), + call: case.wait.site().to_owned(), + }, + "{}", + case.name() + ); + assert_eq!(answer.validated, Validated::NotRun, "{}", case.name()); + } + } + + /// Each answer is counted among those that did not come from this round's oracle. + /// + /// `Provenance::measured_elsewhere` reads the provenance's own chip, which a never-returned + /// row has none of, so reading it alone left all three out of the report's per-chip count -- + /// the one thing that count exists to prevent. [`crate::recording::Answer::measured_elsewhere`] + /// reads the field these rows do carry. + #[test] + fn every_answer_is_counted_as_coming_from_another_chip() { + for case in all() { + let answer = case.stated_answer().unwrap(); + assert_eq!( + answer.measured_elsewhere(), + Some(recording::APPLE_M4), + "{}: the report would not count it", + case.name() + ); + } + } + + /// Record mode refuses all three, in the case's own words. + #[test] + fn record_mode_refuses_every_one_of_them() { + for case in all() { + assert_eq!( + case.metal_source().forbidden(), + Some(case.says), + "{}: record mode would run it", + case.name() + ); + } + } +} diff --git a/crates/metal2vulkan-conformance/src/cases/shared_events.rs b/crates/metal2vulkan-conformance/src/cases/shared_events.rs new file mode 100644 index 000000000..7b7b4f00e --- /dev/null +++ b/crates/metal2vulkan-conformance/src/cases/shared_events.rs @@ -0,0 +1,97 @@ +//! A shared event's value only rises, from the host and from the GPU alike. +//! +//! `MTLSharedEvent` holds one 64-bit value. The host reads and writes it with `signaledValue` and +//! `setSignaledValue:`, the GPU raises it with `encodeSignalEvent:value:`, and the host waits for it +//! with `waitUntilSignaledValue:timeoutMS:`. A **lower** value, set or signalled, leaves it where it +//! was: the value is a high-water mark, not a register. +//! +//! The case walks that in one shape: +//! +//! - a new event's value; +//! - the host sets 5, then 3, then 5 — it reads 5, the 3 having changed nothing; +//! - a command buffer signals 3, then another signals 5 — it reads 5; +//! - a host wait for 3 and one for 5 answer, and one for 6 runs out; +//! - a command buffer signals `u64::MAX`, and a host wait for it answers. +//! +//! `runtime_lane::events` holds this as `a_shared_events_value_only_rises`, which asserts the +//! runtime agrees with itself. Here both sides answer and the answers are compared field by field, +//! so the numbers are Metal's rather than ours. +//! +//! # Why it is safe and quick +//! +//! The GPU's part is three command buffers that encode one signal each and nothing else: no shader, +//! no pass, no dispatch. Every wait of the case's own thread is bounded +//! ([`crate::shared_events::WAIT_MS`]), including the one that is meant to run out, and the two +//! bounded waits that are meant to answer are for values the event has already reached. +//! +//! The ordering facts of the event family — a wait that holds work until a signal arrives, and the +//! order two queues see — are not here. They need completed and scheduled handlers in the +//! vocabulary, which nothing has yet. + +use crate::case::{Abort, Case, Input, MetalSource, Side}; +use crate::shared_events::WAIT_MS; +use crate::transcript::{Node, Observed, Sites}; + +/// The case's name. +pub const RISING_VALUE: &str = "shared-event-rising-value"; + +/// The label the case sets, so `label` has something of ours to answer with. +const LABEL: &str = "conformance-rising-value"; + +/// The site the row sits at. +const AT: &str = "rising-value"; + +/// A case over what a shared event's value does. +pub struct RisingValue { + name: &'static str, +} + +/// The case. +pub fn rising_value() -> RisingValue { + RisingValue { name: RISING_VALUE } +} + +impl Case for RisingValue { + fn name(&self) -> &'static str { + self.name + } + + fn metal_source(&self) -> MetalSource { + MetalSource::Run + } + + fn inputs(&self) -> Result, String> { + // What the case feeds: the label it sets, the values the host sets and the GPU signals in + // order, the values it waits for, and the bound each wait is given. The bound is an input + // because it decides what a wait's answer means. + let mut words = Vec::new(); + for value in [5u64, 3, 5] { + words.extend(value.to_le_bytes()); + } + let mut signals = Vec::new(); + for value in [3u64, 5, u64::MAX] { + signals.extend(value.to_le_bytes()); + } + let mut waits = Vec::new(); + for value in [3u64, 5, 6, u64::MAX] { + waits.extend(value.to_le_bytes()); + } + Ok(vec![ + Input::bytes("label", LABEL.as_bytes()), + Input::bytes("host-sets", &words), + Input::bytes("gpu-signals", &signals), + Input::bytes("host-waits-for", &waits), + Input::bytes("wait-bound-millis", &WAIT_MS.to_le_bytes()), + ]) + } + + fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> { + match side.shared_event_rises(LABEL) { + Ok(rise) => sites.push(rise.node(AT)), + // The row records the failure and the run ends: every fact the case has is in the one + // call, so there is nothing after it to read. + Err(failure) => sites.push(Node::leaf(AT, Observed::value(failure.value))), + } + Ok(()) + } +} diff --git a/crates/metal2vulkan-conformance/src/handler_waits.rs b/crates/metal2vulkan-conformance/src/handler_waits.rs new file mode 100644 index 000000000..06f3897b6 --- /dev/null +++ b/crates/metal2vulkan-conformance/src/handler_waits.rs @@ -0,0 +1,116 @@ +//! A wait made from a command buffer's own handler: the vocabulary for the one shape Metal does not +//! come back from. +//! +//! Metal runs a command buffer's scheduled and completed handlers on threads of its own, and a wait +//! made from one of them for **that same command buffer** is a wait for a transition the handler is +//! itself in the middle of. Metal does not detect it: the call never returns, and the probe that +//! found that out ended with it. +//! +//! So there is nothing to carry and nothing to run. What a case over this pins is the one fact there +//! is — that Metal never came back, and that we answer a typed error there instead — through +//! [`MetalSource::did_not_return`](crate::case::MetalSource::did_not_return) and +//! [`Verdict::MetalNeverReturned`](crate::verdict::Verdict::MetalNeverReturned). +//! +//! **Nothing here has a Metal side, by construction.** [`crate::metal_side::MetalSide`] does not +//! implement [`Side::handler_wait`](crate::case::Side::handler_wait), and must not: the call it +//! would make is the call that ends Metal's process. Record mode refuses the row before anything is +//! encoded, and the recording is written from the probe that died. +//! +//! Our own leg is safe and bounded: the runtime refuses the wait at once, so the handler returns, +//! the command buffer completes, and the case's own thread waits for it with a bound. + +use crate::transcript::{Negative, Node, NodeName, Observed, Value}; + +/// Which of a command buffer's handlers the wait is made from. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum HandlerKind { + /// `addScheduledHandler:`. + Scheduled, + /// `addCompletedHandler:`. + Completed, +} + +impl HandlerKind { + /// The Metal call that adds it, which is how a site names it. + pub fn call(self) -> &'static str { + match self { + HandlerKind::Scheduled => "addScheduledHandler", + HandlerKind::Completed => "addCompletedHandler", + } + } +} + +/// Which wait the handler makes for its own command buffer. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum WaitKind { + /// `waitUntilCompleted`. + UntilCompleted, + /// `waitUntilScheduled`. + UntilScheduled, +} + +impl WaitKind { + /// The Metal call, which is how a site names it. + pub fn call(self) -> &'static str { + match self { + WaitKind::UntilCompleted => "waitUntilCompleted", + WaitKind::UntilScheduled => "waitUntilScheduled", + } + } +} + +/// One wait a case asks about: made from `from`, for the handler's own command buffer. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct OwnWait { + pub from: HandlerKind, + pub wait: WaitKind, +} + +impl OwnWait { + /// The wait `wait` made from `from`. + pub const fn new(from: HandlerKind, wait: WaitKind) -> Self { + Self { from, wait } + } + + /// The site the wait's answer sits at: the two calls, so a reader of a diff sees which handler + /// made which wait without counting rows. + /// + /// It is `'static` rather than built, because a recording's provenance names the call Metal did + /// not return from and must hold the same words the site does. + pub const fn site(&self) -> &'static str { + match (self.from, self.wait) { + (HandlerKind::Scheduled, WaitKind::UntilCompleted) => { + "addScheduledHandler/waitUntilCompleted" + } + (HandlerKind::Scheduled, WaitKind::UntilScheduled) => { + "addScheduledHandler/waitUntilScheduled" + } + (HandlerKind::Completed, WaitKind::UntilCompleted) => { + "addCompletedHandler/waitUntilCompleted" + } + (HandlerKind::Completed, WaitKind::UntilScheduled) => { + "addCompletedHandler/waitUntilScheduled" + } + } + } + + /// The words the wait fingerprints as, for a case's input fingerprint. + pub fn words(&self) -> Vec { + format!("{}:{}", self.from.call(), self.wait.call()).into_bytes() + } +} + +/// The site Metal's answer is, for a wait Metal does not come back from: the negative fact, not a +/// value. +/// +/// A case states this rather than leaving the site out, which is the whole point of the record kind: +/// "Metal never returned" and "nobody looked" must read differently, and a run of ours that +/// *answers* here is a divergence +/// ([`DivergenceKind::AnsweredWhereMetalDidNotReturn`](crate::diff::DivergenceKind::AnsweredWhereMetalDidNotReturn)), +/// not a pass. +pub fn never_returned(name: impl Into) -> Node { + Node::leaf( + name, + Observed::value(Value::Nothing(Negative::NeverReturned)), + ) +} diff --git a/crates/metal2vulkan-conformance/src/lib.rs b/crates/metal2vulkan-conformance/src/lib.rs index da2dccf1e..1d4078427 100644 --- a/crates/metal2vulkan-conformance/src/lib.rs +++ b/crates/metal2vulkan-conformance/src/lib.rs @@ -45,6 +45,7 @@ pub mod cost; pub mod device; pub mod diff; pub mod fixture; +pub mod handler_waits; pub mod known_refusals; pub mod measured; pub mod queue_slots; @@ -56,6 +57,7 @@ pub mod report; pub mod run; pub mod runtime_side; pub mod runtime_work; +pub mod shared_events; pub mod texture_query; pub mod transcript; pub mod validated; diff --git a/crates/metal2vulkan-conformance/src/metal_side.rs b/crates/metal2vulkan-conformance/src/metal_side.rs index 4f2b7c44c..0a7d8e71a 100644 --- a/crates/metal2vulkan-conformance/src/metal_side.rs +++ b/crates/metal2vulkan-conformance/src/metal_side.rs @@ -34,16 +34,18 @@ use objc2_metal::{ MTLBlendFactor, MTLBlendOperation, MTLBlitCommandEncoder, MTLBuffer, MTLClearColor, MTLCommandBuffer, MTLCommandBufferStatus, MTLCommandEncoder, MTLCommandQueue, MTLComputeCommandEncoder, MTLComputePipelineDescriptor, MTLComputePipelineState, - MTLCreateSystemDefaultDevice, MTLDevice, MTLFunction, MTLIndexType, MTLIndirectCommandBuffer, - MTLIndirectCommandBufferDescriptor, MTLIndirectCommandType, MTLIndirectRenderCommand, - MTLLibrary, MTLLoadAction, MTLMeshRenderPipelineDescriptor, MTLOrigin, MTLPipelineOption, - MTLPixelFormat, MTLPrimitiveType, MTLRasterizationRateLayerDescriptor, MTLRasterizationRateMap, + MTLCreateSystemDefaultDevice, MTLDevice, MTLEvent, MTLFunction, MTLIndexType, + MTLIndirectCommandBuffer, MTLIndirectCommandBufferDescriptor, MTLIndirectCommandType, + MTLIndirectRenderCommand, MTLLibrary, MTLLoadAction, MTLMeshRenderPipelineDescriptor, + MTLOrigin, MTLPipelineOption, MTLPixelFormat, MTLPrimitiveType, + MTLRasterizationRateLayerDescriptor, MTLRasterizationRateMap, MTLRasterizationRateMapDescriptor, MTLRegion, MTLRenderCommandEncoder, MTLRenderPassDescriptor, MTLRenderPipelineDescriptor, MTLRenderPipelineReflection, MTLRenderPipelineState, MTLRenderStages, MTLResource, MTLResourceOptions, MTLResourceUsage, MTLSamplerAddressMode, - MTLSamplerBorderColor, MTLSamplerDescriptor, MTLSamplerMinMagFilter, MTLSamplerState, MTLSize, - MTLStageInputOutputDescriptor, MTLStepFunction, MTLStorageMode, MTLStoreAction, MTLTexture, - MTLTextureDescriptor, MTLTextureType, MTLTextureUsage, MTLTileRenderPipelineDescriptor, + MTLSamplerBorderColor, MTLSamplerDescriptor, MTLSamplerMinMagFilter, MTLSamplerState, + MTLSharedEvent, MTLSize, MTLStageInputOutputDescriptor, MTLStepFunction, MTLStorageMode, + MTLStoreAction, MTLTexture, MTLTextureDescriptor, MTLTextureType, MTLTextureUsage, + MTLTileRenderPipelineDescriptor, }; /// The Metal level this side answers at: the host's own, since Metal answers as the release it runs @@ -1483,6 +1485,55 @@ impl Side for MetalSide { ) } + fn shared_event_rises(&mut self, label: &str) -> Answer { + use crate::shared_events::{EventRise, WAIT_MS}; + let event = self + .device + .newSharedEvent() + .ok_or_else(|| Failure::named("NewSharedEvent", "returned nil".to_owned()))?; + event.setLabel(Some(&NSString::from_str(label))); + let read_label = event.label().map(|label| label.to_string()); + let initial = event.signaledValue(); + // The host's sets: a lower value leaves the event where it was. + event.setSignaledValue(5); + event.setSignaledValue(3); + event.setSignaledValue(5); + let after_host_sets = event.signaledValue(); + let as_event: &ProtocolObject = ProtocolObject::from_ref(&*event); + let signal = |value: u64| -> Answer { + // One autorelease pool per signal: the command buffer this answers is autoreleased, + // and a loop that makes several without a pool that drains keeps every one of them + // alive. + objc2::rc::autoreleasepool(|_| { + let command_buffer = self + .queue + .commandBuffer() + .ok_or_else(|| Failure::named("CommandBuffer", "returned nil".to_owned()))?; + command_buffer.encodeSignalEvent_value(as_event, value); + command_buffer.commit(); + command_buffer.waitUntilCompleted(); + Ok(event.signaledValue()) + }) + }; + let after_gpu_signals = [signal(3)?, signal(5)?]; + let waits = [ + event.waitUntilSignaledValue_timeoutMS(3, WAIT_MS), + event.waitUntilSignaledValue_timeoutMS(5, WAIT_MS), + event.waitUntilSignaledValue_timeoutMS(6, WAIT_MS), + ]; + let after_max_signal = signal(u64::MAX)?; + let waited_for_max = event.waitUntilSignaledValue_timeoutMS(u64::MAX, WAIT_MS); + Ok(EventRise { + label: read_label, + initial, + after_host_sets, + after_gpu_signals, + waits, + after_max_signal, + waited_for_max, + }) + } + fn makes_texture(&mut self, query: &HeapTextureQuery) -> Answer { let descriptor = queried_descriptor(query); // The texture, where Metal makes one, is released as this statement ends: the case asks diff --git a/crates/metal2vulkan-conformance/src/recording.rs b/crates/metal2vulkan-conformance/src/recording.rs index bb33310d6..c25a10197 100644 --- a/crates/metal2vulkan-conformance/src/recording.rs +++ b/crates/metal2vulkan-conformance/src/recording.rs @@ -212,7 +212,12 @@ pub struct Outcome { pub struct Answer { pub key: OracleKey, pub provenance: Provenance, - /// The device Metal named, for the reader. Nothing compares against it. + /// Where the answer came from: the device Metal named, for a run, and for a row Metal did not + /// return from, the chip the probe died on, as the suite names it. + /// + /// Nothing in a transcript compares against it. One thing reads it: + /// [`Answer::measured_elsewhere`], because a never-returned row has no other field that says + /// which machine it came from, and the report's per-chip count must not miss it. pub device: String, /// The runs behind the answer: the sum of the outcomes' runs. pub runs: u32, @@ -224,6 +229,25 @@ pub struct Answer { } impl Answer { + /// The chip the answer was measured on, where that is not this round's oracle. + /// + /// Two provenances can say so, and they say it in different fields. + /// [`Provenance::Carried`] holds the chip itself. A row Metal did not return from holds none: + /// it has no value and so no measurement to attribute, and the machine its probe died on is + /// named in [`Answer::device`] alone. Reading only the provenance left every such row out of + /// the report's per-chip count -- which is the one thing that count exists to prevent, an + /// answer from a machine this round cannot re-record on passing unremarked. + pub fn measured_elsewhere(&self) -> Option<&str> { + match &self.provenance { + Provenance::NeverReturned { .. } => { + (self.device != ORACLE_CHIP).then_some(self.device.as_str()) + } + Provenance::Carried { .. } | Provenance::MetalRun => { + self.provenance.measured_elsewhere() + } + } + } + /// The one transcript the answer holds, where the case was deterministic. pub fn deterministic(&self) -> Option<&Transcript> { match self.outcomes.as_slice() { diff --git a/crates/metal2vulkan-conformance/src/replay.rs b/crates/metal2vulkan-conformance/src/replay.rs index 581356589..1fc321594 100644 --- a/crates/metal2vulkan-conformance/src/replay.rs +++ b/crates/metal2vulkan-conformance/src/replay.rs @@ -182,7 +182,7 @@ pub fn replay_against_known( venue, verdict: Verdict::LacksFeature { needs: lacks }, allowances: Allowances::default(), - measured_on: answer.provenance.measured_elsewhere().map(str::to_owned), + measured_on: answer.measured_elsewhere().map(str::to_owned), ours, }); } @@ -193,7 +193,7 @@ pub fn replay_against_known( venue, verdict, allowances, - measured_on: answer.provenance.measured_elsewhere().map(str::to_owned), + measured_on: answer.measured_elsewhere().map(str::to_owned), ours, }) } diff --git a/crates/metal2vulkan-conformance/src/runtime_side.rs b/crates/metal2vulkan-conformance/src/runtime_side.rs index 7a2cc3605..834295418 100644 --- a/crates/metal2vulkan-conformance/src/runtime_side.rs +++ b/crates/metal2vulkan-conformance/src/runtime_side.rs @@ -42,6 +42,10 @@ use std::time::Duration; /// The longest the side waits for a command buffer. A wait that runs out is recorded, not retried. const WAIT: Duration = Duration::from_secs(60); +/// The bytes the handler-wait probe's command buffer fills, so it has real work to be scheduled and +/// completed for rather than being an empty commit. +const HANDLER_FILL: u64 = 64; + /// The runtime side: the device, the queue the case's command buffers come from, and the objects /// the case has made, by handle. pub struct RuntimeSide<'a> { @@ -1578,6 +1582,104 @@ impl Side for RuntimeSide<'_> { ) } + fn handler_wait(&mut self, wait: crate::handler_waits::OwnWait) -> Answer { + use crate::handler_waits::{HandlerKind, WaitKind}; + use std::sync::mpsc; + let queue = self + .device + .new_command_queue() + .map_err(Failure::from_error)?; + let buffer = self + .device + .new_buffer(HANDLER_FILL, ResourceOptions::shared()) + .map_err(Failure::from_error)?; + let command_buffer = queue.command_buffer().map_err(Failure::from_error)?; + let mut blit = command_buffer + .blit_command_encoder() + .map_err(Failure::from_error)?; + blit.fill_buffer(&buffer, 0..HANDLER_FILL, 0x11) + .map_err(Failure::from_error)?; + blit.end_encoding().map_err(Failure::from_error)?; + let (sender, answer) = mpsc::channel(); + let kind = wait.wait; + let handler: metal2vulkan_runtime::Handler = Box::new(move |own: &CommandBuffer| { + let answered = match kind { + WaitKind::UntilCompleted => own.wait_until_completed(), + WaitKind::UntilScheduled => own.wait_until_scheduled(), + }; + let _ = sender.send(answered.err().map(|error| Failure::of(&error))); + }); + match wait.from { + HandlerKind::Scheduled => command_buffer.add_scheduled_handler(handler), + HandlerKind::Completed => command_buffer.add_completed_handler(handler), + } + .map_err(Failure::from_error)?; + command_buffer.commit().map_err(Failure::from_error)?; + // Bounded, so a runtime that did not refuse the handler's wait is recorded rather than + // hanging the suite: the handler would then still be inside its wait and the command + // buffer would never complete. + if command_buffer.wait_until_completed_for(WAIT).is_err() { + return Ok(Value::Nothing(Negative::NeverReturned)); + } + match answer.recv_timeout(WAIT) { + Ok(None) => Ok(Value::ok(Value::Absent)), + Ok(Some(failure)) => Err(failure), + Err(_) => Ok(Value::Nothing(Negative::NeverReturned)), + } + } + + fn shared_event_rises(&mut self, label: &str) -> Answer { + use crate::shared_events::{EventRise, WAIT_MS}; + let bound = Duration::from_millis(WAIT_MS); + let queue = self + .device + .new_command_queue() + .map_err(Failure::from_error)?; + let event = self + .device + .new_shared_event() + .map_err(Failure::from_error)?; + event.set_label(label); + let read_label = event.label(); + let initial = event.signaled_value(); + // The host's sets: a lower value leaves the event where it was. + event.set_signaled_value(5); + event.set_signaled_value(3); + event.set_signaled_value(5); + let after_host_sets = event.signaled_value(); + let signal = |value: u64| -> Answer { + let command_buffer = queue.command_buffer().map_err(Failure::from_error)?; + command_buffer + .encode_signal_event(metal2vulkan_runtime::EventRef::from(&event), value) + .map_err(Failure::from_error)?; + command_buffer.commit().map_err(Failure::from_error)?; + if command_buffer.wait_until_completed_for(WAIT).is_err() { + return Err(Failure::named( + "NeverCompleted", + format!("the command buffer signalling {value}"), + )); + } + Ok(event.signaled_value()) + }; + let after_gpu_signals = [signal(3)?, signal(5)?]; + let waits = [ + event.wait_until_signaled_value(3, bound), + event.wait_until_signaled_value(5, bound), + event.wait_until_signaled_value(6, bound), + ]; + let after_max_signal = signal(u64::MAX)?; + let waited_for_max = event.wait_until_signaled_value(u64::MAX, bound); + Ok(EventRise { + label: read_label, + initial, + after_host_sets, + after_gpu_signals, + waits, + after_max_signal, + waited_for_max, + }) + } + fn makes_texture(&mut self, query: &HeapTextureQuery) -> Answer { match self.device.new_texture(&queried_descriptor(query)) { Ok(_) => Ok(true), diff --git a/crates/metal2vulkan-conformance/src/shared_events.rs b/crates/metal2vulkan-conformance/src/shared_events.rs new file mode 100644 index 000000000..7e76772f9 --- /dev/null +++ b/crates/metal2vulkan-conformance/src/shared_events.rs @@ -0,0 +1,79 @@ +//! What a shared event's value does: the vocabulary for the event family's first case. +//! +//! `MTLSharedEvent`'s value **only rises**, from the host and from the GPU alike: a lower value set +//! or signalled leaves it where it was. A host wait for a value the event has reached answers at +//! once, and one for a value above it runs out. +//! +//! Every fact here is a value or a boolean, so the record is a small set of fields rather than +//! bytes, and the GPU's part is three command buffers that encode one signal each and nothing else. + +use crate::transcript::{Node, NodeName, Observed, Value}; + +/// How long a host wait is given before it counts as having run out. +/// +/// Short on purpose: the waits a case makes are for values the event has **already** reached, which +/// answer at once, and for one it has not, which never will. A long bound would only make the case +/// slow. +pub const WAIT_MS: u64 = 10; + +/// What one run of the rising-value probe observed. Each field is one call's answer. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct EventRise { + /// `label`, after `setLabel:`. + pub label: Option, + /// `signaledValue` of a new event. + pub initial: u64, + /// `signaledValue` after the host set 5, then 3, then 5. + pub after_host_sets: u64, + /// `signaledValue` after a command buffer signalled 3, and then after one signalled 5. + pub after_gpu_signals: [u64; 2], + /// `waitUntilSignaledValue:timeoutMS:` for 3, for 5 and for 6, each with [`WAIT_MS`]. + pub waits: [bool; 3], + /// `signaledValue` after a command buffer signalled `u64::MAX`. + pub after_max_signal: u64, + /// Whether the host wait for `u64::MAX` answered. + pub waited_for_max: bool, +} + +impl EventRise { + /// The observations as the sites a case emits under one node, so both sides emit one shape. + pub fn node(&self, name: impl Into) -> Node { + let label = match &self.label { + Some(label) => Value::Variant { + name: "Some".to_owned(), + payload: Box::new(Value::Lines(vec![label.clone()])), + }, + None => Value::unit_variant("None"), + }; + let mut node = Node::branch(name, Vec::new()) + .with(Node::leaf("label", Observed::value(label))) + .with(Node::leaf( + "signaled-value/new", + Observed::value(Value::Uint(self.initial)), + )) + .with(Node::leaf( + "signaled-value/after-host-sets", + Observed::value(Value::Uint(self.after_host_sets)), + )); + for (at, (value, signalled)) in self.after_gpu_signals.iter().zip([3u64, 5]).enumerate() { + node = node.with(Node::leaf( + format!("signaled-value/after-gpu-signal-{at}-of-{signalled}"), + Observed::value(Value::Uint(*value)), + )); + } + for (answered, wanted) in self.waits.iter().zip([3u64, 5, 6]) { + node = node.with(Node::leaf( + format!("wait-until-signaled-value/{wanted}"), + Observed::value(Value::Bool(*answered)), + )); + } + node.with(Node::leaf( + "signaled-value/after-gpu-signal-of-u64-max", + Observed::value(Value::Uint(self.after_max_signal)), + )) + .with(Node::leaf( + "wait-until-signaled-value/u64-max", + Observed::value(Value::Bool(self.waited_for_max)), + )) + } +} diff --git a/crates/metal2vulkan-conformance/src/validated.rs b/crates/metal2vulkan-conformance/src/validated.rs index d54e26db0..251fbcd4a 100644 --- a/crates/metal2vulkan-conformance/src/validated.rs +++ b/crates/metal2vulkan-conformance/src/validated.rs @@ -512,4 +512,14 @@ impl Side for Announcing { self.at("render"); self.inner.render(work) } + + fn handler_wait(&mut self, wait: crate::handler_waits::OwnWait) -> Answer { + self.at("handler_wait"); + self.inner.handler_wait(wait) + } + + fn shared_event_rises(&mut self, label: &str) -> Answer { + self.at("shared_event_rises"); + self.inner.shared_event_rises(label) + } }