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,