diff --git a/crates/metal2vulkan-validation/src/candidate/engine.rs b/crates/metal2vulkan-validation/src/candidate/engine.rs index 372fae8aa..f5dd7fd5a 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine.rs @@ -94,7 +94,7 @@ pub mod variants; /// how it decides a match. A change no recorded row can observe (a case kind no earlier executor /// ran, or one it refused) needs no bump; its commit says why. The commit that bumps it says what /// changed; this comment keeps no history. -pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v213"; +pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v214"; /// One kernel case in the terms the runtime route takes: what this executor supports of an /// [`AuthoredCase`] (buffers, device buffer arrays, argument-buffer buffers and textures, diff --git a/crates/metal2vulkan-validation/src/case/out_of_bounds.rs b/crates/metal2vulkan-validation/src/case/out_of_bounds.rs index 4f89f0b69..92afbad7d 100644 --- a/crates/metal2vulkan-validation/src/case/out_of_bounds.rs +++ b/crates/metal2vulkan-validation/src/case/out_of_bounds.rs @@ -155,7 +155,9 @@ pub enum ContainmentForm { /// Accesses to a `device` buffer argument the product reaches by its device address (a /// `BufferForm::Psb` slot: a typed atomic or a wide pointer reaches it). DeviceAddress, - /// Accesses to a `[[threadgroup(n)]]` buffer, in the threadgroup arena. + /// Accesses to a `[[threadgroup(n)]]` buffer, in the threadgroup arena, which no profile + /// checks: the candidate refuses a case of it before it runs + /// (`executor_contract::out_of_bounds`). Threadgroup, /// Reads and writes of a `texture_buffer`. TexelBuffer, diff --git a/crates/metal2vulkan-validation/src/coverage.rs b/crates/metal2vulkan-validation/src/coverage.rs index 5e52d07c1..0ad06d5d2 100644 --- a/crates/metal2vulkan-validation/src/coverage.rs +++ b/crates/metal2vulkan-validation/src/coverage.rs @@ -96,10 +96,11 @@ pub enum ImageEncoding { /// reads (the access targets' checks, `lower::texture::slot`). /// /// Census names do not all show the encoding they compiled under, so the report keys its rows by -/// this, taken from the compile, not by the names. An access by device address (a `BufferForm::Psb` -/// slot or a wide pointer) or to an arena is checked in the shader whatever the profile; the census -/// names it apart from a descriptor access of the same strategy, so the name, not the module, says -/// which accesses these encodings apply to. +/// this, taken from the compile, not by the names. These encodings do not govern an access by +/// device address (a `BufferForm::Psb` slot or a wide pointer) or to the private arena, which is +/// checked in the shader whatever the profile, nor one to the threadgroup arena, which no profile +/// checks; the census names each apart from a descriptor access of the same strategy, so the name, +/// not the module, says which accesses these encodings apply to. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(from = "ContainmentRecord")] pub struct Containment { diff --git a/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds.rs b/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds.rs index f08a439d0..fce8dda5b 100644 --- a/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds.rs +++ b/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds.rs @@ -7,9 +7,8 @@ //! //! - **The form and mechanism** of each target are what its compiled module does with it, never //! only what the case says ([`containment`]): a buffer is a storage buffer through its -//! descriptor, or a device address; a buffer slot the product reaches through a descriptor view, -//! a slot reached by its device address and the threadgroup arena are checked in the shader in -//! every leg, except that a kernel whose buffer arguments are bound as storage buffers of set 0 +//! descriptor, or a device address; a buffer slot the product reaches through a descriptor view +//! and a slot reached by its device address are checked in the shader in every leg, except that a kernel whose buffer arguments are bound as storage buffers of set 0 //! (`ModuleFacts::robust_views`) leaves its views' loads and stores to its pipeline's //! `robustBufferAccess2` and checks only their atomics in the shader; a texel buffer and an image follow the product's texel containment //! (`DeviceProfile::device_reads_texels` and `device_drops_texel_writes`): a texel buffer is @@ -17,7 +16,10 @@ //! `robustImageAccess` at either level, each otherwise checked in the shader. A buffer reached through a pointer loaded from an argument buffer is a //! device address the resident set resolves, a thread-local array a typed object whose index is //! checked against its length, and an argument buffer's texture array a handle table the loaded -//! resource id is looked up in: each checked in the shader in every leg. Under the identity +//! resource id is looked up in: each checked in the shader in every leg. The threadgroup arena is +//! checked nowhere: no profile checks a threadgroup access, and one past the memory is undefined, +//! as in Metal (docs/API.md, "Threadgroup memory"), so the candidate does not run a case reaching +//! past it ([`Check::Unchecked`]). Under the identity //! domains (`DevicePolicy`) a loaded pointer is the address it holds, which nothing checks, so //! the candidate does not run the case ([`Check::Unchecked`]), and a loaded resource id's index //! is masked onto the descriptor arrays, whose elements no live texture owns are null @@ -119,8 +121,9 @@ pub enum Check { Padded, /// Nothing checks the access: neither the shader nor the device's robustness bounds it (a /// pointer loaded from memory under the identity pointer domain, `PointerDomain::Identity`, - /// is the device address it holds, used as given, and fixed-function vertex input on a device - /// without buffer robustness fetches past its buffer what the device gives). A run would reach + /// is the device address it holds, used as given; fixed-function vertex input on a device + /// without buffer robustness fetches past its buffer what the device gives; and no profile + /// checks a threadgroup access). A run would reach /// memory no binding gave the case, so the candidate refuses the case before it makes the /// pipeline (`NotSupported::Uncontained`). Unchecked, @@ -235,9 +238,9 @@ pub fn read_rule(form: ContainmentForm, mechanism: Mechanism, written: bool) -> // (its checker rule), so none reaches a byte the in-range indices do not, and the declared // read bytes, which only a vertex id outside the buffer's indices reaches, stay zero. (Medium::IndexBuffer, _) | (_, Check::Binder | Check::Padded) => ReadRule::Zero, - // An in-shader check yields zero for a load and for a skipped atomic; a device address, the - // arena, and a typed object take it in every leg. - (Medium::DeviceAddress | Medium::Arena | Medium::TypedObject, _) + // An in-shader check yields zero for a load and for a skipped atomic; a device address and + // a typed object take it in every leg. + (Medium::DeviceAddress | Medium::TypedObject, _) | (_, Check::Shader | Check::ShaderReads) => ReadRule::Zero, // Robust buffer access 2: a load returns zero, an atomic an undefined value. (_, Check::Robust2) if form == ContainmentForm::BufferAtomic => ReadRule::Any, @@ -470,10 +473,13 @@ pub fn containment( } _ => Err(format!("{} is not a buffer slot", target.resource.label())), }, + // No profile checks a threadgroup access, the arena's or a typed threadgroup object's + // index: one past the memory is undefined, as in Metal (docs/API.md, "Threadgroup + // memory"), and reads what the device holds there. OutOfBoundsResource::ThreadgroupMemory { .. } => made( ContainmentForm::Threadgroup, Medium::Arena, - Check::Shader, + Check::Unchecked, true, ), OutOfBoundsResource::ArgumentBufferBuffer { buffer_binding, .. } => { diff --git a/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds/tests.rs b/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds/tests.rs index 56974a3cf..d70b7cb9a 100644 --- a/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds/tests.rs +++ b/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds/tests.rs @@ -111,7 +111,7 @@ fn the_read_rule_follows_the_mechanism_not_the_case() { assert_eq!(rule(form, medium, Check::Shader, true), ReadRule::Zero); } } - // A device address and the arena are checked in the shader whatever the leg. + // A device address is checked in the shader whatever the leg. assert_eq!( rule(F::BufferAtomic, Medium::DeviceAddress, Check::Robust2, true), ReadRule::Zero diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index f7f11869e..90be40282 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -537,7 +537,9 @@ cargo run -p metal2vulkan-validation --release --bin corpus-vulkan -- \ `not_supported{uncontained:variant ...}` naming the one that differs. The facts are the identity domains' (`DevicePolicy`): a buffer reached through a pointer loaded from an argument buffer is the address the pointer holds, which nothing checks (the runtime's README states it), so such a - case is refused as `not_supported{uncontained:unchecked loaded_pointer}`, and an argument + case is refused as `not_supported{uncontained:unchecked loaded_pointer}`; threadgroup memory, + whose accesses no profile checks (one past it is undefined, as in Metal), is refused the same + way as `not_supported{uncontained:unchecked threadgroup}`; and an argument buffer's texture array is the descriptor arrays its resource ids' masked indices read (`resource-id:shader`), a read past it a texel of a bound texture or zero. Each buffer target, and the buffer a texture-buffer target is made over, sits between guards of its declared reach