conformance: a new texture's fresh read is unchecked on metal2vulkan-rt, where Metal is silent

rt answers a new texture with whatever its memory last held. Metal's two texture-making sentences
say nothing of a new texture's contents: MTLDevice.h gives newTextureWithDescriptor: only
"Allocate a new texture with privately owned storage.", and Apple's page only "Creates a new
texture instance.". The page for newBufferWithLength:options: promises zeros ("Creates a buffer
the method clears with zero values."). An Apple M3 Max on macOS 27.0.1 read zero from new Shared
and Managed textures.

What changes:
- A new justification, Justification::NewRuntimeAccepted(slug): an accepted difference of
  docs/API.md that holds on the rt run alone. On the old runtime's run it is
  Unjustified::OldRuntime, which faults nothing, so the old runtime's answers still compare.
- The declaration replay::new_texture_contents(site) leaves the site unchecked under the new
  docs/API.md entry "The new runtime's new textures read what their memory last held". It carries
  the four facts above and the words "silent", never "undefined".
- It is named at the fresh site of every texture row:
  - fresh-texture-* and fresh-chain-*, every storage mode;
  - fresh-pattern-*;
  - texture-round-trip-*;
  - each format-footprints round trip.
- It is not named by any buffer row or texture-over-buffer row: Metal promises those zeros, and
  they stay exact on rt. The written sites and the statuses stay exact on both runtimes. rt writes
  nothing to pass a row.

Why: these rows' fresh sites follow process history on rt. m3-max-52251 (lavapipe, rt) ran plain
development at ed2d2295ce and 391db1e57a and the set at be7ff19f8a:
- 73, 74 and 74 rows divergent, all at fresh sites.
- texture-round-trip-1/12/13/14 are exact each alone in a process and divergent after other cases.
- Which Shared/Managed fresh-texture rows read the released texture's 0xa5 changes from run to
  run, even alone.

Tests:
- a_new_texture_s_fresh_read_is_unchecked_on_the_new_runtime_alone: the bytes are unchecked on rt
  and are the site's one row on the old runtime. A written-site difference stays a row. An
  unknown slug fails the case.
- The fresh rows' allowance test now holds the declaration on every texture and pattern row and
  on no buffer row.
This commit is contained in:
Anees Iqbal committed 2026-11-19 06:55:22 -08:00
1 parent b9969c9987
commit 2f4c9fc9dc
7 files changed
+174 -16

No files matched your search

