diff --git a/crates/metal2vulkan-validation/profiles/README.md b/crates/metal2vulkan-validation/profiles/README.md index 81c4b4142..86d663baf 100644 --- a/crates/metal2vulkan-validation/profiles/README.md +++ b/crates/metal2vulkan-validation/profiles/README.md @@ -80,7 +80,7 @@ Reading notes for consumers of these files: - A file states what its source reports, not what the driver honors. `moltenvk-m3` states `robustBufferAccess` as MoltenVK reports it, but MoltenVK adds no bounds check for it: on the captured device out-of-bounds storage and uniform buffer accesses, buffer atomics, and vertex - fetches read and wrote the next buffer's memory, while texel buffers were contained. Validation records it as a driver limitation (`HostClass::robust_buffers_uncontained`). + fetches read and wrote the next buffer's memory, while texel buffers were contained. - A file states no deviation from the specifications, and the product reads none: its profile is derived from the file's Vulkan queries alone (`Device::from_queries`). The product refuses a file that holds the former top-level `m2v_deviations` object. diff --git a/crates/metal2vulkan-validation/src/authored_compile/tests.rs b/crates/metal2vulkan-validation/src/authored_compile/tests.rs index c31aca96c..45b1c0e04 100644 --- a/crates/metal2vulkan-validation/src/authored_compile/tests.rs +++ b/crates/metal2vulkan-validation/src/authored_compile/tests.rs @@ -910,7 +910,6 @@ fn a_stopped_case_worker_fails_every_cell_of_its_case() { fn every_outcome_kind_round_trips_through_a_bless() { use crate::case::out_of_bounds::ContainmentForm; use crate::check::admission::ExecutionRefused; - use crate::coverage::RobustBufferForm; use crate::engine::{LimitKind, UnsupportedReason}; use crate::requirement::ToolingRequirement; let product = |outcome: Outcome| { @@ -979,12 +978,6 @@ fn every_outcome_kind_round_trips_through_a_bless() { ToolingRequirement::VertexAttributeLiteral, ]))), executor(NotSupported::Uncontained { - forms: BTreeSet::from([RobustBufferForm::LoadStore, RobustBufferForm::Atomic]), - unchecked: BTreeSet::new(), - variant: None, - }), - executor(NotSupported::Uncontained { - forms: BTreeSet::new(), unchecked: BTreeSet::from([ContainmentForm::LoadedPointer]), variant: None, }), diff --git a/crates/metal2vulkan-validation/src/candidate/engine.rs b/crates/metal2vulkan-validation/src/candidate/engine.rs index 7f4a47a9a..9e7754868 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine.rs @@ -57,7 +57,7 @@ use crate::check::admission::{ use crate::check::interface::AirInterface; use crate::check::CheckedCase; use crate::companion::{Companion, Spelling}; -use crate::coverage::{ExecutedCensus, ExecutionClass}; +use crate::coverage::ExecutedCensus; use crate::engine::{bounded_detail, Outcome, RowSource}; use crate::executor_contract::out_of_bounds::{self, OutOfBoundsRun, TargetRun}; use crate::executor_contract::stage_inputs; @@ -1583,14 +1583,12 @@ pub fn is_engine_slot(environment_id: &str) -> bool { } /// How a compiled module contains each of `targets` (`out_of_bounds::containment`: its slot's -/// form and `profile`'s encodings) on a device that executes as `class`, or `None` for a case -/// without targets: the run's out-of-bounds facts, before what its guards count -/// (`TargetRun::escaped`, `TargetRun::past_end`). A target whose form the device leaves -/// uncontained under that encoding, or whose accesses the module checks nowhere -/// (`out_of_bounds::Check::Unchecked`), refuses the run, so it is decided before anything is +/// form and `profile`'s encodings), or `None` for a case without targets: the run's +/// out-of-bounds facts, before what its guards count (`TargetRun::escaped`, +/// `TargetRun::past_end`). A target whose accesses the module checks nowhere +/// (`out_of_bounds::Check::Unchecked`) refuses the run, so it is decided before anything is /// submitted, before the executor's context executes. pub(crate) fn out_of_bounds_run( - class: Option, profile: &DeviceProfile, module: &out_of_bounds::ModuleFacts<'_>, targets: &[OutOfBoundsTarget], @@ -1613,15 +1611,13 @@ pub(crate) fn out_of_bounds_run( }) }) .collect::, ExecutorError>>()?; - let uncontained = out_of_bounds::uncontained(&targets, class); let unchecked = targets .iter() .filter(|target| target.mechanism.check == out_of_bounds::Check::Unchecked) .map(|target| target.form) .collect::>(); - if !uncontained.is_empty() || !unchecked.is_empty() { + if !unchecked.is_empty() { return Err(NotSupported::Uncontained { - forms: uncontained, unchecked, variant: None, } @@ -1634,13 +1630,11 @@ pub(crate) fn out_of_bounds_run( /// `device`, that runs the Metal vertex function (`graphics::vertex_module`) contains each of /// `case`'s targets, its attributes fetched from `case`'s vertex buffers. pub(crate) fn draw_out_of_bounds_run( - class: Option, device: &metal2vulkan::device::Device, pipeline: &RenderPipeline, case: &graphics::RenderCase, ) -> Result, ExecutorError> { out_of_bounds_run( - class, device.profile(), &out_of_bounds::ModuleFacts { stage: ShaderStage::Vertex, diff --git a/crates/metal2vulkan-validation/src/candidate/platform/compute.rs b/crates/metal2vulkan-validation/src/candidate/platform/compute.rs index 0ce1fa54c..0fb337615 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/compute.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/compute.rs @@ -276,11 +276,10 @@ fn run( return Err(NotSupported::NotEnabled(missing).into()); } // How the compiled module contains each out-of-bounds target on this device, decided before - // anything runs; a form the device leaves uncontained is refused, never run. A kernel fetches - // each stage input as the descriptor it was compiled under says. + // anything runs; a target checked nowhere is refused, never run. A kernel fetches each stage + // input as the descriptor it was compiled under says. let attributes = out_of_bounds::Fetch::of_stage_input(case.stage_input.as_ref()); let out_of_bounds = out_of_bounds_run( - context.execution_class, device.profile(), &out_of_bounds::ModuleFacts { stage: Stage::Kernel, diff --git a/crates/metal2vulkan-validation/src/candidate/platform/render.rs b/crates/metal2vulkan-validation/src/candidate/platform/render.rs index 7d3b6e6c5..b8d1c33ca 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/render.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/render.rs @@ -186,8 +186,8 @@ fn run( .map(|map| graphics::rate_map_regions(map, &context.region_limits(), &pipeline.graphics)) .transpose()?; // How the Metal vertex function's module contains each out-of-bounds target on this device, - // decided before anything runs; a form the device leaves uncontained is refused, never run. - let out_of_bounds = draw_out_of_bounds_run(context.execution_class, device, pipeline, case)?; + // decided before anything runs; a target checked nowhere is refused, never run. + let out_of_bounds = draw_out_of_bounds_run(device, pipeline, case)?; let spv_sha256 = sha256_bytes( &pipeline .stages diff --git a/crates/metal2vulkan-validation/src/candidate/platform/runtime.rs b/crates/metal2vulkan-validation/src/candidate/platform/runtime.rs index f588bd82b..1d7f1eb95 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/runtime.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/runtime.rs @@ -387,8 +387,7 @@ fn run( let descriptor = descriptor(case, kernel)?; // How the modules the state may dispatch contain each out-of-bounds target, decided before // anything is made or submitted. - let out_of_bounds = - runtime_bounds::contained(device, case, &descriptor, Some(execution_class(identity)))?; + let out_of_bounds = runtime_bounds::contained(device, case, &descriptor)?; let (threads_per_group, dispatch) = match case.dispatch { Dispatch::Threads { threads, @@ -589,7 +588,7 @@ pub(super) fn ran( } /// The class of the device `identity` names. -pub(super) fn execution_class(identity: &Identity) -> ExecutionClass { +fn execution_class(identity: &Identity) -> ExecutionClass { match identity.device_type { vk::PhysicalDeviceType::CPU => ExecutionClass::CpuIcd, _ => ExecutionClass::Host(HostClass(metal2vulkan::vk::DriverId::from_raw( diff --git a/crates/metal2vulkan-validation/src/candidate/platform/runtime_bounds.rs b/crates/metal2vulkan-validation/src/candidate/platform/runtime_bounds.rs index 890940d20..7e4abf318 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/runtime_bounds.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/runtime_bounds.rs @@ -24,7 +24,6 @@ use crate::candidate::engine::{ draw_out_of_bounds_run, out_of_bounds_run, product_refusal, ComputeCase, }; use crate::check::admission::{ExecutorError, NotSupported}; -use crate::coverage::ExecutionClass; use crate::executor_contract::out_of_bounds::{self, OutOfBoundsRun}; use metal2vulkan::error::Error as TranslationError; use metal2vulkan::pipeline::{ @@ -33,18 +32,17 @@ use metal2vulkan::pipeline::{ use metal2vulkan::Budget; use metal2vulkan_runtime as rt; -/// The out-of-bounds facts of `case`'s run of `descriptor` on `device`, executing as `class`, as -/// the module documentation says: `None` for a case without targets. +/// The out-of-bounds facts of `case`'s run of `descriptor` on `device`, as the module +/// documentation says: `None` for a case without targets. /// /// Err: the translator's refusal of every variant, as the product's (`product_refusal`), the /// first one's named; its other errors the same way; `NotSupported::Uncontained` where the -/// variants disagree or `class` leaves a form uncontained; a target no variant's module reaches -/// as validation knows fails the run. +/// variants disagree or a target's accesses are checked nowhere; a target no variant's module +/// reaches as validation knows fails the run. pub(super) fn contained( device: &rt::Device, case: &ComputeCase, descriptor: &ComputePipelineDescriptor, - class: Option, ) -> Result, ExecutorError> { if case.out_of_bounds.is_empty() { return Ok(None); @@ -83,7 +81,7 @@ pub(super) fn contained( policy: *translator.policy(), strategies: lowered.strategies(), }; - let run = out_of_bounds_run(class, translator.profile(), &module, &case.out_of_bounds); + let run = out_of_bounds_run(translator.profile(), &module, &case.out_of_bounds); runs.push((variant, run)); } let Some(((_, first), rest)) = runs.split_first() else { @@ -94,7 +92,6 @@ pub(super) fn contained( }; if let Some(&(variant, _)) = rest.iter().find(|(_, run)| run != first) { return Err(NotSupported::Uncontained { - forms: Default::default(), unchecked: Default::default(), variant: Some(variant), } @@ -103,18 +100,16 @@ pub(super) fn contained( first.clone() } -/// The out-of-bounds facts of `case`'s draw of `descriptor` on `device`, executing as `class`, as -/// the module documentation says: `None` for a case without targets. +/// The out-of-bounds facts of `case`'s draw of `descriptor` on `device`, as the module +/// documentation says: `None` for a case without targets. /// /// Err: the translator's refusal of the descriptor, as the product's (`product_refusal`); -/// `NotSupported::Uncontained` where `class` leaves a form uncontained or a target's accesses are -/// checked nowhere; a target the vertex function's module does not reach as validation knows fails -/// the draw. +/// `NotSupported::Uncontained` where a target's accesses are checked nowhere; a target the vertex +/// function's module does not reach as validation knows fails the draw. pub(super) fn drawn( device: &rt::Device, case: &RenderCase, descriptor: &RenderPipelineDescriptor, - class: Option, ) -> Result, ExecutorError> { if case.out_of_bounds.is_empty() { return Ok(None); @@ -123,5 +118,5 @@ pub(super) fn drawn( let pipeline = translator .compile_render_pipeline(descriptor, &Budget::standard()) .map_err(|error| product_refusal(&error))?; - draw_out_of_bounds_run(class, translator, &pipeline, case) + draw_out_of_bounds_run(translator, &pipeline, case) } diff --git a/crates/metal2vulkan-validation/src/candidate/platform/runtime_render.rs b/crates/metal2vulkan-validation/src/candidate/platform/runtime_render.rs index 97e34b92b..f5e34d77b 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/runtime_render.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/runtime_render.rs @@ -91,11 +91,10 @@ fn run( let _grant = runtime::sampler_grant(device)?; let descriptor = descriptor(case, draw)?; // How the state's vertex function contains each out-of-bounds target, decided before anything - // is made: a target the device leaves uncontained or checked nowhere refuses the draw. The - // routed targets are attribute buffers (`engine::runs_render_through_runtime`), which the - // draw places without guards, so a contained one is not drawn either. - let class = Some(runtime::execution_class(identity)); - if runtime_bounds::drawn(device, case, &descriptor, class)?.is_some() { + // is made: a target checked nowhere refuses the draw. The routed targets are attribute + // buffers (`engine::runs_render_through_runtime`), which the draw places without guards, so a + // contained one is not drawn either. + if runtime_bounds::drawn(device, case, &descriptor)?.is_some() { return Err(NotSupported::NotImplemented( "a draw through the runtime whose out-of-bounds targets are contained: it places \ its vertex buffers without guards" diff --git a/crates/metal2vulkan-validation/src/check/admission.rs b/crates/metal2vulkan-validation/src/check/admission.rs index 917a51c8a..14d6bf48b 100644 --- a/crates/metal2vulkan-validation/src/check/admission.rs +++ b/crates/metal2vulkan-validation/src/check/admission.rs @@ -93,14 +93,12 @@ pub enum NotSupported { /// executor. Requirements(BTreeSet), /// An out-of-bounds case whose run would reach memory no binding gave it, so it is not run - /// there: the opened device leaves accesses of `forms` uncontained under the robust buffer - /// encoding the case's module compiled to (`HostClass::robust_buffers_uncontained`), the - /// module checks the accesses of its targets of the `unchecked` forms nowhere - /// (`out_of_bounds::Check::Unchecked`), or, for a run through the runtime, the kernel's - /// `variant` contains one of its targets otherwise than the first variant the translator - /// lowered of it (`platform::runtime_bounds`), so which module a dispatch runs would decide it. + /// there: the case's module checks the accesses of its targets of the `unchecked` forms + /// nowhere (`out_of_bounds::Check::Unchecked`), or, for a run through the runtime, the + /// kernel's `variant` contains one of its targets otherwise than the first variant the + /// translator lowered of it (`platform::runtime_bounds`), so which module a dispatch runs + /// would decide it. Uncontained { - forms: BTreeSet, #[serde(default)] unchecked: BTreeSet, #[serde(default)] @@ -126,20 +124,11 @@ impl NotSupported { "not_supported{{tooling_requirement:{}}}", requirement_names(requirements) ), - Self::Uncontained { - forms, - unchecked, - variant, - } => format!( + Self::Uncontained { unchecked, variant } => format!( "not_supported{{uncontained:{}}}", - forms + unchecked .iter() - .map(|form| form.label().to_owned()) - .chain( - unchecked - .iter() - .map(|form| format!("unchecked {}", form.as_str())) - ) + .map(|form| format!("unchecked {}", form.as_str())) .chain(variant.map(|variant| format!("variant {variant:?}"))) .collect::>() .join(",") @@ -172,23 +161,13 @@ impl fmt::Display for NotSupported { "{}: the executor does not run these families", self.outcome() ), - Self::Uncontained { - unchecked, - variant: None, - .. - } if !unchecked.is_empty() => write!( + Self::Uncontained { variant: None, .. } => write!( formatter, "{}: the compiled module checks the accesses of these forms nowhere, neither in \ the shader nor by the device's robustness, so the case's out-of-bounds accesses \ are not run", self.outcome() ), - Self::Uncontained { variant: None, .. } => write!( - formatter, - "{}: the device leaves these forms uncontained under its robust buffer access, so \ - the case's out-of-bounds accesses are not run there", - self.outcome() - ), Self::Uncontained { variant: Some(variant), .. diff --git a/crates/metal2vulkan-validation/src/coverage.rs b/crates/metal2vulkan-validation/src/coverage.rs index 5d18662d9..4ad6dbcff 100644 --- a/crates/metal2vulkan-validation/src/coverage.rs +++ b/crates/metal2vulkan-validation/src/coverage.rs @@ -17,12 +17,6 @@ //! robustness feature ([`Leg`]): as stated, which selects the robust encodings, and with every //! robustness feature removed ([`robustness_off`]), which selects the in-shader ones, the ones the //! runtime's floor compiles, as it enables no robustness feature. -//! -//! A driver that advertises buffer robustness without containing some of its forms is a recorded -//! limitation (MoltenVK leaves loads, stores, and atomics through buffer descriptors and -//! fixed-function vertex input uncontained): a run of the robust buffer encoding there is -//! evidence for the in-bounds path only, never containment evidence for those forms -//! ([`HostClass::robust_buffers_uncontained`], which out-of-bounds evidence reads). use crate::candidate::engine::artifact::ExecutedArtifact; use crate::case::Stage; @@ -92,9 +86,7 @@ pub enum BufferEncoding { /// (`DeviceProfile::checks_buffers_in_shader`). Checked, /// Left to robust descriptors: `robustBufferAccess` or `robustBufferAccess2` is enabled, and - /// the shader emits no check. Both levels select the same shader. A device may - /// advertise the feature without containing every form - /// ([`HostClass::robust_buffers_uncontained`], MoltenVK). + /// the shader emits no check. Both levels select the same shader. Robust, } @@ -359,8 +351,7 @@ impl ModuleCensus { } } -/// A Vulkan driver (`VkDriverId`): the host class of a GPU (NVIDIA proprietary, RADV, ANV, -/// MoltenVK, ...). +/// A Vulkan driver (`VkDriverId`): the host class of a GPU (NVIDIA proprietary, RADV, ANV, ...). #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct HostClass(pub vk::DriverId); @@ -392,75 +383,6 @@ impl ExecutionClass { .driver_id .map(|driver| ExecutionClass::Host(HostClass(driver))) } - - /// The forms this class leaves uncontained under the robust buffer encoding: its driver's - /// ([`HostClass::robust_buffers_uncontained`]); none for a CPU ICD. - pub fn robust_buffers_uncontained(self) -> &'static [RobustBufferForm] { - match self { - ExecutionClass::Host(host) => host.robust_buffers_uncontained(), - ExecutionClass::CpuIcd => &[], - } - } -} - -/// An out-of-bounds access Vulkan's robust buffer access keeps inside the buffer's memory (the -/// specification's "Shader Out-of-Bounds Memory Access" and "Vertex Input Extraction" under -/// `robustBufferAccess`): what the robust buffer encoding ([`BufferEncoding::Robust`]) leaves to -/// the device. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum RobustBufferForm { - /// A load or store through a storage or uniform buffer descriptor. - LoadStore, - /// An atomic on a storage buffer. - Atomic, - /// A read, write, or atomic on a uniform or storage texel buffer. - TexelBuffer, - /// A fixed-function vertex attribute fetch. - VertexInput, -} - -impl RobustBufferForm { - /// The form's name in the report. - pub fn label(self) -> &'static str { - match self { - RobustBufferForm::LoadStore => "load-store", - RobustBufferForm::Atomic => "atomic", - RobustBufferForm::TexelBuffer => "texel-buffer", - RobustBufferForm::VertexInput => "vertex-input", - } - } -} - -impl HostClass { - /// The forms this driver leaves uncontained although it advertises `robustBufferAccess`, a - /// recorded driver limitation: on it a run of the robust buffer encoding is evidence for the - /// in-bounds path of these forms only, never for their containment. - /// - /// MoltenVK advertises the feature on every device and adds no bounds check for it (its - /// shader converter emits none, and Metal bounds neither a buffer access nor a - /// vertex-descriptor fetch). On an Apple M3 Max (macOS 26.7, MoltenVK 1.4.1) loads, stores, - /// and atomics through storage and uniform buffer descriptors, and fixed-function vertex - /// fetches, past their buffer read or wrote the next buffer's bytes; texel buffer accesses - /// were contained. By user decision the product keeps the robust encoding there (no in-shader - /// check), as native Metal bounds none of these either. SwiftShader's robustness leaves a - /// storage buffer's atomics uncontained too, below the floor. Under `robustBufferAccess` its storage - /// buffer loads and stores and its storage texel buffer atomic add and store were measured - /// contained, and OB1's cases (storage, uniform, and texel buffers, and buffer atomics with the - /// check) matched. Its vertex-input fetches and index-buffer reads were not measured; like - /// every other driver's, they are taken to follow Vulkan's rules until a measurement says - /// otherwise. - pub fn robust_buffers_uncontained(self) -> &'static [RobustBufferForm] { - if self.0 == vk::DriverId::MOLTENVK { - &[ - RobustBufferForm::LoadStore, - RobustBufferForm::Atomic, - RobustBufferForm::VertexInput, - ] - } else { - &[] - } - } } /// The census of what one candidate run executed, and where (the evidence side). diff --git a/crates/metal2vulkan-validation/src/coverage/tests.rs b/crates/metal2vulkan-validation/src/coverage/tests.rs index be9d7461a..8dbab2933 100644 --- a/crates/metal2vulkan-validation/src/coverage/tests.rs +++ b/crates/metal2vulkan-validation/src/coverage/tests.rs @@ -7,7 +7,7 @@ use crate::case::out_of_bounds::{ContainmentForm, OutOfBoundsResource, OutOfBoun use crate::case::AuthoredCase; use std::collections::BTreeMap; -const MOLTENVK: HostClass = HostClass(vk::DriverId::MOLTENVK); +const RADV: HostClass = HostClass(vk::DriverId::MESA_RADV); const FREE: SubgroupShape = SubgroupShape { required_size: None, @@ -43,14 +43,14 @@ fn executed_census_round_trips() { let census = ExecutedCensus { out_of_bounds: None, rate_map_pass: None, - device: Some(ExecutionClass::Host(MOLTENVK)), + device: Some(ExecutionClass::Host(RADV)), product: "p".into(), restricted_to: None, modules: vec![module(Stage::Kernel, pinned(32, true), &["simd.reduce"])], artifact: None, }; let json = serde_json::to_value(&census).unwrap(); - assert_eq!(json["device"], serde_json::json!({"host": 14})); + assert_eq!(json["device"], serde_json::json!({"host": 3})); assert_eq!( json["modules"][0]["containment"], serde_json::json!({"buffers": "robust", "images": "unused"}) @@ -74,7 +74,7 @@ fn a_rate_mapped_pass_records_its_regions() { regions: 2, precision: BTreeSet::new(), }), - device: Some(ExecutionClass::Host(MOLTENVK)), + device: Some(ExecutionClass::Host(RADV)), product: "p".into(), restricted_to: None, modules: vec![module(Stage::Fragment, FREE, &["arith.float"])], 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 82d2ad880..64544084f 100644 --- a/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds.rs +++ b/crates/metal2vulkan-validation/src/executor_contract/out_of_bounds.rs @@ -49,7 +49,6 @@ use crate::case::out_of_bounds::{ContainmentForm, OutOfBoundsResource, OutOfBoundsTarget}; use crate::case::{AuthoredCase, OutputSelection}; -use crate::coverage::{ExecutionClass, RobustBufferForm}; use crate::observation_contract::{ComparisonClass, ObservationLanes}; use base64::Engine as _; use metal2vulkan::device::{DevicePolicy, DeviceProfile, HandleDomain, PointerDomain, Robustness}; @@ -161,41 +160,6 @@ impl Mechanism { }; format!("{medium}:{check}") } - - /// The form of the robust buffer encoding this mechanism leaves to the device - /// ([`RobustBufferForm`]): a descriptor view's loads and stores or atomics, a texel buffer, and - /// fixed-function vertex input, under buffer robustness; `None` for every in-shader check, for - /// the binder's and the padded copy's, for an unchecked access, for images, and for an index - /// fetch, which only `robustBufferAccess2` bounds. - pub fn robust_buffer_form(self, form: ContainmentForm) -> Option { - match (self.medium, self.check) { - ( - _, - Check::Shader - | Check::ShaderReads - | Check::Binder - | Check::Padded - | Check::Unchecked, - ) => None, - (Medium::DescriptorView, _) if form == ContainmentForm::BufferAtomic => { - Some(RobustBufferForm::Atomic) - } - (Medium::DescriptorView, _) => Some(RobustBufferForm::LoadStore), - (Medium::TexelBuffer, _) => Some(RobustBufferForm::TexelBuffer), - (Medium::VertexInput, _) => Some(RobustBufferForm::VertexInput), - ( - Medium::DeviceAddress - | Medium::Arena - | Medium::Image - | Medium::TypedObject - | Medium::HandleTable - | Medium::ResourceId - | Medium::IndexBuffer - | Medium::HandleArray, - _, - ) => None, - } - } } /// One target as a candidate run contained it: what the census records of an out-of-bounds run. @@ -740,24 +704,6 @@ pub fn robust_check(profile: &DeviceProfile) -> Result { } } -/// The forms among `targets` that `class` leaves uncontained -/// ([`ExecutionClass::robust_buffers_uncontained`]): a run there would access memory outside the -/// target, so the candidate refuses it before any submission, a recorded driver limitation. -pub fn uncontained( - targets: &[TargetRun], - class: Option, -) -> BTreeSet { - let Some(class) = class else { - return BTreeSet::new(); - }; - let limited = class.robust_buffers_uncontained(); - targets - .iter() - .filter_map(|target| target.mechanism.robust_buffer_form(target.form)) - .filter(|form| limited.contains(form)) - .collect() -} - /// Whether a candidate observation `candidate` of `case` matches its Metal observation `golden` /// under `class`, with the out-of-bounds facts `run` of the run for a case that declares targets. A /// case without targets compares as every case does. 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 ac8c7103b..e1ef556b3 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 @@ -1,7 +1,5 @@ use super::*; use crate::case::out_of_bounds::OutOfBounds; -use crate::coverage::HostClass; -use metal2vulkan::vk; /// A kernel case reading `src` (binding 0, 16 bytes) out of bounds into `out` (binding 1, 32 /// bytes): bytes 16..32 of the output are the out-of-bounds reads of target 0. @@ -263,43 +261,6 @@ fn the_metal_oracle_records_zeros_in_the_read_bytes() { assert_eq!(threadgroup_reach(&case, 0), 0); } -/// MoltenVK leaves a descriptor view's loads, stores, and atomics uncontained under its robust -/// buffer encoding; an in-shader check, a device address, and a texel buffer are contained there, -/// and no form is uncontained on another driver. -#[test] -fn moltenvk_refuses_exactly_the_forms_its_robust_encoding_leaves_uncontained() { - let moltenvk = Some(ExecutionClass::Host(HostClass(vk::DriverId::MOLTENVK))); - let radv = Some(ExecutionClass::Host(HostClass(vk::DriverId::MESA_RADV))); - let target = |form, medium, check| TargetRun { - resource: OutOfBoundsResource::Buffer { binding: 0 }, - form, - mechanism: Mechanism { medium, check }, - written: true, - escaped: Some(0), - past_end: Some(0), - }; - use ContainmentForm as F; - let robust_load = target(F::StorageBuffer, Medium::DescriptorView, Check::Robust); - let robust_atomic = target(F::BufferAtomic, Medium::DescriptorView, Check::Robust); - assert_eq!( - uncontained(&[robust_load.clone(), robust_atomic], moltenvk), - BTreeSet::from([RobustBufferForm::LoadStore, RobustBufferForm::Atomic]) - ); - assert!(uncontained(&[robust_load], radv).is_empty()); - for contained in [ - target(F::StorageBuffer, Medium::DescriptorView, Check::Shader), - target(F::DeviceAddress, Medium::DeviceAddress, Check::Shader), - target(F::TexelBuffer, Medium::TexelBuffer, Check::Robust), - target(F::Texture, Medium::Image, Check::Robust2), - ] { - assert!( - uncontained(std::slice::from_ref(&contained), moltenvk).is_empty(), - "{contained:?}" - ); - } - assert!(uncontained(&[], None).is_empty()); -} - /// [`case`] whose target is the texture at binding 0 (`texture_type` `ty`, four `r32_uint` /// texels), of `form`, with `reach_after`, and no read bytes: Metal defines its out-of-bounds /// results, so the whole output compares with Metal. @@ -581,14 +542,6 @@ fn an_in_layout_target_has_no_guard_and_its_own_read_rule() { for check in [Check::Shader, Check::Robust, Check::Robust2] { assert_eq!(rule(Medium::TypedObject, check), ReadRule::Zero); assert_eq!(rule(Medium::HandleTable, check), ReadRule::ResidentTexels); - assert_eq!( - Mechanism { - medium: Medium::HandleTable, - check - } - .robust_buffer_form(ContainmentForm::HandleArrayIndex), - None - ); } } @@ -939,12 +892,6 @@ fn the_identity_domains_leave_a_loaded_pointer_unchecked_and_mask_a_resource_id( false ) ); - assert_eq!( - loaded - .mechanism - .robust_buffer_form(ContainmentForm::LoadedPointer), - None - ); let masked = containment(&handles, &module(identity), profile).unwrap(); assert_eq!( (masked.form, masked.mechanism.label()), @@ -968,12 +915,7 @@ fn the_identity_domains_leave_a_loaded_pointer_unchecked_and_mask_a_resource_id( .contains("resolves no handle") ); // The unchecked target refuses the run, naming its form; the masked one runs. - match out_of_bounds_run( - None, - profile, - &module(identity), - &[pointer, handles.clone()], - ) { + match out_of_bounds_run(profile, &module(identity), &[pointer, handles.clone()]) { Err(ExecutorError::NotSupported(refused @ NotSupported::Uncontained { .. })) => { assert_eq!( refused.outcome(), @@ -986,7 +928,7 @@ fn the_identity_domains_leave_a_loaded_pointer_unchecked_and_mask_a_resource_id( } other => panic!("{other:?}"), } - let run = out_of_bounds_run(None, profile, &module(identity), &[handles]) + let run = out_of_bounds_run(profile, &module(identity), &[handles]) .unwrap() .unwrap(); assert_eq!(run.targets[0].mechanism, masked.mechanism); @@ -1087,13 +1029,7 @@ fn a_draws_targets_are_contained_by_their_fetch() { }, "{label}" ); - // It leaves nothing to a driver's robust buffer encoding, and a read past it is zero. - assert_eq!( - index - .mechanism - .robust_buffer_form(ContainmentForm::IndexBuffer), - None - ); + // A read past it is zero. assert_eq!( read_rule(ContainmentForm::IndexBuffer, index.mechanism, false), ReadRule::Zero @@ -1140,21 +1076,4 @@ fn a_draws_targets_are_contained_by_their_fetch() { read_rule(ContainmentForm::HandleArrayIndex, handle_array, false), ReadRule::ResidentTexels ); - // The robust vertex fetch is MoltenVK's uncontained vertex input. - let moltenvk = Some(ExecutionClass::Host(HostClass(vk::DriverId::MOLTENVK))); - let vertex_input = TargetRun { - resource: attribute, - form: ContainmentForm::VertexInput, - mechanism: Mechanism { - medium: Medium::VertexInput, - check: Check::Robust, - }, - written: false, - escaped: Some(0), - past_end: Some(0), - }; - assert_eq!( - uncontained(&[vertex_input], moltenvk), - BTreeSet::from([RobustBufferForm::VertexInput]) - ); } diff --git a/crates/metal2vulkan-validation/src/refusal/tests.rs b/crates/metal2vulkan-validation/src/refusal/tests.rs index ebda313fb..e8e762782 100644 --- a/crates/metal2vulkan-validation/src/refusal/tests.rs +++ b/crates/metal2vulkan-validation/src/refusal/tests.rs @@ -1,7 +1,6 @@ //! A refusal's class from the executor's typed refusal, and a refusal record's own checks. use super::*; -use crate::coverage::RobustBufferForm; use crate::engine::{LimitKind, Outcome, UnsupportedReason}; use crate::requirement::ToolingRequirement; @@ -37,8 +36,7 @@ fn a_refusal_is_classed_by_its_type() { ), ( NotSupported::Uncontained { - forms: [RobustBufferForm::LoadStore].into(), - unchecked: Default::default(), + unchecked: [crate::case::out_of_bounds::ContainmentForm::LoadedPointer].into(), variant: None, }, RefusalClass::Device,