SEMANTICS 2091: on ANV, a stage past the serialized-object bound keeps the widest pin or is refused

Mesa's common pipeline runtime (vk_pipeline.c) serializes every compute stage into a precompiled
shader and reads it back before compiling it. nir_serialize names each object by a 20-bit index
(MAX_OBJECT_IDS 1<<20) checked only by an assert, so a release build wraps past 2^20 objects and
the driver faults inside vkCreateComputePipelines. On Intel Iris this took a consumer's host
process down on a large compute kernel (its translated stage: idx_table_len 1,096,128).

DriverWorkaround::SerializedStageWrapsLargeModules (keyed on ANV) bounds the stage's weight at
SERIALIZED_STAGE_WEIGHT = 786,432 instructions, every call counted as its callee's body. A module
over the bound is never handed to the driver: a kernel that emulated its simdgroups only in place
of the widest mode's pin compiles pinned to 32 lanes again (lower::simd::WidestPin::Kept), and any
other is refused as Unsupported::driver_defect(Feature::StageSize, ..), where Metal compiles it.
The gap is recorded in docs/FAST-PATHS.md's known gaps; REFUSALS regenerated, reach.tsv marks
StageSize rare, api_signatures carries the two new variants.

The bound's basis: 22 stages measured at 0.14-0.99 serialized objects per weight unit; 786,432 is
3/4 of 2^20 at the worst measured ratio of about 1.

Verified: the crash reproduced live on ms01's Iris (job 25723) with both the consumer kernel and a
synthetic 360k-FMA chain; test
a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused; checks job 25736 (msi): clippy
on the workspace, rustdoc, the full metal2vulkan suite, green. Not yet verified: the consumer's
Iris run at the next pin.

SEMANTICS_VERSION 2090 -> 2091: translator output and refusals change on ANV.
This commit is contained in:
Anees Iqbal committed 2026-11-13 09:05:44 -08:00
1 parent aea1543936
commit c53ea4164e
16 files changed
+288 -45

No files matched your search

