Translator and validation: a bound kernel requires pipeline robustness, and its views are contained by robust buffer access 2

A module that reaches its buffers through storage views of set 0 now requires the
pipeline-robustness feature (VkFeature::PipelineRobustness), which a pipeline needs to state its
own robustness. The out-of-bounds contract reads that requirement (ModuleFacts::robust_views):
such a kernel's views are contained by robustBufferAccess2 (Check::Robust2), their atomics by
the shader's check, both reading zero, as before for the read rule. Built only; the suites and
the authored out-of-bounds cases on a bound card follow.
This commit is contained in:
Anees Iqbal committed 2026-11-26 05:04:54 -08:00
1 parent cf270fa34e
commit dd71dbc775
7 files changed
+116 -4

No files matched your search

@@ -906,6 +906,9 @@ pub(crate) fn draw_out_of_bounds_run(
handle_table: pipeline.interface.needs_handle_translation,
policy: *device.policy(),
strategies: &graphics::vertex_module(pipeline)?.strategies,
// A render stage reaches its buffers at their addresses or through views checked in
// the shader.
robust_views: false,
},
&case.out_of_bounds,
)
@@ -80,6 +80,8 @@ pub(super) fn contained(
handle_table: lowered.resolves_handles(),
policy: *translator.policy(),
strategies: lowered.strategies(),
robust_views: (lowered.requirements().features)
.contains(&metal2vulkan::device::VkFeature::PipelineRobustness),
};
let run = out_of_bounds_run(translator.profile(), &module, &case.out_of_bounds);
runs.push((variant, run));
@@ -266,6 +266,8 @@ pub fn compile_module(
// Every committed profile's device takes the resident-table domains (`committed_profiles`).
policy: DevicePolicy::RESIDENT_TABLES,
strategies: function.strategies(),
robust_views: (function.requirements().features)
.contains(&metal2vulkan::device::VkFeature::PipelineRobustness),
};
let out_of_bounds = inputs
.out_of_bounds
@@ -9,7 +9,9 @@
//! 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; a texel buffer and an image follow the product's texel containment
//! 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
//! checked in the shader; an image's reads are left to `robustImageAccess2` and its writes to
//! `robustImageAccess` at either level, each otherwise checked in the shader. A buffer reached through a pointer loaded from an argument buffer is a
@@ -340,6 +342,11 @@ pub struct ModuleFacts<'a> {
/// (`Device::policy`).
pub policy: DevicePolicy,
pub strategies: &'a StrategyCensus,
/// The module's storage views are contained by its pipeline's robust buffer access 2, not by
/// a check in the shader: a kernel whose buffer arguments are bound as storage buffers of set
/// 0, which requires the pipeline-robustness feature (`VkFeature::PipelineRobustness` in its
/// requirements). Its atomics keep their check in the shader.
pub robust_views: bool,
}
impl ModuleFacts<'_> {
@@ -452,7 +459,10 @@ pub fn containment(
BufferForm::Descriptor => made(
ContainmentForm::StorageBuffer,
Medium::DescriptorView,
Check::Shader,
match module.robust_views {
true => Check::Robust2,
false => Check::Shader,
},
written,
),
_ => unknown(),
@@ -778,6 +778,7 @@ fn thread_memory_is_contained_by_the_typed_arrays_check_only() {
handle_table: true,
policy: DevicePolicy::RESIDENT_TABLES,
strategies: &strategies,
robust_views: false,
};
let target = OutOfBoundsTarget {
resource,
@@ -894,6 +895,7 @@ fn the_identity_domains_leave_a_loaded_pointer_unchecked_and_mask_a_resource_id(
handle_table: false,
policy,
strategies: &strategies,
robust_views: false,
};
let target = |resource, form| OutOfBoundsTarget {
resource,
@@ -990,6 +992,7 @@ fn a_draws_targets_are_contained_by_their_fetch() {
handle_table: false,
policy: DevicePolicy::RESIDENT_TABLES,
strategies,
robust_views: false,
};
let target = OutOfBoundsTarget {
resource,
@@ -1098,3 +1101,76 @@ fn a_draws_targets_are_contained_by_their_fetch() {
ReadRule::ResidentTexels
);
}
/// A kernel's storage view is contained by its pipeline's robust buffer access 2 where the module
/// binds its buffers as storage buffers of set 0 (`ModuleFacts::robust_views`), and by a check in
/// the shader where it does not; an atomic on the view keeps its check in the shader either way.
/// The read rule is zero in each.
#[test]
fn a_bound_kernel_s_storage_view_is_contained_by_robust_buffer_access_2() {
use metal2vulkan::pipeline::StrategyCensus;
let profiles = crate::coverage::tier_table::committed_profiles().unwrap();
let profile = &profiles
.iter()
.find(|entry| entry.tier.stem == "intel-irisxe-anv")
.unwrap()
.profile;
let slots = BTreeMap::from([(
SlotRef {
stage: SymStage::Kernel,
class: SlotClass::Buffer,
index: 1,
},
// A written buffer slot reached through its storage view (the interface has no
// constructor outside the product).
serde_json::from_value::<SlotInterface>(serde_json::json!({"Buffer": {
"access": {"read": true, "write": true},
"window": "Whole",
"form": "Descriptor",
"kind": "Buffer",
}}))
.unwrap(),
)]);
let strategies = StrategyCensus::default();
let attributes = BTreeMap::new();
let mut identity = DevicePolicy::default();
identity.pointer_domain = PointerDomain::Identity;
identity.handle_domain = HandleDomain::Identity;
let contained = |robust_views, form| {
let module = ModuleFacts {
stage: SymStage::Kernel,
slots: &slots,
attributes: &attributes,
resident_roots: false,
handle_table: false,
policy: identity,
strategies: &strategies,
robust_views,
};
let target = OutOfBoundsTarget {
resource: OutOfBoundsResource::Buffer { binding: 1 },
form,
reach_before: 0,
reach_after: 256,
};
containment(&target, &module, profile).unwrap()
};
for (robust_views, form, check) in [
(true, ContainmentForm::StorageBuffer, Check::Robust2),
(false, ContainmentForm::StorageBuffer, Check::Shader),
(true, ContainmentForm::BufferAtomic, Check::Shader),
(false, ContainmentForm::BufferAtomic, Check::Shader),
] {
let what = format!("{form:?} with robust views {robust_views}");
let c = contained(robust_views, form);
assert_eq!(c.form, form, "{what}");
assert_eq!(c.mechanism.medium, Medium::DescriptorView, "{what}");
assert_eq!(c.mechanism.check, check, "{what}");
assert!(c.written, "{what}");
assert_eq!(
read_rule(c.form, c.mechanism, true),
ReadRule::Zero,
"{what}"
);
}
}
@@ -3203,6 +3203,14 @@ fn lower_bounded<K>(
.properties
.insert(crate::device::requirements::VkProperty::DeviceSampling);
}
// A kernel that reaches its buffers through storage views of set 0 is contained by its
// pipeline's robust buffer access 2 (`RuntimeFact::RobustStorageBuffers`), which a pipeline
// states only where the device enables the pipeline-robustness feature.
if plan.families.access.robust_views {
requirements
.features
.insert(crate::device::requirements::VkFeature::PipelineRobustness);
}
// The set-1 heap's binding flags need their features beside the module's.
requirements
.features
@@ -9,8 +9,8 @@
//! no slot pushes its address or its bounds (`PushField::SlotGuestBase`,
//! `PushField::SlotBounds`), and no load reads the zero range (`PushField::ZeroAddress`). The
//! module states `RuntimeFact::RobustStorageBuffers` and each slot's alignment
//! (`RuntimeFact::AddressAlignment`: 4 for a `uint` buffer, 16 for a `float4` one), and passes
//! L3.
//! (`RuntimeFact::AddressAlignment`: 4 for a `uint` buffer, 16 for a `float4` one), requires the
//! pipeline-robustness feature (`VkFeature::PipelineRobustness`), and passes L3.
//! - A slot the dispatch binds at a multiple of 4 below its argument's alignment
//! (`LoweringInputs::word_bound_buffers`) keeps its device address, held to 4: a view's `uvec4`
//! units take the bind offset to be a multiple of the argument's alignment.
@@ -21,6 +21,7 @@
use std::collections::BTreeSet;
use super::engine_word_phases::{bound_identity_profiles, device_alignments};
use crate::device::requirements::VkFeature;
use crate::lower::select::LowerInputs;
use crate::pipeline::facts::RuntimeFact;
use crate::pipeline::sym::{PushField, ResourceKind, SlotClass, SlotRef, Stage};
@@ -113,6 +114,11 @@ fn a_kernel_reaches_its_buffers_through_set_0_views_at_their_bind_offsets() {
"{what}: {:?}",
a.facts
);
assert!(
(a.requirements.features).contains(&VkFeature::PipelineRobustness),
"{what}: {:?}",
a.requirements.features
);
let stated: Vec<u32> = (a.facts.iter())
.filter_map(|f| match f {
RuntimeFact::AddressAlignment { align, .. } => Some(*align),
@@ -147,5 +153,10 @@ fn a_word_bound_slot_keeps_its_device_address() {
"{what}: {:?}",
a.facts
);
assert!(
!(a.requirements.features).contains(&VkFeature::PipelineRobustness),
"{what}: {:?}",
a.requirements.features
);
}
}