diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index cf89159e7..630a2e41c 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 = 2363; +pub const SEMANTICS_VERSION: u32 = 2364; /// 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/blob.rs b/crates/metal2vulkan/src/lower/access/blob.rs index 571fdba32..d3eb7fe61 100644 --- a/crates/metal2vulkan/src/lower/access/blob.rs +++ b/crates/metal2vulkan/src/lower/access/blob.rs @@ -17,10 +17,10 @@ use std::sync::Arc; use crate::air::ir::{CastOp, Const, Inst, InstId, InstKind, Value, ValueId}; -use crate::error::{AccessCause, Error}; +use crate::error::{AccessCause, DiagName, Error, IdentityCause, Unsupported}; use crate::lower::emit::EmitCx; use crate::lower::select::SelectCx; -use crate::memory::blob::{BlobUse, ModuleWords}; +use crate::memory::blob::{BlobUse, ModuleWords, MODULE_BYTES}; use crate::memory::contain; use crate::memory::leaf::{self, k32, Leaf, WordMem}; use crate::memory::plan::{ConstGlobalForm, MemoryPlan}; @@ -143,7 +143,9 @@ pub fn lowered_pointer(cx: &SelectCx<'_>, v: Value) -> Result, } /// Record that the function reads the blob, its bytes shared with the memory plan's: the module's -/// words, with no descriptor. +/// words, with no descriptor. A blob past [`MODULE_BYTES`] is refused here, at the first read +/// through memory, naming its size (`Unsupported{IdentityDomains}`, not implemented: the module +/// holds no such blob's words). pub fn use_blob(cx: &mut SelectCx<'_>) -> Result<(), Error> { if cx.families.access.blob.is_some() { return Ok(()); @@ -152,6 +154,13 @@ pub fn use_blob(cx: &mut SelectCx<'_>) -> Result<(), Error> { Some(b) => Arc::clone(&b.bytes), None => return Err(cx.invariant("a blob pointer without a blob")), }; + let len = bytes.len() as u64; + if len > MODULE_BYTES { + let form = format!("constant data of {len} bytes read through memory"); + return Err(Unsupported::identity(IdentityCause::ConstantBlob) + .naming(DiagName::new(form)) + .into()); + } cx.families.access.blob = Some(BlobUse { bytes }); Ok(()) } diff --git a/crates/metal2vulkan/src/lower/select.rs b/crates/metal2vulkan/src/lower/select.rs index fd9a55b3b..600b2e4d8 100644 --- a/crates/metal2vulkan/src/lower/select.rs +++ b/crates/metal2vulkan/src/lower/select.rs @@ -1877,16 +1877,6 @@ fn identity_refusal(plan: &Plan) -> Option<(IdentityCause, String)> { format!("state of a bound texture or sampler beyond its resource ID ({f:?})"), )); } - // The module holds the blob's words (`memory::blob`) up to its bound. - if let Some(blob) = &plan.families.access.blob { - let bytes = blob.bytes.len() as u64; - if bytes > crate::memory::blob::MODULE_BYTES { - return Some(( - IdentityCause::ConstantBlob, - format!("constant data of {bytes} bytes read through memory"), - )); - } - } // A bound kernel's storage views are set 0's storage buffers, one a view slot. let bound = match views { true => (plan.slots.iter().flatten())