+1 -1
View File
@@ -61,7 +61,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 = 2090;
pub const SEMANTICS_VERSION: u32 = 2091;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
+4 -2
View File
@@ -411,11 +411,13 @@ fn by_identity(desc: &DeviceDescription) -> Vec<DriverWorkaround> {
// An `f32` operation fused into the conversion of its result to `half`, on every GPU it
// drives.
Some(vk::DriverId::MESA_RADV) => vec![DriverWorkaround::HalfConversionFusedWithArithmetic],
// A register allocator that faults compiling a module past a word bound, and products of
// one value by zeros of opposite sign kept as one, on every GPU it drives.
// A register allocator that faults compiling a module past a word bound, products of one
// value by zeros of opposite sign kept as one, and a stage past 2^20 objects of its
// serialized form corrupted, on every GPU it drives.
Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA) => vec![
DriverWorkaround::RegisterAllocatorOverflowsLargeModules,
DriverWorkaround::OppositeZeroProductsMerged,
DriverWorkaround::SerializedStageWrapsLargeModules,
],
_ => Vec::new(),
}
+16
View File
@@ -1500,6 +1500,22 @@ pub enum DriverWorkaround {
/// `f32` constant with a `-0.0` component multiplies by `+0.0` in that component and negates
/// it (`ProductForm::PositiveZeroFactors`), the same value on every device.
OppositeZeroProductsMerged,
/// The driver's pipeline creation corrupts a stage of more than 2^20 objects of its own
/// intermediate form. Mesa's common pipeline runtime (`vk_pipeline.c`), which ANV's pipelines
/// go through, writes each stage after the driver's preprocessing into a precompiled shader
/// with `nir_serialize` and reads it back with `nir_deserialize` before compiling it, on every
/// pipeline it makes, cached or not. The serialized form names a value by a 20-bit index, and
/// the bound (`MAX_OBJECT_IDS`, `1 << 20`) is held only by an assertion, which a release build
/// leaves out: past it the indices wrap, and the reader takes other objects for them. Measured
/// with ANV (`VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA`), Mesa 26.2.6, on the Iris Xe of RPL-P: a
/// kernel whose serialized stage held 1,096,128 objects faulted in `vkCreateComputePipelines`
/// (`SEGV_MAPERR` at address `0x40`, in the reader, at its 1,048,578th object), and so did a
/// synthetic compute module of 360,000 chained multiply-adds (about three objects each). Keyed
/// on the driver whatever its GPU and release, in `device::derive`. A module whose entry weighs more than
/// the bound the compile keeps under (`pipeline::compile`'s stage bound) is planned again in
/// the `Direct` simdgroup tier where it took the `Emulated` one only in place of the widest
/// mode's pin, and refused otherwise (`Needs::DriverDefect`), never handed to the driver.
SerializedStageWrapsLargeModules,
}
#[cfg(test)]
+22 -17
View File
@@ -1102,31 +1102,36 @@ fn radv_carries_the_fused_half_conversion() {
assert!(!profile_of(&desc).workarounds().contains(&defect));
}
/// `DriverWorkaround::RegisterAllocatorOverflowsLargeModules` is keyed on ANV, whatever its GPU
/// and release; every committed ANV profile carries it, and no other profile does. The UHD 770's
/// description under RADV or NVIDIA's driver loses it.
/// `DriverWorkaround::RegisterAllocatorOverflowsLargeModules` and
/// `DriverWorkaround::SerializedStageWrapsLargeModules` are keyed on ANV, whatever its GPU and
/// release; every committed ANV profile carries them, and no other profile does. The Iris Xe's
/// description under RADV or NVIDIA's driver loses them.
#[test]
fn register_allocator_overflow_is_keyed_on_anv() {
fn large_module_defects_are_keyed_on_anv() {
use crate::device::profile::DriverWorkaround;
let fact = DriverWorkaround::RegisterAllocatorOverflowsLargeModules;
let profile_of = |desc: &DeviceDescription| {
Device::new(desc.clone(), DevicePolicy::default())
.unwrap()
.profile()
.clone()
};
for (stem, text) in committed_profiles() {
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
let anv = desc.driver_id == Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA);
let p = profile_of(&desc);
assert_eq!(p.workarounds().contains(&fact), anv, "{stem}");
}
let mut desc = profile("intel-irisxe-rplp-anv");
assert!(profile_of(&desc).workarounds().contains(&fact));
for other in [vk::DriverId::MESA_RADV, vk::DriverId::NVIDIA_PROPRIETARY] {
desc.driver_id = Some(other);
let p = profile_of(&desc);
assert!(!p.workarounds().contains(&fact), "{other:?}");
for fact in [
DriverWorkaround::RegisterAllocatorOverflowsLargeModules,
DriverWorkaround::SerializedStageWrapsLargeModules,
] {
for (stem, text) in committed_profiles() {
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
let anv = desc.driver_id == Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA);
let p = profile_of(&desc);
assert_eq!(p.workarounds().contains(&fact), anv, "{fact:?} on {stem}");
}
let mut desc = profile("intel-irisxe-rplp-anv");
assert!(profile_of(&desc).workarounds().contains(&fact));
for other in [vk::DriverId::MESA_RADV, vk::DriverId::NVIDIA_PROPRIETARY] {
desc.driver_id = Some(other);
let p = profile_of(&desc);
assert!(!p.workarounds().contains(&fact), "{fact:?} under {other:?}");
}
}
}
+3
View File
@@ -1261,6 +1261,9 @@ pub enum Feature {
ImageAtomics,
/// Too many descriptors of one kind in a stage or pipeline.
DescriptorCount,
/// A stage module larger than the device's driver compiles intact (`Needs::DriverDefect`
/// names the defect).
StageSize,
/// A buffer window beyond the descriptor range limits.
BufferRange,
+9 -4
View File
@@ -1181,12 +1181,13 @@ fn function_storage(
Ok((required > storage.bytes()).then_some(PrecisionNote::FunctionStorageAssumed))
}
/// Select the plan of `e`.
/// Select the plan of `e` under `inputs`, a kernel weighed for the `Emulated` tier in place of its
/// widest mode's pin or keeping it as `widest_pin` says.
pub fn select(
e: &Entry,
mp: &MemoryPlan,
p: &DeviceProfile,
inputs: &LowerInputs,
(inputs, widest_pin): (&LowerInputs, simd::WidestPin),
m: &mut Meter,
) -> Result<Plan, Error> {
let func = e
@@ -1667,11 +1668,15 @@ fn finish(
// tier the profile's subgroups give them, and depends on that variant. A kernel whose lockstep
// order is only exact on emulated simdgroups emulates them on every dispatch, which no variant
// selects, and so does a large kernel whose `Direct` tier pins the device's widest mode
// (`simd::widest_pin`), unless the emulated tier refuses it below.
// (`simd::widest_pin`), unless the emulated tier refuses it below or the kernel keeps the pin
// (`widest_pin`, a plan made again past its driver's stage bound).
let model = &p.fields().subgroup;
let variant = cx.inputs.emulated_simdgroups && stage == Stage::Kernel;
let lockstep = cx.entry.lockstep.emulated && stage == Stage::Kernel;
let widest = !variant && !lockstep && simd::widest_pin(&cx, m)?;
let widest = !variant
&& !lockstep
&& widest_pin == simd::WidestPin::Weighed
&& simd::widest_pin(&cx, m)?;
let mut tier = if variant || lockstep || widest {
if variant {
cx.facts.insert(RuntimeFact::EmulatedSimdgroups);
+12
View File
@@ -339,6 +339,18 @@ pub struct SimdPlan {
/// The census name of the places the device's simdgroup lockstep orders, with no words.
pub const DEVICE_LOCKSTEP: &str = "barrier.lockstep.device";
/// Whether [`widest_pin`] weighs a kernel for the `Emulated` tier, or the kernel keeps the
/// `Direct` tier's pin to the device's widest mode whatever its pressure: a kernel whose emulated
/// module passed the bound its driver compiles intact is planned again keeping it
/// (`pipeline::compile`'s stage bound, `DriverWorkaround::SerializedStageWrapsLargeModules`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WidestPin {
/// [`widest_pin`] weighs the kernel.
Weighed,
/// The kernel keeps the `Direct` tier's pin.
Kept,
}
/// The census name of a kernel that took the `Emulated` tier in place of the `Direct` tier's pin
/// to the device's widest mode ([`widest_pin`]): one use, no words.
pub const WIDEST_PIN: &str = "simd.emulated.widest-pin";
+52 -16
View File
@@ -19,6 +19,7 @@ mod entry;
pub mod key;
mod numbered;
mod partition;
mod stage_bound;
#[cfg(test)]
mod tests;
@@ -1645,6 +1646,25 @@ pub(crate) fn compile_bitcode_kept(
})
}
/// [`compile_bitcode_kept`] under the stage bound `weight_cap` in place of
/// [`stage_bound::SERIALIZED_STAGE_WEIGHT`], so a test reaches the bound with a small module.
#[cfg(test)]
pub(crate) fn compile_bitcode_bounded(
bitcode: &[u8],
entry: EntryRef<'_>,
p: &DeviceProfile,
m: &mut Meter,
weight_cap: u64,
) -> Result<(CompiledFunction, Plan, TypedModule), Error> {
guarded(|| {
let consts = FunctionConstantValues::defaults();
let inputs = LowerInputs::new();
let r = Request::bitcode(bitcode, entry, &consts, &[], &inputs);
compile_bounded(&r, p, m, (SPIRV_WORDS, weight_cap), TypedModule::clone)
.map(|(artifact, plan, module)| (CompiledFunction::new(artifact), plan, module))
})
}
/// The stage `fd` compiled for `p` as [`compile_stage`] compiles it (its linked functions and
/// dynamic libraries included), returning the finished typed module its words were serialized
/// from, for the CPU interpreter.
@@ -1680,7 +1700,8 @@ pub(crate) fn plan_bitcode(
) -> Result<Plan, Error> {
guarded(|| {
let r = Request::bitcode(bitcode, entry, consts, &[], inputs);
plan_one(&r, p, m).map(|planned| planned.plan)
let widest = crate::lower::simd::WidestPin::Weighed;
plan_one(&r, p, widest, m).map(|planned| planned.plan)
})
}
@@ -2680,7 +2701,12 @@ pub(crate) fn specialized_bitcode_entry(
}
/// [`ordered_entry`], then analyze and select.
fn plan_one(r: &Request<'_>, p: &DeviceProfile, m: &mut Meter) -> Result<Planned, Error> {
fn plan_one(
r: &Request<'_>,
p: &DeviceProfile,
widest: crate::lower::simd::WidestPin,
m: &mut Meter,
) -> Result<Planned, Error> {
let Specialized {
air_hash,
entry,
@@ -2726,7 +2752,7 @@ fn plan_one(r: &Request<'_>, p: &DeviceProfile, m: &mut Meter) -> Result<Planned
(&linked, &r.dynamic.key()),
);
let memory = crate::memory::plan::analyze_memory(&spec, p, m)?;
let plan = crate::lower::select::select(&spec, &memory, p, &inputs, m)?;
let plan = crate::lower::select::select(&spec, &memory, p, (&inputs, widest), m)?;
let kernel = KernelFacts {
max_total_threads: spec.ep.stage.max_total_threads(),
work_group_size: spec.ep.stage.work_group_size(),
@@ -2774,19 +2800,29 @@ fn compile_kept<K>(
word_cap: u64,
keep: impl FnOnce(&TypedModule) -> K,
) -> Result<(Arc<FunctionArtifact>, Plan, K), Error> {
let Planned {
key,
spec,
before,
plan,
kernel,
} = plan_one(r, p, m)?;
plan.estimate.check(word_cap)?;
let crate::lower::emit::Emitted { mut module, merged } =
crate::lower::emit::emit_module(&spec, &plan, m)?;
// Every driver compiles each repeated region of the entry again; above the measured size,
// repeated regions are written once, as a loop.
crate::spirv::roll::roll_entry(&mut module, m)?;
let caps = (word_cap, stage_bound::SERIALIZED_STAGE_WEIGHT);
compile_bounded(r, p, m, caps, keep)
}
/// [`compile_kept`] under the stage bound `weight_cap` where the profile needs one
/// (`stage_bound`; [`stage_bound::SERIALIZED_STAGE_WEIGHT`] in production).
fn compile_bounded<K>(
r: &Request<'_>,
p: &DeviceProfile,
m: &mut Meter,
(word_cap, weight_cap): (u64, u64),
keep: impl FnOnce(&TypedModule) -> K,
) -> Result<(Arc<FunctionArtifact>, Plan, K), Error> {
let (
Planned {
key,
spec,
before,
plan,
kernel,
},
crate::lower::emit::Emitted { mut module, merged },
) = stage_bound::emit(r, p, (word_cap, weight_cap), m)?;
// On a driver whose compiler loses a simdgroup's storage writes after an `optnone` call only
// its helper invocations make, those invocations take another arm where that is exact, and
// each such call left is fenced once every analysis below has read the module.
@@ -168,7 +168,9 @@ impl DeviceProfile {
}
/// Everything [`DeviceProfile::compile_entry`] does before emission (decode, specialize,
/// analyze, select), and what it cost against `budget`.
/// analyze, select), and what it cost against `budget`: its first plan, which a kernel whose
/// emitted module passes the bound its driver compiles intact replaces
/// (`DriverWorkaround::SerializedStageWrapsLargeModules`).
pub fn plan_entry(
&self,
d: &EntryDescriptor<'_>,
@@ -177,7 +179,9 @@ impl DeviceProfile {
) -> (Result<EntryPlan, Error>, CompileReport) {
let mut m = Meter::new(budget);
let planned = guarded(|| {
plan_one(&d.request(InputsFrom::Given(inputs)), self, &mut m).map(|planned| EntryPlan {
let r = d.request(InputsFrom::Given(inputs));
let widest = crate::lower::simd::WidestPin::Weighed;
plan_one(&r, self, widest, &mut m).map(|planned| EntryPlan {
stage: planned.plan.stage,
strategies: census(&planned.plan).entries,
estimated_words: planned.plan.estimate.words,
@@ -0,0 +1,77 @@
//! The stage bound: a module kept under the size its driver's compiler takes intact
//! (`DriverWorkaround::SerializedStageWrapsLargeModules`).
//!
//! Mesa's common pipeline runtime (`vk_pipeline.c`), which ANV's pipelines go through, writes each
//! stage after the driver's preprocessing into a precompiled shader (`nir_serialize`) and reads it
//! back (`nir_deserialize`) before compiling it, on every pipeline it makes, cached or not. The
//! serialized form names a value by a 20-bit index, and the bound (`MAX_OBJECT_IDS`, 2^20 objects:
//! values, blocks, variables) is held only by an assertion a release build leaves out: past it the
//! indices wrap, the reader takes other objects for them, and the driver faults inside
//! `vkCreateComputePipelines` (Mesa 26.2.6, ANV on the Iris Xe).
//!
//! On a profile with the defect, a module whose entry weighs more than [`SERIALIZED_STAGE_WEIGHT`]
//! (`spirv::roll::entry_weight`: the entry's instructions with each call counted as its callee's
//! body, as the driver inlines every call) after the repeated regions are rolled is past the bound:
//!
//! - a kernel that took the `Emulated` simdgroup tier only in place of the `Direct` tier's pin to
//! the device's widest mode (`lower::simd::widest_pin`) is planned again keeping the pin
//! (`lower::simd::WidestPin::Kept`), its emulated module dropped and what its emission charged
//! released;
//! - every other module past it, a kernel planned again that still is among them, is refused
//! (`Unsupported`, `Feature::StageSize`, `Needs::DriverDefect`): Metal compiles it, so the
//! refusal is the device's gap, recorded in `docs/FAST-PATHS.md`'s known gaps.
//!
//! **The bound.** The driver's object count is not the module's: it counts the stage after its
//! own inlining and optimization. Measured on ANV, Mesa 26.2.6, on the Iris Xe of RPL-P (the count
//! each serialized stage holds, read where the driver reads it back), over 22 compute stages of
//! entry weights 1,667 to 1,565,083: 0.14 to 0.99 objects per instruction of the entry's weight,
//! 0.70 for the heaviest, whose 1,096,128 objects faulted the driver. [`SERIALIZED_STAGE_WEIGHT`]
//! is three quarters of 2^20: a stage at the bound stays under the driver's 2^20 objects at up to
//! 4/3 objects per instruction, a third above the largest ratio measured.
use super::{plan_one, Planned, Request};
use crate::budget::Meter;
use crate::device::profile::DriverWorkaround;
use crate::device::DeviceProfile;
use crate::error::{Error, Feature, Unsupported};
use crate::lower::emit::Emitted;
use crate::lower::simd::WidestPin;
/// The heaviest entry ([`crate::spirv::roll::entry_weight`]) a profile with
/// `DriverWorkaround::SerializedStageWrapsLargeModules` is handed (the module docs' bound).
pub(crate) const SERIALIZED_STAGE_WEIGHT: u64 = 3 << 18;
/// `r`'s function planned and emitted with its repeated regions rolled, under the plan's word
/// estimate `word_cap` and, on a profile with the defect, under the stage bound `weight_cap` (the
/// module docs): planned again keeping the widest mode's pin where only that pin's emulation passed
/// it, else refused.
pub(super) fn emit(
r: &Request<'_>,
p: &DeviceProfile,
(word_cap, weight_cap): (u64, u64),
m: &mut Meter,
) -> Result<(Planned, Emitted), Error> {
let defect = DriverWorkaround::SerializedStageWrapsLargeModules;
let bounded = p.workarounds().contains(&defect);
let mut widest = WidestPin::Weighed;
loop {
let planned = plan_one(r, p, widest, m)?;
planned.plan.estimate.check(word_cap)?;
let before = m.ledger();
let mut emitted = crate::lower::emit::emit_module(&planned.spec, &planned.plan, m)?;
// Every driver compiles each repeated region of the entry again; above the measured size,
// repeated regions are written once, as a loop.
crate::spirv::roll::roll_entry(&mut emitted.module, m)?;
if !bounded || crate::spirv::roll::entry_weight(&emitted.module, m)? <= weight_cap {
return Ok((planned, emitted));
}
if widest == WidestPin::Kept || !planned.plan.families.simd.widest_pin {
return Err(Unsupported::driver_defect(Feature::StageSize, defect).into());
}
// The emulated module goes, and with it what its emission holds of the ledger.
drop(emitted);
let held = m.ledger().saturating_sub(before);
m.release(usize::try_from(held).unwrap_or(usize::MAX));
widest = WidestPin::Kept;
}
}
+2 -1
View File
@@ -406,7 +406,8 @@ fn typed_module_of(
m,
)?;
let memory = crate::memory::static_root::analyze_memory(&spec, p, m)?;
let plan = crate::lower::select::select(&spec, &memory, p, inputs, m)?;
let widest = crate::lower::simd::WidestPin::Weighed;
let plan = crate::lower::select::select(&spec, &memory, p, (inputs, widest), m)?;
let crate::lower::emit::Emitted { mut module, .. } =
crate::lower::emit::emit_module(&spec, &plan, m)?;
crate::spirv::roll::roll_entry(&mut module, m)?;
@@ -2319,6 +2319,73 @@ fn a_pressured_kernel_takes_the_emulated_tier_in_place_of_the_widest_mode() {
);
}
/// On a driver that corrupts a stage past the size it compiles intact
/// (`DriverWorkaround::SerializedStageWrapsLargeModules`, ANV: the Iris Xe of RPL-P), a module
/// whose entry weighs more than the stage bound (`pipeline::compile`'s `stage_bound`, here a bound
/// the test sets) is never emitted: the pressured kernel of
/// `a_pressured_kernel_takes_the_emulated_tier_in_place_of_the_widest_mode`, whose emulated
/// module passes the bound, is planned again keeping the `Direct` tier's pin to 32 lanes, its
/// answers Metal's; under a bound its `Direct` module passes too, it is refused
/// (`Feature::StageSize`, the defect named). The same description under another driver, which
/// has no such defect, emits the emulated module under either bound.
#[test]
fn a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused() {
use crate::device::profile::DriverWorkaround;
use crate::device::Device;
use crate::error::{Feature, Needs, Unsupported};
use crate::lower::simd::{WIDEST_PIN, WIDEST_PIN_FLOOR, WIDEST_PIN_WORDS};
use crate::pipeline::compile::compile_bitcode_bounded;
use crate::pipeline::testing::meter;
use crate::spirv::roll::entry_weight;
let half = |t: u32| if t & 31 < 16 { t ^ 1 } else { t };
let fan = Padding::Fan((WIDEST_PIN_FLOOR / 2 + 16).max(WIDEST_PIN_WORDS as usize + 8));
let Some(bc) = assemble("device_half", &device_half_padded(fan, None)) else {
return;
};
let entry = EntryRef::Name("device_half");
let weight = |module: &TypedModule| entry_weight(module, &mut meter()).expect("weight");
let defect = DriverWorkaround::SerializedStageWrapsLargeModules;
let iris_desc = crate::pipeline::testing::description("intel-irisxe-rplp-anv").unwrap();
let iris = Device::new(iris_desc.clone(), DevicePolicy::default()).unwrap();
let iris = iris.profile();
assert!(iris.workarounds().contains(&defect));
let mut other_desc = iris_desc;
other_desc.driver_id = Some(crate::vk::DriverId::MESA_RADV);
let other = Device::new(other_desc, DevicePolicy::default()).unwrap();
let other = other.profile();
assert!(!other.workarounds().contains(&defect));
// Unbounded, the kernel emulates its simdgroups in place of the widest mode on both.
let compile = |p, cap| compile_bitcode_bounded(&bc, entry, p, &mut meter(), cap);
let (_, plan, emulated) = compile(iris, u64::MAX).expect("emulated on the Iris Xe");
assert_eq!((plan.simd.1, uses(&plan, WIDEST_PIN)), (Tier::Emulated, 1));
let emulated = weight(&emulated);
// Under a bound the emulated module passes: planned again keeping the pin, exact at 32 lanes.
let (_, plan, module) = compile(iris, emulated - 1).expect("planned again");
assert_eq!(plan.simd.1, Tier::Direct);
assert_eq!(uses(&plan, WIDEST_PIN), 0);
assert_eq!(plan.subgroup.size, Some(32));
let pinned = weight(&module);
assert!(pinned < emulated, "pinned {pinned}, emulated {emulated}");
let want: Vec<u32> = (0..64).map(half).collect();
assert_eq!(run_words(&plan, &module, 64, SubgroupSize::W32), want);
// Under a bound the pinned module passes too: refused, the defect named.
let refused = compile(iris, pinned - 1).expect_err("past the bound");
let Error::Unsupported(Unsupported { feature, needs, .. }) = refused else {
panic!("{refused:?}");
};
assert_eq!(feature, Feature::StageSize);
assert_eq!(needs, Needs::DriverDefect(defect));
// Without the defect, the emulated module is emitted under either bound.
for cap in [emulated - 1, pinned - 1] {
let (_, plan, module) = compile(other, cap).expect("emitted without the defect");
assert_eq!((plan.simd.1, uses(&plan, WIDEST_PIN)), (Tier::Emulated, 1));
assert!(weight(&module) > cap, "{cap}");
for lanes in CHUNKED {
assert_eq!(run_words(&plan, &module, 64, lanes), want, "{lanes:?}");
}
}
}
/// Texture calls take no device barrier: their pointer is the texture's handle.
#[test]
fn texture_calls_take_no_device_barrier() {
@@ -13500,6 +13500,7 @@ variant metal2vulkan::device::DriverWorkaround::NarrowMaskAfterSignedClamp Narro
variant metal2vulkan::device::DriverWorkaround::OppositeZeroProductsMerged OppositeZeroProductsMerged
variant metal2vulkan::device::DriverWorkaround::PerspectiveReadsExtrapolated PerspectiveReadsExtrapolated
variant metal2vulkan::device::DriverWorkaround::RegisterAllocatorOverflowsLargeModules RegisterAllocatorOverflowsLargeModules
variant metal2vulkan::device::DriverWorkaround::SerializedStageWrapsLargeModules SerializedStageWrapsLargeModules
variant metal2vulkan::device::DriverWorkaround::TessellatorNotMetals TessellatorNotMetals
variant metal2vulkan::device::DriverWorkaround::VertexGroupingNotApples VertexGroupingNotApples
variant metal2vulkan::device::Exposure::Core Core(ApiVersion)
@@ -14294,6 +14295,7 @@ variant metal2vulkan::error::Feature::SimdgroupMatrix SimdgroupMatrix
variant metal2vulkan::error::Feature::SparseTexture SparseTexture { slot: SlotRef }
variant metal2vulkan::error::Feature::SparseTextures SparseTextures { missing: SparseNeed }
variant metal2vulkan::error::Feature::Stage Stage(u8)
variant metal2vulkan::error::Feature::StageSize StageSize
variant metal2vulkan::error::Feature::StageStoresAndAtomics StageStoresAndAtomics
variant metal2vulkan::error::Feature::StaticInitializer StaticInitializer
variant metal2vulkan::error::Feature::StencilExport StencilExport
Can't render this file because it is too large.
+10
View File
@@ -606,6 +606,16 @@ driver's. Each is open work.
ANV then writes through a null state inside `vkCmdDraw*` instead of failing the command
buffer. What spare pools keep of such recordings is freed as they go
back (`RECORDED`); what command buffers alive at once record is not bounded.
- **On ANV, a stage module heavier than the driver compiles intact is refused, or keeps the
widest mode's pin** (`pipeline/compile/stage_bound.rs`,
`DriverWorkaround::SerializedStageWrapsLargeModules`). Mesa's common pipeline runtime writes
each stage into a precompiled shader and reads it back before compiling it, naming each of its
objects by a 20-bit index that wraps without a word past 2^20 objects in a release build (Mesa
26.2.6: the driver faults inside `vkCreateComputePipelines`). A module whose entry weighs more
than `SERIALIZED_STAGE_WEIGHT` (786,432 instructions, every call counted as its callee's body)
is never handed to the driver: a kernel that emulated its simdgroups only in place of the
widest mode's pin is compiled pinned to 32 lanes again, and every other one is refused
(`Feature::StageSize`), where Metal compiles it.
- **A rate-mapped pass's work is cut into bounded pieces only between its executed commands'
draws, and between ranges of a draw's indices where the draw is cut so**
+4 -2
View File
@@ -27,7 +27,7 @@ Columns:
| Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed |
|---|---|---|---|---|---|---|---|
| Translator and front-end refusals | 129 | 129 | 7 | 32 | 71 | 19 | 0 |
| Translator and front-end refusals | 130 | 130 | 7 | 32 | 72 | 19 | 0 |
| Runtime gaps | 79 | 79 | 1 | 10 | 46 | 22 | 0 |
| Apple-only calls | 4 | 4 | 0 | 0 | 0 | 4 | 0 |
| Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 |
@@ -41,7 +41,7 @@ Columns:
| Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` |
|---|---|---|---|---|---|---|---|---|
| Translator and front-end refusals | 0 | 0 | 0 | 48 | 58 | 0 | 0 | 23 |
| Translator and front-end refusals | 0 | 0 | 0 | 49 | 58 | 0 | 0 | 23 |
| Runtime gaps | 0 | 0 | 0 | 0 | 79 | 0 | 0 | 0 |
| Apple-only calls | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 |
| Binder refusals at a device limit | 0 | 0 | 0 | 9 | 0 | 0 | 0 | 0 |
@@ -89,6 +89,7 @@ Columns:
| `Int64Atomics` | 64-bit atomics | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`) | `device` | 2: `crates/metal2vulkan/src/lower/access/atomic.rs (select, 2 sites)` | `rare`: 64-bit atomics |
| `ImageAtomics` | Image atomics beyond 32-bit integers | devices without a capability the site computes (`gaps`); every device (no Vulkan mechanism) | `device` | 3: `crates/metal2vulkan-runtime/src/families/formats.rs (atomic_gap, 2 sites)`, `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format)` | `rare`: texture atomics beyond 32-bit integers |
| `DescriptorCount` | Too many descriptors of one kind in a stage or pipeline | devices short of a device limit the site names; devices without VkLimit::MaxUniformBufferRange | `device` | 3: `crates/metal2vulkan/src/lower/access/mod.rs (accept_placement)`, `crates/metal2vulkan/src/lower/select.rs (finish)` (+1) | `app`: many textures or buffers in one stage on a smaller device |
| `StageSize` | A stage module larger than the device's driver compiles intact (`Needs::DriverDefect` names the defect) | drivers with a defect | `device` | 1: `crates/metal2vulkan/src/pipeline/compile/stage_bound.rs (emit)` | `rare`: a kernel too large for a driver's compiler, on a driver measured to corrupt one past its bound |
| `BufferRange` | A buffer window beyond the descriptor range limits | devices without a capability the site computes (`needs`); devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism) | `device` | 8: `crates/metal2vulkan-runtime/src/function_table.rs (past_storage_buffer_range)`, `crates/metal2vulkan/src/bind/graphics.rs (patch_binding, 3 sites)` (+4) | `app`: a buffer window past a device's descriptor range |
| `Int64Arithmetic` | 64-bit integer arithmetic | devices without VkFeature::ShaderInt64 | `device` | 2: `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`, `crates/metal2vulkan/src/lower/select.rs (selector_form)` | `rare`: 64-bit integers on a device without shaderInt64 |
| `Float64Arithmetic` | 64-bit float arithmetic | devices without VkFeature::ShaderFloat64 | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)` | `rare`: doubles (MSL has none outside Apple's own code) |
@@ -614,6 +615,7 @@ Each refusal's sites, with the function that builds it.
- `feature::Int64Atomics`: `crates/metal2vulkan/src/lower/access/atomic.rs (select, 2 sites)`
- `feature::ImageAtomics`: `crates/metal2vulkan-runtime/src/families/formats.rs (atomic_gap, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format)`
- `feature::DescriptorCount`: `crates/metal2vulkan/src/lower/access/mod.rs (accept_placement)`; `crates/metal2vulkan/src/lower/select.rs (finish)`; `crates/metal2vulkan/src/pipeline/link.rs (limit_error)`
- `feature::StageSize`: `crates/metal2vulkan/src/pipeline/compile/stage_bound.rs (emit)`
- `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs (patch_binding, 3 sites)`; `crates/metal2vulkan/src/bind/graphics.rs (rebind_with)`; `crates/metal2vulkan/src/bind/instantiate.rs (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs (select)`; `crates/metal2vulkan/src/lower/access/mod.rs (place_slots)`
- `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs (selector_form)`
- `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`
+1
View File
@@ -36,6 +36,7 @@ feature CoherentMemory rare coherent(device) accesses
feature Int64Atomics rare 64-bit atomics
feature ImageAtomics rare texture atomics beyond 32-bit integers
feature DescriptorCount app many textures or buffers in one stage on a smaller device
feature StageSize rare a kernel too large for a driver's compiler, on a driver measured to corrupt one past its bound
feature BufferRange app a buffer window past a device's descriptor range
feature Int64Arithmetic rare 64-bit integers on a device without shaderInt64
feature Float64Arithmetic rare doubles (MSL has none outside Apple's own code)
Can't render this file because it contains an unexpected character in line 17 and column 65.