From 9886324e315a4db7d9df0d94dc3ff3f5b813a6ff Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 3 Dec 2026 08:30:45 -0800 Subject: [PATCH] Translator: a device-address access checked against its pushed length is named checked What: AccessPlan gains bounded, the memory-plan slots reached by their device address that read their PushField::SlotBounds (place_slots puts a device-address slot there where AccessPlan::variable holds it), and AccessPlan::check names a target of one checked. A load, store, quad store or buffer atomic of such a slot carries .checked in its census name, as a view's does. Copies' names are unchanged (they carry no check). SEMANTICS 2359: census names change, no module word does. Why: emit::prepare checks an access of such a slot whose emitted offset is not a constant against the slot's pushed length, so the name now says the check the module runs. Verified (lavapipe and CPU interpreter, job m3-max-84692 at a8256703d8, the same patches before the rebase onto 436dd1045e): the two flipped tests fail at the red commit and pass here; clippy plain, m2v_gpu and m2v_cpu_icd exit 0; translator 2620 of 2621 passed, 20 skipped, the one failure golden_hashes with all 28950 cells under a changed profile fingerprint (the table awaits its bless since the device policy went); validation 1348 passed, 2 skipped; rustdoc and private rustdoc of the seven crates clean; the lavapipe conformance replay exits 0 with no ledger drift. Job m3-max-84598 (the same change on 848acada38): air, runtime, devtools and harness 872 passed, 4 skipped; conformance 1053 passed; doctests 2 passed; the full golden and inventory lists at the base and here move 0 values (28950 and 1233 cells). --- crates/metal2vulkan/src/cache/mod.rs | 2 +- crates/metal2vulkan/src/lower/access/mod.rs | 17 +++++++++++++---- crates/metal2vulkan/src/memory/contain.rs | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index d88a2e3c2..f7da77627 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -60,7 +60,7 @@ mod tests; /// unchanged version, and its bless records the version. Independent of the crate's version and of /// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no /// history. -pub const SEMANTICS_VERSION: u32 = 2358; +pub const SEMANTICS_VERSION: u32 = 2359; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another diff --git a/crates/metal2vulkan/src/lower/access/mod.rs b/crates/metal2vulkan/src/lower/access/mod.rs index 145c99995..05251b394 100644 --- a/crates/metal2vulkan/src/lower/access/mod.rs +++ b/crates/metal2vulkan/src/lower/access/mod.rs @@ -468,11 +468,12 @@ impl AccessPlan { ) } - /// The containment check target `t` takes as emitted (`emit::prepare`): none for a - /// device-address slot, whose accesses are checked against its pushed length where they may - /// reach another offset ([`AccessPlan::variable`]), else the in-shader check. + /// The containment check target `t` is named by: the in-shader check for a storage view, and + /// for a device-address slot that reads its pushed length ([`AccessPlan::bounded`]), against + /// which its accesses at an offset that is not a constant are checked (`emit::prepare`); none + /// for any other device-address slot, which no access reaches at a run-time offset. pub fn check(&self, t: &Target) -> Check { - match self.by_address(t) { + match self.by_address(t) && !self.bounded.contains(&t.slot) { true => Check::None, false => Check::InShader, } @@ -709,6 +710,11 @@ pub struct AccessPlan { /// slot is reached by its device address reads `PushField::ZeroAddress` outside its buffer /// (`emit::prepare`, `pulled`), whatever offset its own access proved. pub read: BTreeSet, + /// The memory-plan slots reached by their device address that read their + /// `PushField::SlotBounds` ([`AccessPlan::variable`]): an access of one whose emitted offset + /// is not a constant is checked against it (`emit::prepare`), and every access of one is + /// named checked ([`AccessPlan::check`]). + pub bounded: BTreeSet, /// Under the identity domains, a kernel on a device that binds its buffer arguments /// (`DeviceProfile::binds_kernel_buffers`): its storage views are its slots' buffers, each /// bound over its buffer, and its pipeline's robust buffer access 2 contains them @@ -1202,6 +1208,9 @@ fn place_slots(cx: &mut SelectCx<'_>, m: &mut Meter) -> Result { addressed_slot(cx, plan.slot); + if cx.families.access.variable.contains(&plan.slot) { + cx.families.access.bounded.insert(i); + } if let Some(align) = address_alignment(cx, plan) { // A word memory's base is a multiple of 4; a slot each of whose accesses is // one narrow unit needs only that unit's alignment. diff --git a/crates/metal2vulkan/src/memory/contain.rs b/crates/metal2vulkan/src/memory/contain.rs index 8746d776b..c2a7bdc21 100644 --- a/crates/metal2vulkan/src/memory/contain.rs +++ b/crates/metal2vulkan/src/memory/contain.rs @@ -24,8 +24,8 @@ use crate::spirv::ir::{BinOp, ConstBits, Constant}; /// How one leaf access is contained. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Check { - /// No in-shader check: a device-address access under the identity domains, which nothing - /// bounds (`AccessPlan::psb_contained`). + /// No in-shader check: a device-address access under the identity domains of a slot no access + /// reaches at a run-time offset, which nothing bounds (`AccessPlan::psb_contained`). None, /// The normative in-shader check. InShader,