From 5ee4a0c3efddf36d2cb57e9f002f71a92be9b491 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 23 Oct 2026 17:08:31 +0300 Subject: [PATCH] Keep no address Metal printed in a recording, and guard it The steps this packet landed as, in order: - Say in the module docs why the one unguardable key is not a fallback - Regenerate the coverage document for the visibility re-key Content: the tree of `development` at 1bf1f53209, unchanged. --- .../visibility-boolean-offsets.json | 2 +- ...bility-boolean-revisit-after-covering.json | 2 +- ...ibility-boolean-revisit-after-nothing.json | 2 +- .../visibility-counting-offsets.json | 2 +- ...ility-counting-revisit-after-disabled.json | 2 +- .../visibility-counting-revisit.json | 2 +- .../src/cases/visibility.rs | 26 +++++++- crates/metal2vulkan-conformance/src/tests.rs | 59 +++++++++++++++++++ .../metal2vulkan-conformance/src/validated.rs | 54 ++++++++++++++++- docs/CONFORMANCE-COVERAGE.md | 9 +-- 10 files changed, 147 insertions(+), 13 deletions(-) diff --git a/crates/metal2vulkan-conformance/recordings/visibility-boolean-offsets.json b/crates/metal2vulkan-conformance/recordings/visibility-boolean-offsets.json index fb11fb2c6..84480f5c6 100644 --- a/crates/metal2vulkan-conformance/recordings/visibility-boolean-offsets.json +++ b/crates/metal2vulkan-conformance/recordings/visibility-boolean-offsets.json @@ -371,7 +371,7 @@ "validated": { "stopped": { "call": "render", - "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nprevious setVisibilityResultMode was unused.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." + "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nprevious setVisibilityResultMode was unused.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." } } } diff --git a/crates/metal2vulkan-conformance/recordings/visibility-boolean-revisit-after-covering.json b/crates/metal2vulkan-conformance/recordings/visibility-boolean-revisit-after-covering.json index 574d9fbc1..a1949bb87 100644 --- a/crates/metal2vulkan-conformance/recordings/visibility-boolean-revisit-after-covering.json +++ b/crates/metal2vulkan-conformance/recordings/visibility-boolean-revisit-after-covering.json @@ -280,7 +280,7 @@ "validated": { "stopped": { "call": "render", - "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nusing the same offset (0) in the visibility buffer twice in the same command encoder is not allowed.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." + "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nusing the same offset (0) in the visibility buffer twice in the same command encoder is not allowed.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." } } } diff --git a/crates/metal2vulkan-conformance/recordings/visibility-boolean-revisit-after-nothing.json b/crates/metal2vulkan-conformance/recordings/visibility-boolean-revisit-after-nothing.json index d1bd9fe12..9e6b7b518 100644 --- a/crates/metal2vulkan-conformance/recordings/visibility-boolean-revisit-after-nothing.json +++ b/crates/metal2vulkan-conformance/recordings/visibility-boolean-revisit-after-nothing.json @@ -280,7 +280,7 @@ "validated": { "stopped": { "call": "render", - "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nusing the same offset (0) in the visibility buffer twice in the same command encoder is not allowed.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." + "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nusing the same offset (0) in the visibility buffer twice in the same command encoder is not allowed.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." } } } diff --git a/crates/metal2vulkan-conformance/recordings/visibility-counting-offsets.json b/crates/metal2vulkan-conformance/recordings/visibility-counting-offsets.json index dea13e9f6..6acd8ab5c 100644 --- a/crates/metal2vulkan-conformance/recordings/visibility-counting-offsets.json +++ b/crates/metal2vulkan-conformance/recordings/visibility-counting-offsets.json @@ -280,7 +280,7 @@ "validated": { "stopped": { "call": "render", - "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nprevious setVisibilityResultMode was unused.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." + "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nprevious setVisibilityResultMode was unused.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." } } } diff --git a/crates/metal2vulkan-conformance/recordings/visibility-counting-revisit-after-disabled.json b/crates/metal2vulkan-conformance/recordings/visibility-counting-revisit-after-disabled.json index b5439f972..43e099eee 100644 --- a/crates/metal2vulkan-conformance/recordings/visibility-counting-revisit-after-disabled.json +++ b/crates/metal2vulkan-conformance/recordings/visibility-counting-revisit-after-disabled.json @@ -280,7 +280,7 @@ "validated": { "stopped": { "call": "render", - "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nusing the same offset (0) in the visibility buffer twice in the same command encoder is not allowed.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." + "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nusing the same offset (0) in the visibility buffer twice in the same command encoder is not allowed.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." } } } diff --git a/crates/metal2vulkan-conformance/recordings/visibility-counting-revisit.json b/crates/metal2vulkan-conformance/recordings/visibility-counting-revisit.json index 117a86435..76844a9c6 100644 --- a/crates/metal2vulkan-conformance/recordings/visibility-counting-revisit.json +++ b/crates/metal2vulkan-conformance/recordings/visibility-counting-revisit.json @@ -280,7 +280,7 @@ "validated": { "stopped": { "call": "render", - "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nusing the same offset (0) in the visibility buffer twice in the same command encoder is not allowed.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." + "message": "redundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = .\nSet Visibility Result Mode Validation\nusing the same offset (0) in the visibility buffer twice in the same command encoder is not allowed.\nredundant setting of \n label = \n length = 8\n cpuCacheMode = MTLCPUCacheModeDefaultCache\n storageMode = MTLStorageModeShared\n hazardTrackingMode = MTLHazardTrackingModeTracked\n resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked\n purgeableState = MTLPurgeableStateNonVolatile\n label = ." } } } diff --git a/crates/metal2vulkan-conformance/src/cases/visibility.rs b/crates/metal2vulkan-conformance/src/cases/visibility.rs index 1784c330a..c1b6ccf0b 100644 --- a/crates/metal2vulkan-conformance/src/cases/visibility.rs +++ b/crates/metal2vulkan-conformance/src/cases/visibility.rs @@ -25,7 +25,31 @@ //! - The same questions counted, and the fullscreen triangle's count at **4x**, which is the one //! shape here with a multisampled attachment. //! -//! Nothing here can fault a GPU: one 4 by 4 target a pass, three vertices a draw, no loop. +//! # How this family's inputs are keyed, and the one key the compiler cannot guard +//! +//! Every input fingerprint here is **the name of the Metal call and the values handed it**, never +//! `Debug` text. Three of them were `format!("{:?}")`, and one was the worst instance of that trap +//! in the suite: the depth/stencil state keyed on +//! [`metal2vulkan::metal::state::DepthStencilDescriptor`], a public type of the **published** +//! translator crate, so a field added to that struct in another crate staled these recordings and +//! nothing in either crate connected the two. +//! +//! `Act` and `Depth` are this module's own types, so they are matched and destructured with +//! **no `..`**: a field added to either is a compile error here, which is where the decision +//! belongs. +//! +//! **The depth/stencil key cannot have that protection, and the substitute is not a fallback.** +//! `DepthStencilDescriptor` and `StencilDescriptor` are `#[non_exhaustive]`, so this crate cannot +//! destructure them field by field — the compiler *requires* a `..` — and there is no compile +//! error to be had across that boundary. So `depth_state_words` states the one field this family +//! sets and **refuses rather than keys** a descriptor that differs from +//! `DepthStencilDescriptor::default()` anywhere else. That gives both halves of what is wanted, +//! and it holds without any help from the compiler: a field this family starts setting surfaces as +//! an error out of `inputs()` instead of a key quietly missing it, while a field left at its +//! default writes nothing — which is the property that actually stops a widened descriptor from +//! staling these recordings. +//! +//! //! Nothing here can fault a GPU: one 4 by 4 target a pass, three vertices a draw, no loop. use crate::allowance::{Allowance, Justification, Loosening}; use crate::case::{Abort, Case, Failure, Handle, Input, MetalSource, Side}; diff --git a/crates/metal2vulkan-conformance/src/tests.rs b/crates/metal2vulkan-conformance/src/tests.rs index bbcd33be6..f61f64ab1 100644 --- a/crates/metal2vulkan-conformance/src/tests.rs +++ b/crates/metal2vulkan-conformance/src/tests.rs @@ -1647,6 +1647,65 @@ fn the_committed_recordings_carry_all_three_validated_answers() { ); } +/// **No committed recording holds an address Metal printed.** +/// +/// A validation complaint names the object it is about by its pointer +/// (``), which is this run's heap and moves under ASLR, so a +/// recording that kept one could never be re-recorded byte for byte — and a re-record that changes +/// nothing is how a fingerprint refresh is told from a re-measurement. `crate::validated::read` +/// normalises them to `0xADDR`; this is what keeps "contained to six recordings" from quietly +/// becoming sixty, in this family or any other. +/// +/// Every answer of every recording is read, not only the newest chip's, so an answer carried from +/// another chip cannot smuggle one in. +#[test] +fn no_recorded_message_holds_an_address() { + /// `0x` and this many hexadecimal digits is an address, which is + /// `crate::validated::ADDRESS_DIGITS`. + const DIGITS: usize = 6; + let holds_address = |text: &str| { + let bytes = text.as_bytes(); + (0..bytes.len()).any(|at| { + bytes[at] == b'0' + && at + 1 < bytes.len() + && bytes[at + 1] | 0x20 == b'x' + && bytes[at + 2..] + .iter() + .take_while(|byte| byte.is_ascii_hexdigit()) + .count() + >= DIGITS + }) + }; + // The scan itself finds one, so a green run means the recordings are clean and not that the + // check cannot fire. + assert!(holds_address("")); + assert!(!holds_address("length = 8, mask = 0xffff")); + let mut held: Vec = Vec::new(); + let mut messages = 0; + for case in crate::cases::all() { + let recording = crate::recording::read(case.name()) + .unwrap_or_else(|why| panic!("{}: {why}", case.name())); + for answer in &recording.answers { + let Validated::Stopped { call, message } = &answer.validated else { + continue; + }; + messages += 1; + if holds_address(message) { + held.push(format!("{}: {call}: {message}", case.name())); + } + } + } + assert!( + held.is_empty(), + "{} recording(s) keep an address Metal printed, which no re-record can reproduce:\n{}", + held.len(), + held.join("\n") + ); + // And the walk really read the validated messages there are, so the emptiness above is a + // result rather than a selection that found nothing to look at. + assert!(messages > 0, "no recording holds a validation complaint"); +} + /// The committed ledger parses, every row names a gap, and each row's case is a real case. /// /// A row whose case has been renamed away would otherwise read as "no longer held" forever, or diff --git a/crates/metal2vulkan-conformance/src/validated.rs b/crates/metal2vulkan-conformance/src/validated.rs index b7988e6ce..5ca354cf9 100644 --- a/crates/metal2vulkan-conformance/src/validated.rs +++ b/crates/metal2vulkan-conformance/src/validated.rs @@ -65,7 +65,12 @@ //! not seen is still attributed and still recorded. //! //! The message a recording keeps is stripped of `NSLog`'s timestamp and process prefix, because a -//! recording holds nothing host-specific: the prefix carries this run's process id. +//! recording holds nothing host-specific: the prefix carries this run's process id. The same rule +//! takes out the **addresses** Metal prints — a complaint names the object it is about by its +//! pointer (``), which is this run's heap and moves under ASLR +//! on every run, so it is host-specific in the strongest sense. A recording holding one could +//! never be re-recorded byte for byte, and a re-record that changes nothing is how a fingerprint +//! refresh is told from a re-measurement. use crate::recording::Validated; @@ -161,7 +166,7 @@ pub fn read(said: &str) -> Option { if text.is_empty() || text.starts_with(BANNER) { continue; } - complaint.push(text.to_owned()); + complaint.push(strip_addresses(text)); } (!complaint.is_empty()).then(|| Validated::Stopped { call: if call.is_empty() { @@ -190,6 +195,51 @@ fn strip_prefix(line: &str) -> &str { line.trim_end() } +/// What a recording keeps in place of an address Metal printed. +/// +/// Normalised and **not** removed, so the complaint still reads as the sentence Apple wrote and a +/// reader can see that a pointer was there. +const ADDRESS: &str = "0xADDR"; + +/// The hexadecimal digits that make a `0x` number an address rather than a constant Metal quoted. +/// +/// Six, which is the threshold the suite-wide guard `no_recorded_message_holds_an_address` holds +/// the committed recordings to, so the two cannot drift. An arm64 pointer prints ten or eleven digits; +/// a shorter `0x` number in a complaint is left as the number it is. +const ADDRESS_DIGITS: usize = 6; + +/// `text` with every address Metal printed replaced by [`ADDRESS`]. +/// +/// The reason is the module's: an address is this run's heap, so it must not reach a recording, for +/// the same reason `NSLog`'s process prefix must not. +fn strip_addresses(text: &str) -> String { + let bytes = text.as_bytes(); + let mut out = String::with_capacity(text.len()); + let mut at = 0; + while at < bytes.len() { + // `0x` or `0X` and then enough hexadecimal digits. Only ASCII is stepped over here, so + // `at` stays on a character boundary for the branch below. + if bytes[at] == b'0' && at + 1 < bytes.len() && bytes[at + 1] | 0x20 == b'x' { + let digits = bytes[at + 2..] + .iter() + .take_while(|byte| byte.is_ascii_hexdigit()) + .count(); + if digits >= ADDRESS_DIGITS { + out.push_str(ADDRESS); + at += 2 + digits; + continue; + } + } + let next = text[at..] + .chars() + .next() + .expect("at is a character boundary"); + out.push(next); + at += next.len_utf8(); + } + out +} + /// A side that announces each call it is about to make, so the parent can attribute Metal's own /// output to the call that provoked it. It observes nothing and changes nothing else. /// diff --git a/docs/CONFORMANCE-COVERAGE.md b/docs/CONFORMANCE-COVERAGE.md index c0bbf3c35..8e3bc3f89 100644 --- a/docs/CONFORMANCE-COVERAGE.md +++ b/docs/CONFORMANCE-COVERAGE.md @@ -10,9 +10,10 @@ The suite reaches Metal through `objc2-metal`, whose Rust name for a binding is Its limits, measured rather than asserted: -- **451 of 546 call sites** in the Metal leg resolve to an item of the SDK. 30 of those resolve because only one type in `objc2-metal` binds the name at all, so no typing was needed. -- **95 call sites' receivers did not type.** They cost the count 7 selectors, which the suite calls and which this attributes to no item: +- **451 of 550 call sites** in the Metal leg resolve to an item of the SDK. 30 of those resolve because only one type in `objc2-metal` binds the name at all, so no typing was needed. +- **99 call sites' receivers did not type.** They cost the count 8 selectors, which the suite calls and which this attributes to no item: - `type`, bound by `MTLArgument`, `MTLArgumentDescriptor`, `MTLBinding`, `MTLPointerType`, `MTLTensorReferenceType`, `MTLTextureReferenceType` + - `count`, bound by `MTL4CounterHeap`, `MTL4CounterHeapDescriptor` - `executeCommandsInBuffer:withRange:`, bound by `MTL4ComputeCommandEncoder`, `MTL4RenderCommandEncoder`, `MTLComputeCommandEncoder`, `MTLRenderCommandEncoder` - `imageblockSampleLength`, bound by `MTL4RenderPassDescriptor`, `MTLRenderPassDescriptor`, `MTLRenderPipelineState` - `index`, bound by `MTLArgument`, `MTLArgumentDescriptor`, `MTLBinding`, `MTLFunctionConstant` @@ -271,8 +272,8 @@ An implemented container no case's Metal leg touches. These are the families of | `Side` methods the Metal leg reaches an SDK item through | 48 | | SDK items a case's Metal leg reaches, median | 31 | | the same, least and most | 0 and 83 | -| Metal call sites in the leg | 546 | -| distinct selectors the leg sends | 227 | +| Metal call sites in the leg | 550 | +| distinct selectors the leg sends | 228 | | of those, resolved to an item of the coverage map | 220 | | oracles the recordings name | `apple-m3-max` ×693 |