@@ -72,6 +72,13 @@ pub enum Justification {
/// runtime's contract, a static note it answers by a format's class on every device, where
/// the old runtime announces the same notice under other facts.
NewRuntimeNotice(String),
/// **An entry of `docs/API.md`'s accepted differences that holds on `metal2vulkan-rt` alone**,
/// by its slug. On the new runtime's run it holds as [`Justification::AcceptedDifference`]
/// does; on the old runtime's it holds nowhere and faults nothing
/// ([`Unjustified::OldRuntime`]), so the old runtime's answers at the site still compare
/// exactly. It is for an answer the new runtime gives where Metal's documentation is silent
/// and the old runtime gives Metal's measured one.
NewRuntimeAccepted(String),
}
impl Justification {
@@ -101,6 +108,12 @@ impl Justification {
Self::NewRuntimeNotice(kind.code().to_owned())
}
/// An accepted difference's justification on `metal2vulkan-rt`'s run alone, by its entry's
/// slug.
pub fn new_runtime_accepted(slug: impl Into<String>) -> Self {
Self::NewRuntimeAccepted(slug.into())
}
/// What the report prints for it.
pub fn describe(&self) -> String {
match self {
@@ -118,6 +131,9 @@ impl Justification {
Justification::NewRuntimeNotice(code) => {
format!("the degrade notice {code}, on metal2vulkan-rt")
}
Justification::NewRuntimeAccepted(slug) => format!(
"the accepted difference {slug} (docs/API.md section 10), on metal2vulkan-rt"
),
}
}
@@ -147,6 +163,12 @@ impl Justification {
(!accepted_differences().iter().any(|entry| entry == slug))
.then(|| Unjustified::NoSuchAcceptedDifference(slug.clone()))
}
Justification::NewRuntimeAccepted(slug) => {
if !accepted_differences().iter().any(|entry| entry == slug) {
return Some(Unjustified::NoSuchAcceptedDifference(slug.clone()));
}
(!offered.new_runtime).then_some(Unjustified::OldRuntime)
}
Justification::MetalValidation { says } => match offered.metal_validation {
Validated::Stopped { message, .. } if message.contains(says) => None,
Validated::Stopped { message, .. } => {
@@ -187,8 +209,9 @@ pub struct Offered<'a> {
/// `true` unless the run says otherwise ([`Offered::on_venue`]), so a venue's answer justifies
/// nothing by default.
pub lossless_compression: bool,
/// Whether the run is `metal2vulkan-rt`'s ([`Justification::NewRuntimeNotice`]). `false`
/// unless the run says otherwise ([`Offered::on_new_runtime`]).
/// Whether the run is `metal2vulkan-rt`'s ([`Justification::NewRuntimeNotice`],
/// [`Justification::NewRuntimeAccepted`]). `false` unless the run says otherwise
/// ([`Offered::on_new_runtime`]).
pub new_runtime: bool,
}
@@ -251,8 +274,9 @@ pub enum Unjustified {
/// The venue presents a Mac that keeps textures compressed, as the recordings' Apple silicon
/// Mac does, so the answer of a venue that keeps none justifies nothing here.
VenueCompresses,
/// The run is the old runtime's, where a notice the case scopes to `metal2vulkan-rt`
/// ([`Justification::NewRuntimeNotice`]) loosens nothing.
/// The run is the old runtime's, where a notice or an accepted difference the case scopes to
/// `metal2vulkan-rt` ([`Justification::NewRuntimeNotice`],
/// [`Justification::NewRuntimeAccepted`]) loosens nothing.
OldRuntime,
}
@@ -260,8 +284,9 @@ impl Unjustified {
/// Whether an allowance that does not hold for this reason faults the case. Every reason does
/// but two: a venue's own answer ([`Justification::WithoutCompression`]) on a venue that
/// presents Metal's compression holds nowhere, as on the Mac that recorded the case, and a
/// notice scoped to `metal2vulkan-rt` ([`Justification::NewRuntimeNotice`]) holds nowhere on
/// the old runtime's run, so naming either is no fault there. The site then compares as if the
/// notice or accepted difference scoped to `metal2vulkan-rt`
/// ([`Justification::NewRuntimeNotice`], [`Justification::NewRuntimeAccepted`]) holds nowhere
/// on the old runtime's run, so naming either is no fault there. The site then compares as if the
/// case loosened nothing, and a difference there is the site's own and nothing more.
pub fn faults_the_case(&self) -> bool {
!matches!(self, Unjustified::VenueCompresses | Unjustified::OldRuntime)
@@ -299,8 +324,8 @@ impl std::fmt::Display for Unjustified {
does, so the answer of a venue that keeps none justifies nothing here",
),
Unjustified::OldRuntime => out.write_str(
"the run is the old runtime's, which a notice scoped to metal2vulkan-rt does not \
loosen",
"the run is the old runtime's, which a notice or an accepted difference scoped to \
metal2vulkan-rt does not loosen",
),
}
}
@@ -34,7 +34,9 @@
//! [`crate::cases::textures`] uses: a 16 by 16 `Shared` texture read fresh, written whole by
//! `replaceRegion:`, and read back, both reads into a destination that already holds [`BEFORE`] so
//! a byte the copy did not write is a recorded value rather than a zero nobody can tell from a
//! written one.
//! written one. On `metal2vulkan-rt`'s run the fresh read is unchecked: a new texture there reads
//! what its memory last held, where Metal's texture-making calls are silent
//! ([`crate::replay::new_texture_contents`]).
//!
//! ## What each sweep can tell apart, measured
//!
@@ -598,6 +600,12 @@ impl Case for FootprintCase {
if self.shared_texture_buffers {
named.push(crate::replay::shared_memory_notice());
}
// Each round trip's fresh read, on the new runtime: a new texture there reads what its
// memory last held, where Metal's texture-making calls are silent. The write and the read
// back still compare exactly.
named.extend(self.round_trips.iter().map(|format| {
crate::replay::new_texture_contents(&format!("{}/{}", format.name(), site::FRESH))
}));
named
}
@@ -47,6 +47,16 @@
//! compression. The `written` site, the statuses and every `Shared` and `Managed` row still compare
//! exactly there.
//!
//! **On `metal2vulkan-rt`'s run, the `fresh` site of every texture row and every pattern row is
//! declared too** ([`crate::replay::new_texture_contents`]), of every storage mode: Metal's two
//! texture-making sentences are silent on a new texture's contents, and the new runtime reads what
//! the texture's memory last held, so the site moves with what the process made and released
//! before the row. Replayed on lavapipe, the `Shared` and `Managed` rows read the released
//! texture's [`OLD`] or an earlier case's bytes, and which of them did moved from run to run, each
//! row alone in a process included. The buffer rows and the texture-over-buffer rows read a
//! buffer's memory, whose zeros Metal promises, and name no such declaration; the `written` site
//! and the statuses compare exactly on both runtimes.
//!
//! Every row names one notice, and it belongs to the venue rather than to any row: the declaration
//! [`crate::replay::shared_memory_notice`] carries, the notice a device without unified memory
//! announces for the `Shared` buffer each row reads its answer back through.
@@ -1096,7 +1106,14 @@ impl Case for FreshTexture {
}
fn allowances(&self) -> Vec<Allowance> {
let mut allowances = vec![shared_memory_notice()];
// A new texture of every storage mode, on the new runtime, reads what its memory last
// held, where Metal's texture-making calls are silent (the module docs). Replayed on
// lavapipe: the Shared and Managed rows read the released texture's `OLD`, or an earlier
// case's bytes, and which rows do moves from run to run.
let mut allowances = vec![
shared_memory_notice(),
crate::replay::new_texture_contents("fresh"),
];
// A new `Private` texture on a device that presents no texture compression holds what
// its memory held (the module docs). Expected, not yet run: no such venue replayed it.
if self.row.storage == Storage::Private {
@@ -1386,6 +1403,9 @@ impl Case for FreshPattern {
// canonical encoding, so every value still compares exactly.
let mut allowances = vec![
shared_memory_notice(),
// A new texture on the new runtime reads what its memory last held, where Metal's
// texture-making calls are silent (the module docs).
crate::replay::new_texture_contents("fresh"),
// A new `Private` texture on a device that presents no texture compression holds
// what its memory held, never the pattern (the module docs). Expected, not yet run.
crate::replay::without_compression("fresh"),
@@ -2098,8 +2118,10 @@ mod tests {
/// [`crate::replay::without_compression`], justifies nothing there.
///
/// Every row names [`shared_memory_notice`], which is the venue's memory model and not the
/// row's; every `Private` texture row and every pattern row names the value declaration at its
/// `fresh` site, and no `Shared` or `Managed` row, buffer row or texture over a buffer does;
/// row's; every texture row and every pattern row names the new runtime's declaration at its
/// `fresh` site ([`crate::replay::new_texture_contents`]), and no buffer row or texture over a
/// buffer does, whose zeros Metal promises; every `Private` texture row and every pattern row
/// names the value declaration at its `fresh` site, and no `Shared` or `Managed` row does;
/// **only** the three pattern rows whose read blits out of a texture Metal keeps compressed in
/// a format whose canonical encoding the device's copy may keep apart from Metal's
/// (`BGRA10_XR`, its sRGB twin, `RGB9E5Float`; the notes lavapipe announced) name a further
@@ -2113,6 +2135,7 @@ mod tests {
fn a_row_loosens_the_notices_site_and_a_private_texture_s_fresh_site() {
let notices = format!("case/{}/*", crate::replay::NOTICES_SITE);
let fresh = crate::replay::without_compression("fresh");
let silent = crate::replay::new_texture_contents("fresh");
let [zeroed, _] = zeroed_depth_pattern();
let shared = metal2vulkan_runtime::Degradation::SharedInSystemMemory
.code()
@@ -2121,7 +2144,10 @@ mod tests {
let allowances = case.allowances();
for allowance in &allowances {
assert!(
allowance.path == notices || *allowance == fresh || *allowance == zeroed,
allowance.path == notices
|| *allowance == fresh
|| *allowance == silent
|| *allowance == zeroed,
"{}: {allowance:?}",
case.name()
);
@@ -2142,7 +2168,7 @@ mod tests {
let allowances = FreshTexture { row }.allowances();
assert_eq!(
allowances.len(),
1 + usize::from(private) + 3 * usize::from(depth) + usize::from(compressed),
2 + usize::from(private) + 3 * usize::from(depth) + usize::from(compressed),
"{}",
row.case
);
@@ -2155,6 +2181,7 @@ mod tests {
row.case
);
assert_eq!(allowances.contains(&fresh), private, "{}", row.case);
assert!(allowances.contains(&silent), "{}", row.case);
assert_eq!(allowances.contains(&zeroed), depth, "{}", row.case);
}
// Everything else is held to Metal exactly, the venue's own notice apart.
@@ -2181,11 +2208,12 @@ mod tests {
let allowances = FreshPattern { row }.allowances();
assert_eq!(
allowances.len(),
2 + usize::from(kept) + 2 * usize::from(depth),
3 + usize::from(kept) + 2 * usize::from(depth),
"{}",
row.case
);
assert!(allowances.contains(&fresh), "{}", row.case);
assert!(allowances.contains(&silent), "{}", row.case);
assert_eq!(allowances.contains(&zeroed), depth, "{}", row.case);
}
}
@@ -4,7 +4,9 @@
//! One case a format. Each one makes an 8 by 8 `Shared` 2D texture of its format, read by shaders,
//! at a row pitch one texel wider than its rows, then asks three things of it:
//!
//! - what a **fresh** texture reads (`get_bytes`), which Metal answers as zero;
//! - what a **fresh** texture reads (`get_bytes`), which Metal answers as zero, and which
//! `metal2vulkan-rt`'s run leaves unchecked: there a new texture reads what its memory last
//! held, where Metal's texture-making calls are silent ([`crate::replay::new_texture_contents`]);
//! - what it reads back after `replace_region` wrote the case's pattern over its whole level 0;
//! - whether the **bytes between the rows** stayed as they were.
//!
@@ -284,6 +286,15 @@ impl Case for TextureRoundTrip {
MetalSource::Run
}
fn allowances(&self) -> Vec<crate::allowance::Allowance> {
// The fresh read alone, on the new runtime: a new texture there reads what its memory
// last held, where Metal's texture-making calls are silent. Replayed on lavapipe, four of
// these rows read zero each alone in a process, and an earlier case's bytes after the
// suite's other cases. The written read and the gaps between the rows still compare
// exactly.
vec![crate::replay::new_texture_contents("fresh")]
}
fn inputs(&self) -> Result<Vec<Input>, String> {
Ok(vec![
Input::bytes("format", &self.format.as_raw().to_le_bytes()),
@@ -462,6 +462,33 @@ pub fn without_compression(site: &str) -> crate::allowance::Allowance {
)
}
/// The slug of `docs/API.md`'s accepted difference that says what a new texture reads on
/// `metal2vulkan-rt` ([`new_texture_contents`]).
pub const NEW_TEXTURE_CONTENTS: &str =
"the-new-runtime-s-new-textures-read-what-their-memory-last-held";
/// The declaration a case needs at `site`, what a **new texture** reads before anything writes
/// it, on `metal2vulkan-rt`'s run.
///
/// **What it rests on**, the accepted difference [`NEW_TEXTURE_CONTENTS`] names: Metal's two
/// texture-making sentences are silent on a new texture's contents; the page for
/// `newBufferWithLength:options:` promises zeros; an Apple M3 Max on macOS 27.0.1 read zero from new
/// `Shared` and `Managed` textures; and the new runtime reads what the texture's memory last held,
/// so the site moves with what the process made and released before the case.
///
/// **It loosens that site alone, and only on the new runtime.** The site is unchecked under
/// [`Justification::NewRuntimeAccepted`], which holds nowhere on the old runtime's run, so the old
/// runtime's answers there still compare exactly. A case names it at a texture's fresh read and
/// never at a buffer's, whose zeros Metal promises: the written site, the statuses and every
/// buffer row compare exactly on both runtimes.
pub fn new_texture_contents(site: &str) -> crate::allowance::Allowance {
crate::allowance::Allowance::new(
format!("case/{site}/*"),
crate::allowance::Loosening::Unchecked,
Justification::new_runtime_accepted(NEW_TEXTURE_CONTENTS),
)
}
/// The declaration a case needs where its kernel reaches a texture or a sampler through an
/// **argument buffer**: `set-past-layout-support`, which the runtime announces where it makes a
/// descriptor set layout its driver's `vkGetDescriptorSetLayoutSupport` refuses though the driver
@@ -2957,6 +2957,57 @@ fn a_notice_scoped_to_the_new_runtime_leaves_the_old_runtimes_site_its_one_row()
assert!(!Verdict::of(&found, &Validated::NotRun).is_compliant());
}
/// **A new texture's fresh read is unchecked on the new runtime's run alone.**
/// [`crate::replay::new_texture_contents`] names an accepted difference
/// ([`Justification::NewRuntimeAccepted`]) that holds on `metal2vulkan-rt`'s run: there a fresh
/// read of another process's leftovers, the released texture's `0xa5` bytes as lavapipe read them,
/// is no divergence. On the old runtime's run it holds nowhere and faults nothing, so the same
/// bytes are the site's own one row. A slug `docs/API.md` does not hold fails the case on either
/// run.
#[test]
fn a_new_texture_s_fresh_read_is_unchecked_on_the_new_runtime_alone() {
let bytes = |byte: u8| Observed::value(Value::Bytes(vec![byte; 4]));
let transcript = |fresh: u8, written: u8| {
Transcript::new(vec![
Node::branch("fresh", vec![Node::leaf("texel", bytes(fresh))]),
Node::leaf("written", bytes(written)),
])
};
let allowances = vec![crate::replay::new_texture_contents("fresh")];
let metal = transcript(0, 7);
let ours = transcript(0xa5, 7);
let paths = |found: &crate::compare::Comparison| -> Vec<String> {
found.divergences.iter().map(|at| at.path.clone()).collect()
};
let old = Offered::notices(&[]);
let found = compare(&metal, &ours, &allowances, old);
assert!(found.bad_allowances.is_empty(), "{found:?}");
assert_eq!(paths(&found), ["case/fresh/texel"], "{found:?}");
assert_eq!(
found.unfired[0].why,
Some(Unjustified::OldRuntime.to_string())
);
let rt = old.on_new_runtime(true);
let found = compare(&metal, &ours, &allowances, rt);
assert!(found.divergences.is_empty(), "{found:?}");
assert!(found.bad_allowances.is_empty(), "{found:?}");
assert!(found.unfired.is_empty(), "{found:?}");
// The written site is not the declaration's: a difference there is a row on either run.
let found = compare(&metal, &transcript(0xa5, 8), &allowances, rt);
assert_eq!(paths(&found), ["case/written"], "{found:?}");
let unknown = vec![Allowance::new(
"case/fresh/*",
Loosening::Unchecked,
Justification::new_runtime_accepted("no-such-entry"),
)];
let found = compare(&metal, &ours, &unknown, rt);
assert_eq!(found.bad_allowances.len(), 1, "{found:?}");
assert!(!Verdict::of(&found, &Validated::NotRun).is_compliant());
}
/// **A venue's own answer at a site that differs on a venue presenting Metal's compression is the
/// site's one row.** [`crate::replay::without_compression`] holds only where the venue keeps no
/// texture compressed; on the Mac that recorded the case (MoltenVK on the M3 Max) it holds
+8
View File
@@ -6381,6 +6381,14 @@ each item named states the rule in full.
reads the bytes as they are when the GPU runs it, so a write the consumer makes after the call
and before then may be seen. Metal leaves it undefined: an Apple M3 and an Intel UHD 630 take
the bytes when the GPU reads them, an AMD Radeon Pro 5300M at the commit.
- **The new runtime's new textures read what their memory last held** (`metal2vulkan-rt`'s
`Device::new_texture`). Metal's two texture-making sentences are silent on a new texture's
contents: `MTLDevice.h` gives `newTextureWithDescriptor:` "Allocate a new texture with privately
owned storage.", and Apple's page for it "Creates a new texture instance.". The page for
`newBufferWithLength:options:` promises zeros: "Creates a buffer the method clears with zero
values." An Apple M3 Max on macOS 27.0.1 read zero from new `Shared` and `Managed` textures. The
new runtime reads what the texture's memory last held, so what a new texture reads moves with
what the process made and released before it.
**Function constants**