Translator: MSL 3.2 program-scope buffer bindings become buffer parameters; other shapes refused apart

What: `!air.global_bindings` decodes into `AirAbi::global_bindings` (`GlobalBinding`: the
global, and its node's role, type information and name, read by the parameter-node decoder;
the node's index is -1). Canonicalization (`canon::global_binding`, beside the global
built-ins) makes each plain load of a bound buffer's pointer (device or constant space, one
stated slot) a read of a parameter: the entry's own parameter of the binding's role and type
where it takes one, else one appended, shared by the bindings of one role and type. Lowering
then binds it where a `[[buffer(n)]]` parameter binds; the runtime binds nothing new.

Why: the whole module was refused as ProgramScopeBinding (78 functions in 1 library of the
private corpus on runtime-floor and gate-lavapipe: kernels, one constant struct buffer each,
read only by plain loads of its pointer). Metal fills a bound global from the executing stage's
own argument table. Measured on an Apple M3 Max under macOS 27.0.1:
- m3-max-70268: a kernel's globals read and write the buffers bound at their indices;
  reflection lists each as a binding at its index; a parameter and a global of one type at one
  index, and two globals of one type at one index, read the one buffer; a vertex and a fragment
  function reading one global each read their own stage's buffer at its index.
- m3-max-70306: Metal also takes a bound texture and sampler, bound threadgroup memory, a bound
  sampler array, and a linked visible function of another library that reads a bound buffer.

What stays refused, each a refusal of its own (docs/REFUSALS.md regenerated):
ProgramScopeResource (a texture, sampler or threadgroup memory, one or an array),
ProgramScopeSharedSlot (a binding at a slot an entry parameter or another binding binds with
another role or type), ProgramScopeLinked (bindings in a linked or dynamic-library module),
ProgramScopeRead (a read of a bound buffer other than a load of its pointer, which
`xcrun metal` 32023.922 does not write). ProgramScopeBinding is gone: a consumer's exhaustive
match on Feature breaks, and a consumer's AirAbi literal needs the new field (git grep of the
consumer's checkout at aed8655a62: 0 hits for ProgramScopeBinding and for `AirAbi {`).

Tests: the ABI decode of a binding (a node with a parameter's index, or a global that is not the
externally initialized undef constant, is malformed); canonicalization over a kernel with three
bound buffers (two appended parameters, one shared with the entry's own) and the refused
shapes; linking and dynamic-library refusals.
This commit is contained in:
Anees Iqbal committed 2026-11-23 00:51:10 -08:00
1 parent 338803bb03
commit 058fd25a7b
18 files changed
+790 -60

No files matched your search

+47 -6
View File
@@ -5,20 +5,20 @@
//! set of attributes and requires some of them.
use super::keys::{Key, BUFFER_ACCESS, TEXTURE_ACCESS};
use super::md::{kept_bytes, saw_str, Ops, Site, Tok};
use super::md::{diag, kept_bytes, saw_str, Ops, Site, Tok};
use super::structs::Structs;
use super::{
AbiInt, AccelerationStructureKind, Access, ArgTypeInfo, BufferArg, Builtin, ControlPointField,
DepthQualifier, ImageblockArg, ImageblockKind, IndirectArg, Interpolation, MeshField,
MeshFieldRole, MeshOutputs, MeshTopology, ObjectArg, OutputBinding, OutputRole, ParamBinding,
ParamRole, PatchInput, Predicate, Sampling, Slot, Stage, StructRef, TextureArg, UserKey,
Varying,
DepthQualifier, GlobalBinding, ImageblockArg, ImageblockKind, IndirectArg, Interpolation,
MeshField, MeshFieldRole, MeshOutputs, MeshTopology, ObjectArg, OutputBinding, OutputRole,
ParamBinding, ParamRole, PatchInput, Predicate, Sampling, Slot, Stage, StructRef, TextureArg,
UserKey, Varying,
};
use crate::bitcode::PointeeTable;
use crate::budget::Meter;
use crate::error::Error;
use crate::error::{AbiError, DiagName};
use crate::ir::{AddrSpace, FuncId, MdId, Module, Type, TypeId, TypeLayouts};
use crate::ir::{AddrSpace, FuncId, GlobalId, MdId, Module, Type, TypeId, TypeLayouts};
/// The decoder state shared by every node: the module, the meter, the layout arena, and the two
/// tables that reach the IR type holding an argument buffer (see [`MemberSpace`]).
@@ -343,6 +343,47 @@ impl<'m> Cx<'m, '_> {
})
}
/// Decode the node of `global`'s program-scope binding: a parameter node whose index is -1 (it
/// binds no parameter), with no predicate and no `air.arg_unused`. A buffer node that states no
/// address space takes that of the pointer the global holds.
pub(super) fn global_binding(
&mut self,
id: MdId,
global: GlobalId,
) -> Result<GlobalBinding, Error> {
let m = self.m;
let name = m
.global(global)
.and_then(|g| m.symbols().get(g.name))
.unwrap_or_default();
let node = self.node(id, Context::Input, &diag(name))?;
if node.index != Some(u32::MAX) || node.predicate.is_some() || node.attrs.unused {
return Err(node
.site
.err(AbiError::BadValue, Some("air.global_binding")));
}
let pointer = m
.global(global)
.and_then(|g| match m.types().get(g.value_ty) {
Some(Type::Ptr { space }) => Some(*space),
_ => None,
});
let layouts = node.layouts(|id, site| Structs::get(self, id, site, None))?;
let role = self.role(
&node,
layouts,
Context::Input,
pointer,
MemberSpace::Unstated,
)?;
Ok(GlobalBinding {
global,
role,
ty: node.attrs.ty(),
name: node.attrs.name.clone(),
})
}
/// Decode one output node of an entry of `stage`, the returned value's field `field`.
pub(super) fn output(
&mut self,
+18
View File
@@ -117,6 +117,8 @@ pub struct AirAbi {
pub function_constants: Vec<FunctionConstantDecl>,
/// `!air.sampler_states`: constexpr samplers.
pub static_samplers: Vec<StaticSampler>,
/// `!air.global_bindings`: the program-scope bindings, in list order.
pub global_bindings: Vec<GlobalBinding>,
/// `!air.visible_function_references`.
pub visible_function_refs: Vec<VisibleFunctionRef>,
/// `!air.visible`: the functions this module exports to the Metal linker, in list order.
@@ -1175,6 +1177,22 @@ pub struct StaticSampler {
pub state: SamplerState,
}
/// A program-scope binding of MSL 3.2 (`constant T * constant p [[buffer(n)]];` at program scope),
/// one entry of `!air.global_bindings`: a constant-space global, externally initialized and
/// `undef`, whose value the executing stage's argument table holds at the slot its node states.
/// The node is a parameter node whose index is -1, decoded as a parameter's.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GlobalBinding {
/// The global each read of the binding loads.
pub global: GlobalId,
/// What the node binds: its role key and role attributes.
pub role: ParamRole,
/// `air.arg_type_size`, `air.arg_type_align_size`, and `air.arg_type_name`, as stated.
pub ty: ArgTypeInfo,
/// `air.arg_name`, for diagnostics.
pub name: Option<DiagName>,
}
/// What an `air.visible_function_reference` names.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum VisibleTarget {
+44 -17
View File
@@ -7,15 +7,15 @@ use super::md::{
use super::sampler::decode_global;
use super::structs::Structs;
use super::{
AirAbi, Builtin, CompileOptions, EntryPoint, FunctionConstantDecl, LanguageVersion,
LinkageSignature, LinkageSignatureKind, ModuleLimits, ParamRole, PatchInfo, PatchKind, Stage,
StaticSampler, Version, VisibleFunctionRef, VisibleSymbol, VisibleTarget,
AirAbi, Builtin, CompileOptions, EntryPoint, FunctionConstantDecl, GlobalBinding,
LanguageVersion, LinkageSignature, LinkageSignatureKind, ModuleLimits, ParamRole, PatchInfo,
PatchKind, Stage, StaticSampler, Version, VisibleFunctionRef, VisibleSymbol, VisibleTarget,
};
use crate::bitcode::PointeeTable;
use crate::budget::Meter;
use crate::error::Error;
use crate::error::{AbiError, DiagName, Feature, InputError, InputErrorKind, Location};
use crate::ir::{Md, MdId, Module, Type, TypeId, TypeLayouts};
use crate::error::{AbiError, DiagName, Location};
use crate::ir::{AddrSpace, Const, Md, MdId, Module, Type, TypeId, TypeLayouts};
/// The closed set of named metadata lists.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -30,6 +30,7 @@ enum Named {
Mesh,
FunctionConstants,
SamplerStates,
GlobalBindings,
VisibleFunctionReferences,
Visible,
CoreImage,
@@ -54,6 +55,7 @@ const NAMED: &[(&str, Named)] = &[
("air.mesh", Named::Mesh),
("air.function_constants", Named::FunctionConstants),
("air.sampler_states", Named::SamplerStates),
("air.global_bindings", Named::GlobalBindings),
(
"air.visible_function_references",
Named::VisibleFunctionReferences,
@@ -70,10 +72,6 @@ const NAMED: &[(&str, Named)] = &[
("llvm.dbg.cu", Named::DebugCompileUnits),
];
/// Apple's named list of a module's program-scope buffer bindings (MSL 3.2): each entry
/// `!{!"air.global_binding", <global>, <binding>}` binds a buffer to a program-scope pointer.
const GLOBAL_BINDINGS: &str = "air.global_bindings";
/// Decode every named list of `m`. Entries are decoded kernel, vertex, fragment, object, mesh,
/// each in list order.
pub(super) fn decode(
@@ -86,14 +84,6 @@ pub(super) fn decode(
for named in m.named_md() {
meter.tick(1)?;
let name = m.symbols().get(named.name).unwrap_or_default();
// MSL 3.2's program-scope buffer bindings: valid AIR, not implemented yet, so refused as
// unsupported rather than as a key outside the input's contract.
if name == GLOBAL_BINDINGS.as_bytes() {
return Err(Error::from(InputError::new(
InputErrorKind::Unsupported(Feature::ProgramScopeBinding),
Location::metadata(Some(diag(name)), None, None),
)));
}
let kind = NAMED
.iter()
.find(|(s, _)| s.as_bytes() == name)
@@ -115,6 +105,7 @@ pub(super) fn decode(
entries: Vec::new(),
function_constants: Vec::new(),
static_samplers: Vec::new(),
global_bindings: Vec::new(),
visible_function_refs: Vec::new(),
visible_functions: Vec::new(),
core_image_kernels: Vec::new(),
@@ -218,6 +209,14 @@ pub(super) fn decode(
abi.static_samplers.push(StaticSampler { global, state });
}
}
Named::GlobalBindings => {
cx.meter.reserve(&mut abi.global_bindings, ops.len())?;
for &id in ops {
cx.meter.tick(1)?;
abi.global_bindings
.push(global_binding(&mut cx, id, &site)?);
}
}
Named::VisibleFunctionReferences => {
cx.meter
.reserve(&mut abi.visible_function_refs, ops.len())?;
@@ -474,6 +473,34 @@ fn function_constant(
})
}
/// `!{!"air.global_binding", ptr @g, !<parameter node>}`: a program-scope binding. The global is
/// one Apple's compiler writes for it: a constant of the constant space, externally initialized and
/// `undef`. The node is decoded as a parameter's ([`Cx::global_binding`]).
fn global_binding(cx: &mut Cx<'_, '_>, id: MdId, site: &Site) -> Result<GlobalBinding, Error> {
let m = cx.m;
let key = Some("air.global_binding");
let mut n = Ops::node(m, id, site.clone())?;
let tag = n.string(key)?;
if tag != b"air.global_binding" {
return Err(site.unknown(key, saw_str(tag)));
}
let global = n.global(key)?;
let node = n.child(key)?;
n.finish()?;
let bound = m.global(global).is_some_and(|g| {
g.space == AddrSpace::Constant
&& g.constant
&& g.externally_initialized
&& g.init
.and_then(|c| m.consts().get(c))
.is_some_and(|c| c.value == Const::Undef)
});
if !bound {
return Err(site.err(AbiError::BadValue, key));
}
cx.global_binding(node, global)
}
/// An entry node: `!{ptr @fn, !outputs, !inputs, <stage attribute>...}`.
fn entry(cx: &mut Cx<'_, '_>, stage: Named, id: MdId) -> Result<EntryPoint, Error> {
cx.meter.tick(1)?;
+76 -10
View File
@@ -430,18 +430,83 @@ fn an_unknown_key_names_what_it_read() {
);
}
/// MSL 3.2's program-scope buffer bindings (`!air.global_bindings`) are valid AIR this version
/// does not implement: refused as unsupported, not as malformed input.
#[test]
fn program_scope_bindings_are_unsupported_not_malformed() {
/// The global Apple's compiler writes for a program-scope binding: a constant of the constant
/// space holding a pointer, externally initialized (`external`) and `undef`.
fn bound_global(b: &mut ModuleBuilder, external: bool) -> GlobalId {
let ptr = b.ptr(AddrSpace::Constant);
let undef = b.constant(ptr, Const::Undef);
let name = b.sym("g");
b.global(Global {
name,
value_ty: ptr,
space: AddrSpace::Constant,
constant: true,
init: Some(undef),
externally_initialized: external,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
align: None,
section: None,
})
}
/// The standard kernel with one `!air.global_bindings` entry binding a global (externally
/// initialized: `external`) through the parameter node `binding`.
fn bound(external: bool, binding: &[O<'_>]) -> Result<AirAbi, Error> {
let mut k = Kernel::standard();
let binding = node(&mut k.b, &[S("air.global_binding")]);
k.b.named_md("air.global_bindings", &[binding]);
let err = k.decode().unwrap_err();
let Error::Unsupported(u) = err else {
panic!("not unsupported: {err:?}")
let g = bound_global(&mut k.b, external);
let n = node(&mut k.b, binding);
let entry = node(&mut k.b, &[S("air.global_binding"), G(g), N(n)]);
k.b.named_md("air.global_bindings", &[entry]);
k.decode()
}
/// MSL 3.2's program-scope bindings (`!air.global_bindings`) decode: each entry names its global
/// and a parameter node whose index is -1, read as a parameter's role (`constant float *
/// constant g [[buffer(5)]]`, as `xcrun metal` 32023.922 writes it). A node with a parameter's
/// index, or a global other than the externally initialized `undef` constant, is malformed.
#[test]
fn program_scope_bindings_decode_as_parameter_roles() {
let binding = |index: u64| {
vec![
I(index),
S("air.buffer"),
S("air.location_index"),
I(5),
I(1),
S("air.read"),
S("air.address_space"),
I(2),
S("air.arg_type_size"),
I(4),
S("air.arg_type_align_size"),
I(4),
S("air.arg_type_name"),
S("float"),
S("air.arg_name"),
S("g"),
]
};
assert_eq!(u.feature, Feature::ProgramScopeBinding);
let abi = bound(true, &binding(0xffff_ffff)).unwrap();
let [b] = abi.global_bindings.as_slice() else {
panic!("{:?}", abi.global_bindings)
};
let ParamRole::Buffer(arg) = &b.role else {
panic!("{:?}", b.role)
};
let slot = Slot {
index: AbiInt::Const(5),
count: AbiInt::Const(1),
};
assert_eq!(
(arg.location, arg.access, arg.space),
(slot, Access::Read, AddrSpace::Constant)
);
assert_eq!(b.ty.size, Some(4));
assert_eq!(b.name, Some(DiagName::new("g")));
expect_abi(bound(true, &binding(0)), AbiError::BadValue);
expect_abi(bound(false, &binding(0xffff_ffff)), AbiError::BadValue);
// Any other named list outside the closed set is still a key outside the contract.
let mut k = Kernel::standard();
let other = node(&mut k.b, &[S("air.no_such_entry")]);
@@ -2740,6 +2805,7 @@ fn pointee_size_and_layout_checks() {
entries: vec![],
function_constants: vec![],
static_samplers: vec![],
global_bindings: vec![],
visible_function_refs: vec![],
visible_functions: vec![],
core_image_kernels: vec![],
@@ -29,6 +29,7 @@ fn abi() -> AirAbi {
entries: Vec::new(),
function_constants: Vec::new(),
static_samplers: Vec::new(),
global_bindings: Vec::new(),
visible_function_refs: Vec::new(),
visible_functions: Vec::new(),
core_image_kernels: Vec::new(),
@@ -31,6 +31,7 @@ fn abi() -> AirAbi {
entries: Vec::new(),
function_constants: Vec::new(),
static_samplers: Vec::new(),
global_bindings: Vec::new(),
visible_function_refs: Vec::new(),
visible_functions: Vec::new(),
core_image_kernels: Vec::new(),
@@ -547,7 +548,7 @@ fn an_imported_variable_is_one_object() {
/// What the search cannot answer is refused, each only at a surviving use: a library whose
/// module does not decode before the one exporting it, a hidden definition (whose export Metal's
/// answer is not measured for), a definition of another kind or type, or a library linking does
/// not import from (function constants).
/// not import from (function constants, program-scope bindings).
#[test]
fn what_the_search_cannot_answer_is_refused() {
let refused = |libraries: Vec<DynamicModule>| {
@@ -604,6 +605,31 @@ fn what_the_search_cannot_answer_is_refused() {
}];
}
linking(refused(vec![constants]), "air.function_constants");
// A library whose module carries program-scope bindings: what they read is the calling
// stage's argument table, which the import does not reach.
let mut bound = library("libA", &[def("f", 3)], &[]);
if let Ok(code) = bound.code.as_mut() {
code.abi.global_bindings = vec![crate::abi::GlobalBinding {
global: GlobalId::new(0),
role: ParamRole::Sampler {
location: Slot {
index: AbiInt::Const(0),
count: AbiInt::Const(1),
},
},
ty: ArgTypeInfo::default(),
name: None,
}];
}
match refused(vec![bound]) {
Error::Unsupported(u) => {
assert_eq!(u.feature, Feature::ProgramScopeLinked, "{u}");
let at =
Location::metadata(Some(DiagName::new("f")), None, Some("air.global_bindings"));
assert_eq!(u.location, Some(at), "{u}");
}
other => panic!("{other}"),
}
}
/// A declaration no flat table names is no import: a call to it is still `Linking`, whatever
@@ -0,0 +1,201 @@
//! Program-scope buffer bindings as buffer parameters.
//!
//! MSL 3.2 lets a program bind a buffer at program scope (`constant T * constant p
//! [[buffer(n)]];`), which every function may read. `xcrun metal` 32023.922 makes it a
//! constant-space global, externally initialized and `undef`, makes each read of it (`&p`
//! included) a load of the pointer it holds, and lists it in `!air.global_bindings`
//! ([`GlobalBinding`]). Metal fills it from the executing stage's own argument table: measured on
//! an Apple M3 Max under macOS 27.0.1 (m3-max-70268), a kernel's global reads and writes the buffer
//! bound at its index, a vertex and a fragment function that read one global each read their own
//! stage's buffer there, and two globals of one type at one index, or a global and a parameter of
//! one type, read the one buffer bound there. So `expand` makes each load of a bound buffer's
//! pointer a read of a parameter of the entry: its own parameter of the binding's role and type
//! where it takes one, else one `expand` adds, shared by the bindings of one role and type.
//! Lowering then binds an added parameter where a `[[buffer(n)]]` parameter binds.
//!
//! Three shapes stay refused, each where it is found: an added parameter whose slot another
//! parameter of the entry binds ([`shared_slot`]), and, through what pruning keeps, any read of a
//! binding that did not become a parameter ([`left`]): a texture's, a sampler's or threadgroup
//! memory's, or another read of a buffer's.
use crate::abi::{AbiInt, EntryPoint, GlobalBinding, ParamBinding, ParamRole, Slot};
use crate::budget::Meter;
use crate::error::{DiagName, Error, Feature, Location, Unsupported};
use crate::ir::{AddrSpace, ArgIdx, Body, Const, GlobalId, InstKind, ModuleParts, TypeId, Value};
use super::interface;
use super::rewrite::{append_params, apply, scoped, BodyEdit};
/// The space of the pointer a load of binding `b`'s global reads, where `expand` makes such a load
/// a parameter: `b` binds one buffer of the device or constant space at a stated slot.
fn buffer_space(b: &GlobalBinding) -> Option<AddrSpace> {
match &b.role {
ParamRole::Buffer(arg)
if matches!(arg.space, AddrSpace::Device | AddrSpace::Constant)
&& matches!(
arg.location,
Slot {
index: AbiInt::Const(_),
count: AbiInt::Const(1)
}
) =>
{
Some(arg.space)
}
_ => None,
}
}
/// The binding of `bindings` whose global the load `kind` of a value of type `ty` reads, when
/// `expand` makes the load a parameter.
fn bound<'b>(
parts: &ModuleParts,
bindings: &'b [GlobalBinding],
kind: &InstKind,
ty: TypeId,
) -> Option<&'b GlobalBinding> {
let InstKind::Load {
ptr: Value::Const(c),
volatile: false,
atomic: None,
..
} = kind
else {
return None;
};
let Some(Const::GlobalAddr(g)) = parts.consts.get(*c).map(|k| &k.value) else {
return None;
};
let b = bindings.iter().find(|b| b.global == *g)?;
(parts.types.ptr_space(ty) == Some(buffer_space(b)?)).then_some(b)
}
/// Make each load of a bound buffer's pointer in the entry `ep`'s `body` a read of a parameter
/// (see the module), returning the new body and the parameters added for them (none, and `body`
/// unchanged, when it loads none).
pub(super) fn expand(
body: Body,
parts: &mut ModuleParts,
ep: &EntryPoint,
bindings: &[GlobalBinding],
m: &mut Meter,
) -> Result<(Body, Vec<ParamBinding>), Error> {
// The parameters to add, in the order the body first loads them: one per role and type.
let mut added: Vec<(&GlobalBinding, TypeId)> = Vec::new();
let mut loads = false;
for (_, inst) in body.insts.iter() {
m.tick(1)?;
let Some(b) = bound(parts, bindings, &inst.kind, inst.ty) else {
continue;
};
loads = true;
if own(ep, b).is_none() && !added.iter().any(|(a, _)| alike(a, b)) {
m.reserve(&mut added, 1)?;
added.push((b, inst.ty));
}
}
if !loads {
return Ok((body, Vec::new()));
}
let first = if added.is_empty() {
0
} else {
let tys: Vec<TypeId> = added.iter().map(|&(_, ty)| ty).collect();
append_params(parts, ep.func, &tys, m)?
};
let param = |b: &GlobalBinding| -> Option<u32> {
own(ep, b).or_else(|| {
let at = added.iter().position(|(a, _)| alike(a, b))?;
first.checked_add(u32::try_from(at).ok()?)
})
};
let out = scoped(m, |m, held| {
let mut edit = BodyEdit::keep_all(&body, m, held)?;
for (i, inst) in body.insts.iter() {
m.tick(1)?;
if let Some(p) = bound(parts, bindings, &inst.kind, inst.ty).and_then(param) {
edit.replace(i, Value::Arg(ArgIdx::new(p)));
}
}
apply(&body, &edit, &|c| c, m)
})?;
body.release(m);
let params = added
.iter()
.zip(first..)
.map(|(&(b, _), param)| ParamBinding {
param,
role: b.role.clone(),
unused: false,
predicate: None,
ty: b.ty.clone(),
name: b.name.clone(),
})
.collect();
Ok((out, params))
}
/// Whether bindings `a` and `b` bind one argument: one role and one type.
fn alike(a: &GlobalBinding, b: &GlobalBinding) -> bool {
a.role == b.role && a.ty == b.ty
}
/// The parameter of `ep` that binding `b`'s reads read: one of its role and type that no predicate
/// gates and that the entry uses.
fn own(ep: &EntryPoint, b: &GlobalBinding) -> Option<u32> {
ep.params
.iter()
.find(|p| p.role == b.role && p.ty == b.ty && p.predicate.is_none() && !p.unused)
.map(|p| p.param)
}
/// Refuse the first of the `added` parameters whose buffer slot a present parameter of the entry
/// `params`, or an earlier added one, also binds: Metal reads the one buffer bound there through
/// both, which two parameters do not model.
pub(super) fn shared_slot(
name: &DiagName,
params: &[ParamBinding],
added: &[ParamBinding],
) -> Result<(), Error> {
for (i, p) in added.iter().enumerate() {
let mut earlier = params.iter().chain(added.get(..i).unwrap_or_default());
if earlier.any(|q| interface::overlap(p, q)) {
return Err(refused(
Feature::ProgramScopeSharedSlot,
name,
p.name.clone(),
));
}
}
Ok(())
}
/// Refuse the first of the `bindings` whose global `kept` (what pruning keeps of the entry's
/// globals) still holds: a read of it did not become a parameter.
pub(super) fn left(
name: &DiagName,
bindings: &[GlobalBinding],
kept: impl Fn(GlobalId) -> bool,
) -> Result<(), Error> {
let Some(b) = bindings.iter().find(|b| kept(b.global)) else {
return Ok(());
};
let feature = match buffer_space(b) {
Some(_) => Feature::ProgramScopeRead,
None => Feature::ProgramScopeResource,
};
Err(refused(feature, name, b.name.clone()))
}
/// `feature`, refused in entry `name` at the binding named `binding`.
fn refused(feature: Feature, name: &DiagName, binding: Option<DiagName>) -> Error {
let refusal = Unsupported::not_implemented(feature).at(Location::metadata(
Some(name.clone()),
None,
Some("air.global_bindings"),
));
match binding {
Some(b) => refusal.naming(b).into(),
None => refusal.into(),
}
}
+27 -9
View File
@@ -334,16 +334,16 @@ fn past_table(r: &ParamRole) -> bool {
/// (`RequestError::OverlappingArgument`). Arguments of different tables never overlap, and a
/// parameter gated off binds no slot. A count of 0 binds none either.
fn overlapping(name: &DiagName, params: &[ParamBinding]) -> Result<(), Error> {
let mut seen: Vec<(Table, u64, u64)> = Vec::with_capacity(params.len());
for p in params {
let Some((table, location)) = table_slots(&p.role) else {
for (i, p) in params.iter().enumerate() {
let Some((_, index, count)) = slots(p) else {
continue;
};
let (AbiInt::Const(index), AbiInt::Const(count)) = (location.index, location.count) else {
continue;
};
let (lo, hi) = (u64::from(index), u64::from(index) + u64::from(count));
if seen.iter().any(|&(t, a, b)| t == table && a < hi && lo < b) {
if params
.get(..i)
.unwrap_or_default()
.iter()
.any(|q| overlap(p, q))
{
return Err(InputError::new(
InputErrorKind::Request(RequestError::OverlappingArgument {
param: p.param,
@@ -358,11 +358,29 @@ fn overlapping(name: &DiagName, params: &[ParamBinding]) -> Result<(), Error> {
)
.into());
}
seen.push((table, lo, hi));
}
Ok(())
}
/// The argument table parameter `p` binds in, and its first slot and count, where both are
/// resolved ([`table_slots`]).
fn slots(p: &ParamBinding) -> Option<(Table, u32, u32)> {
let (table, location) = table_slots(&p.role)?;
match (location.index, location.count) {
(AbiInt::Const(index), AbiInt::Const(count)) => Some((table, index, count)),
_ => None,
}
}
/// Whether the resolved slots of parameters `a` and `b` overlap in one argument table.
pub(super) fn overlap(a: &ParamBinding, b: &ParamBinding) -> bool {
let (Some((t, i, n)), Some((u, j, k))) = (slots(a), slots(b)) else {
return false;
};
let (i, n, j, k) = (u64::from(i), u64::from(n), u64::from(j), u64::from(k));
t == u && i < j + k && j < i + n
}
/// How an absent argument of role `r` is read. A buffer or argument buffer reads as the null
/// reference ([`Absent::Null`]): a load through an undeclared buffer is undefined, so the access
/// family's null root (zero) refines it. A texture or sampler is read through texture calls
+17
View File
@@ -296,6 +296,19 @@ pub(super) fn not_implemented(name: &[u8], key: &'static str) -> Error {
.into()
}
/// The linked function `name`, whose module carries program-scope bindings: what they read is the
/// calling stage's argument table, which the import does not reach.
fn bound(name: &[u8]) -> Error {
Unsupported::not_implemented(Feature::ProgramScopeLinked)
.naming(diag(name))
.at(Location::metadata(
Some(diag(name)),
None,
Some("air.global_bindings"),
))
.into()
}
/// The name of the global listing a module's dynamic-library imports: AIR linker ABI.
const FLAT_TABLE: &[u8] = b"air.dyld_flat_table";
@@ -879,6 +892,9 @@ fn plan<'c>(
if super::unread_signature(&l.abi) {
return Ok(Err(not_implemented(name, "air.signature")));
}
if !l.abi.global_bindings.is_empty() {
return Ok(Err(bound(name)));
}
let constants = match &f.constants {
Ok(c) => c,
Err(e) => return Ok(Err(e.clone())),
@@ -1833,6 +1849,7 @@ impl<'a> Libraries<'a> {
return Ok(match (visibility, exports.blocked) {
(Visibility::Hidden, _) => Found::Refused(not_implemented(name, "visibility")),
(_, Some(key)) => Found::Refused(not_implemented(name, key)),
_ if !code.abi.global_bindings.is_empty() => Found::Refused(bound(name)),
_ => Found::At(i, item),
});
}
@@ -32,6 +32,7 @@ fn abi() -> AirAbi {
entries: Vec::new(),
function_constants: Vec::new(),
static_samplers: Vec::new(),
global_bindings: Vec::new(),
visible_function_refs: Vec::new(),
visible_functions: Vec::new(),
core_image_kernels: Vec::new(),
@@ -477,6 +478,36 @@ fn a_linked_module_s_signature_is_read_as_the_entry_s() {
assert!(t.contains("add i32 %a1, i32 5"), "{t}");
}
/// A linked module carrying program-scope bindings is refused at the call of its function, naming
/// it: what the bindings read is the calling stage's argument table, which the import does not
/// reach.
#[test]
fn a_linked_module_with_program_scope_bindings_is_refused() {
let mut l = callee("f", &[]);
code(&mut l).abi.global_bindings = vec![crate::abi::GlobalBinding {
global: GlobalId::new(0),
role: ParamRole::Buffer(BufferArg {
location: Slot {
index: AbiInt::Const(5),
count: AbiInt::Const(1),
},
access: Access::Read,
space: AddrSpace::Constant,
buffer_size: None,
layout: None,
raster_order_group: None,
}),
ty: ArgTypeInfo::default(),
name: None,
}];
let u = match link(&[l]) {
Err(Error::Unsupported(u)) => u,
other => panic!("{other:?}"),
};
assert_eq!(u.feature, Feature::ProgramScopeLinked, "{u}");
assert_eq!(u.symbol, Some(DiagName::new("f")), "{u}");
}
/// The visible functions of a linked module that declares the `i32` function constant `c`
/// (index 0), each `i32 (i32 x)`, as Apple's compiler writes such a module: its static
/// initializer copies `c` into the internal global `c.copy`, which the functions read.
+16 -1
View File
@@ -83,7 +83,9 @@
//! row, the origin and the constant transpose flag (`legacy_matrix`). **Aggregate accesses**: a
//! load or store of a whole array or struct in buffer or threadgroup memory becomes its scalar
//! and vector members' accesses, joined by `insertvalue` or split by `extractvalue`
//! (`aggregates`). **Global built-in
//! (`aggregates`). **Program-scope buffer bindings**: each load of the pointer a bound buffer's
//! global holds becomes a read of the entry's parameter of that buffer, its own or one appended
//! (`global_binding`). **Global built-in
//! variables**: each `air.get_*` read of a program-scope built-in becomes a read of a built-in
//! parameter appended to the entry (`global_builtin`); in OpenCL mode, first, the entry takes
//! the three hidden buffers, each OpenCL C work-item read becomes a read of its built-in or of
@@ -120,6 +122,7 @@ mod fold;
mod forward;
pub mod function_table;
mod generic;
mod global_binding;
mod global_builtin;
mod inline;
mod interface;
@@ -813,6 +816,9 @@ pub fn specialize_dynamic(
} else {
(body, None)
};
// Program-scope buffer bindings: each load of a bound buffer's pointer becomes a read of the
// entry's own parameter of that buffer, or of one added to it.
let (body, bound) = global_binding::expand(body, &mut parts, ep, &abi.global_bindings, m)?;
// Global built-in variables: each read becomes a read of a built-in parameter added to the
// entry, but one Metal refuses in the entry's stage.
let (body, global_builtins) = global_builtin::expand(body, &mut parts, func, &ep.stage, m)?;
@@ -843,6 +849,10 @@ pub fn specialize_dynamic(
if let Some(first) = hidden {
(ep, open_cl_1d_images) = opencl::entry(ep, first, &req.open_cl_lines)?;
}
// The buffer parameters the program-scope bindings' reads became, each at a slot no other
// parameter binds.
global_binding::shared_slot(&ep.name, &ep.params, &bound)?;
ep.params.extend(bound);
// The built-in parameters the global built-ins' reads became.
ep.params.extend(global_builtins);
// A table whose every use devirtualization rewrote is read as a buffer of words.
@@ -871,6 +881,11 @@ pub fn specialize_dynamic(
// What nothing observes goes before pruning, so nothing it alone reaches is kept.
interface::unobserved_code(&mut parts, func, &ep, m)?;
let pruned = prune::prune(parts, func, m)?;
// A program-scope binding whose global the entry still reaches was read other than as a
// buffer parameter.
global_binding::left(&ep.name, &abi.global_bindings, |g| {
pruned.gmap.get(g.index()).copied().flatten().is_some()
})?;
ep.func = pruned.func;
remap_control_points(&mut ep, &pruned.fmap);
// The module's constexpr samplers and those of the linked functions it imported.
@@ -27,6 +27,7 @@ mod float_compares;
mod float_folds;
mod forwarding;
mod generic_pointers;
mod global_bindings;
mod global_builtins;
mod opencl;
mod private_memory;
@@ -54,6 +55,7 @@ fn abi(entries: Vec<EntryPoint>, fcs: Vec<FunctionConstantDecl>) -> AirAbi {
entries,
function_constants: fcs,
static_samplers: Vec::new(),
global_bindings: Vec::new(),
visible_function_refs: Vec::new(),
visible_functions: Vec::new(),
core_image_kernels: Vec::new(),
@@ -0,0 +1,213 @@
//! Program-scope buffer bindings become buffer parameters: each load of the pointer a bound
//! buffer's global holds is a read of the entry's own parameter of that buffer, or of one
//! appended to it, one per role and type; what stays a read of a bound global is refused.
use super::*;
use crate::abi::GlobalBinding;
use crate::error::Feature;
use crate::ir::{Type, TypeId};
/// A global as Apple's compiler writes one for a program-scope binding: a constant of the constant
/// space holding a pointer, externally initialized and `undef`.
fn bound_global(m: &mut ModuleBuilder, name: &str) -> GlobalId {
let ptr = m.ptr(AddrSpace::Constant);
let undef = m.constant(ptr, Const::Undef);
let name = m.sym(name);
m.global(Global {
name,
value_ty: ptr,
space: AddrSpace::Constant,
constant: true,
init: Some(undef),
externally_initialized: true,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
align: None,
section: None,
})
}
/// A binding of `global` with `role`, named `name`.
fn binding(global: GlobalId, role: ParamRole, name: &str) -> GlobalBinding {
GlobalBinding {
global,
role,
ty: ArgTypeInfo::default(),
name: Some(DiagName::new(name)),
}
}
/// [`buffer`]'s role at `index` in `space` with `access`.
fn buffer_role(index: u32, space: AddrSpace, access: Access) -> ParamRole {
match buffer(0, index).role {
ParamRole::Buffer(arg) => ParamRole::Buffer(BufferArg {
space,
access,
..arg
}),
_ => unreachable!(),
}
}
/// `kernel k(device i32* out [[buffer(0)]])` reading three bound globals: `c`, a `constant i32 *`,
/// `d` and `o`, `device i32 *`s. It stores `*c + c[1]` (`c` loaded twice) to `*d`, `*c` to `*o`
/// and `c[1]` to `out`, then what `extra` adds over the globals' addresses; `roles` binds the
/// globals.
fn entry_with(
extra: impl FnOnce(&mut FunctionBuilder<'_>, [Value; 3]),
roles: impl FnOnce([GlobalId; 3]) -> Vec<GlobalBinding>,
) -> Result<Entry, Error> {
let mut m = ModuleBuilder::new();
let globals = [
bound_global(&mut m, "c"),
bound_global(&mut m, "d"),
bound_global(&mut m, "o"),
];
let void = m.void();
let i32t = m.int(32);
let dev = m.ptr(AddrSpace::Device);
let cst = m.ptr(AddrSpace::Constant);
let fty = m.fn_ty(void, &[dev]);
let addrs = globals.map(|g| m.global_addr(g));
let one = {
let i64t = m.int(64);
m.const_int(i64t, 1)
};
let mut f = m.define("k", fty);
let c = load(&mut f, cst, addrs[0]);
let x = load(&mut f, i32t, c);
let c2 = load(&mut f, cst, addrs[0]);
let at = f.push(
cst,
InstKind::Gep {
src_ty: i32t,
base: c2,
indices: vec![one].into(),
inbounds: true,
},
);
let y = load(&mut f, i32t, at);
let sum = f.bin(BinOp::Add, x, y);
let d = load(&mut f, dev, addrs[1]);
store(&mut f, sum, d);
let o = load(&mut f, dev, addrs[2]);
store(&mut f, x, o);
store(&mut f, y, arg(0));
extra(&mut f, addrs);
f.ret(None);
let k = f.finish();
let module = m.finish().unwrap();
let mut abi = abi(vec![kernel(k, vec![buffer(0, 0)])], Vec::new());
abi.global_bindings = roles(globals);
specialize(module, &abi, &request(&[]), &mut meter())
}
/// The three bindings [`entry_with`] describes.
fn standard([c, d, o]: [GlobalId; 3]) -> Vec<GlobalBinding> {
vec![
binding(c, buffer_role(1, AddrSpace::Constant, Access::Read), "c"),
binding(d, buffer_role(3, AddrSpace::Device, Access::ReadWrite), "d"),
binding(o, buffer(0, 0).role, "o"),
]
}
fn refusal(e: Result<Entry, Error>) -> Feature {
match e {
Err(Error::Unsupported(u)) => u.feature,
other => panic!("not a refusal: {other:?}"),
}
}
/// `c`'s two loads read one appended `constant` parameter at `buffer(1)`, `d`'s an appended
/// `device` one at `buffer(3)`, in the order the body first loads them, and `o`'s the entry's own
/// `buffer(0)`, which binds the same role and type; no global is left.
#[test]
fn bound_buffers_become_buffer_parameters() {
let e = entry_with(|_, _| {}, standard).unwrap();
let slots: Vec<_> =
e.ep.params
.iter()
.map(|p| match &p.role {
ParamRole::Buffer(b) => (p.param, b.location.index, b.space),
other => panic!("{other:?}"),
})
.collect();
assert_eq!(
slots,
[
(0, AbiInt::Const(0), AddrSpace::Device),
(1, AbiInt::Const(1), AddrSpace::Constant),
(2, AbiInt::Const(3), AddrSpace::Device),
]
);
let f = e.module.func(e.func).unwrap();
let Some(Type::Function { params, .. }) = e.module.types().get(f.ty) else {
panic!("the entry's type is not a function");
};
assert_eq!(params.len(), 3);
assert_eq!(e.module.globals().len(), 0, "{}", body_text(&e));
let text = body_text(&e);
assert!(text.contains("%a1"), "{text}");
assert!(text.contains("%a2"), "{text}");
}
/// Two bound buffers of two roles at one slot (`d` as a `device` buffer at `c`'s `buffer(1)`), and
/// a bound buffer at the slot of an entry parameter of another role (`o` read-only at the entry's
/// `buffer(0)`), are refused: Metal reads the one buffer bound there through both.
#[test]
fn a_bound_buffer_at_another_argument_s_slot_is_refused() {
let two = |[c, d, o]: [GlobalId; 3]| {
let mut b = standard([c, d, o]);
b[1].role = buffer_role(1, AddrSpace::Device, Access::ReadWrite);
b
};
assert_eq!(
refusal(entry_with(|_, _| {}, two)),
Feature::ProgramScopeSharedSlot
);
let param = |[c, d, o]: [GlobalId; 3]| {
let mut b = standard([c, d, o]);
b[2].role = buffer_role(0, AddrSpace::Device, Access::Read);
b
};
assert_eq!(
refusal(entry_with(|_, _| {}, param)),
Feature::ProgramScopeSharedSlot
);
}
/// A read of a bound buffer's global other than a load of its pointer (here its bits as an
/// `i64`) is refused, as is any read of threadgroup memory bound at program scope.
#[test]
fn a_bound_global_read_otherwise_is_refused() {
let bits = |f: &mut FunctionBuilder<'_>, [c, _, _]: [Value; 3]| {
let i64t = f.module().int(64);
let v = load(f, i64t, c);
let i32t = f.module().int(32);
let v = f.push(
i32t,
InstKind::Cast {
op: CastOp::Trunc,
v,
},
);
store(f, v, arg(0));
};
assert_eq!(
refusal(entry_with(bits, standard)),
Feature::ProgramScopeRead
);
let threadgroup = |[c, d, o]: [GlobalId; 3]| {
let mut b = standard([c, d, o]);
b[1].role = match buffer_role(0, AddrSpace::Threadgroup, Access::ReadWrite) {
ParamRole::Buffer(arg) => ParamRole::Threadgroup(arg),
_ => unreachable!(),
};
b
};
assert_eq!(
refusal(entry_with(|_, _| {}, threadgroup)),
Feature::ProgramScopeResource
);
}
+19 -4
View File
@@ -828,10 +828,25 @@ pub enum Feature {
/// its pixel holds or a color's coverage mask, or a store to the samples of a coverage mask.
/// Tile functions and fragment imageblocks run on single-sample passes only.
Imageblocks,
/// A program-scope buffer binding of MSL 3.2 (macOS 15 and later), `constant T* constant p
/// [[buffer(n)]];` in Apple's `!air.global_bindings` list, valid AIR this version does not
/// implement yet.
ProgramScopeBinding,
/// A texture, a sampler or threadgroup memory bound at program scope (MSL 3.2's
/// `!air.global_bindings`), one or an array, that the entry reads: only a bound buffer becomes
/// a parameter. Metal takes each: an Apple M3 Max under macOS 27.0.1 runs kernels that read a
/// bound texture and sampler, a bound sampler array and bound threadgroup memory (m3-max-70306).
ProgramScopeResource,
/// A buffer bound at program scope at a slot that a parameter of the entry, or another binding
/// it reads, binds with another role or type. Metal takes it: on an Apple M3 Max under macOS
/// 27.0.1, a `device float *` and a `constant uint *` bound at one index read the one buffer
/// bound there (m3-max-70268).
ProgramScopeSharedSlot,
/// A program-scope binding in the module of a function a pipeline links (a visible function,
/// or a dynamic library's). Metal takes it: on an Apple M3 Max under macOS 27.0.1, a kernel's
/// pipeline links another library's visible function, which reads the buffer the kernel's
/// stage binds at the global's index (m3-max-70306).
ProgramScopeLinked,
/// A read of a buffer bound at program scope other than a load of the pointer its global
/// holds. `xcrun metal` 32023.922 writes every read so, `&p` included, so only other AIR reaches
/// it.
ProgramScopeRead,
/// A generic pointer (MSL 4.1's `addrspace(8)`) that canonicalization cannot make a pointer of
/// one address space, by how it comes to hold a space only the run knows
/// ([`GenericPointer`]). Vulkan's logical addressing has no pointer that may point into either
+23 -5
View File
@@ -234,7 +234,10 @@ impl From<crate::air::error::Feature> for Feature {
Air::Tensors => Feature::Tensors,
Air::GpuEncodedIndirectCommands => Feature::GpuEncodedIndirectCommands,
Air::Imageblocks => Feature::Imageblocks,
Air::ProgramScopeBinding => Feature::ProgramScopeBinding,
Air::ProgramScopeResource => Feature::ProgramScopeResource,
Air::ProgramScopeSharedSlot => Feature::ProgramScopeSharedSlot,
Air::ProgramScopeLinked => Feature::ProgramScopeLinked,
Air::ProgramScopeRead => Feature::ProgramScopeRead,
Air::GenericPointer(how) => Feature::GenericPointer(how),
}
}
@@ -883,10 +886,25 @@ pub enum Feature {
/// Metal's) set to a value whose effect the translation has not built: the property it names
/// ([`PrivateRenderField`]). Metal's answer for each was measured; building it is open work.
PrivateRenderState(PrivateRenderField),
/// A program-scope buffer binding of MSL 3.2 (macOS 15 and later), `constant T* constant p
/// [[buffer(n)]];` in Apple's `!air.global_bindings` list, valid AIR this version does not
/// implement yet.
ProgramScopeBinding,
/// A texture, a sampler or threadgroup memory bound at program scope (MSL 3.2's
/// `!air.global_bindings`), one or an array, that the entry reads: only a bound buffer becomes
/// a parameter. Metal takes each: an Apple M3 Max under macOS 27.0.1 runs kernels that read a
/// bound texture and sampler, a bound sampler array and bound threadgroup memory (m3-max-70306).
ProgramScopeResource,
/// A buffer bound at program scope at a slot that a parameter of the entry, or another binding
/// it reads, binds with another role or type. Metal takes it: on an Apple M3 Max under macOS
/// 27.0.1, a `device float *` and a `constant uint *` bound at one index read the one buffer
/// bound there (m3-max-70268).
ProgramScopeSharedSlot,
/// A program-scope binding in the module of a function a pipeline links (a visible function,
/// or a dynamic library's). Metal takes it: on an Apple M3 Max under macOS 27.0.1, a kernel's
/// pipeline links another library's visible function, which reads the buffer the kernel's
/// stage binds at the global's index (m3-max-70306).
ProgramScopeLinked,
/// A read of a buffer bound at program scope other than a load of the pointer its global
/// holds. `xcrun metal` 32023.922 writes every read so, `&p` included, so only other AIR reaches
/// it.
ProgramScopeRead,
/// A generic pointer (MSL 4.1's `addrspace(8)`) that canonicalization cannot make a pointer of
/// one address space, by how it comes to hold a space only the run knows
/// ([`GenericPointer`]). Vulkan's logical addressing has no pointer that may point into either
+14 -2
View File
@@ -805,6 +805,7 @@ field metal2vulkan-air::abi::AirAbi.compile pub compile: CompileOptions
field metal2vulkan-air::abi::AirAbi.core_image_kernels pub core_image_kernels: Vec<CoreImageKernel>
field metal2vulkan-air::abi::AirAbi.entries pub entries: Vec<EntryPoint>
field metal2vulkan-air::abi::AirAbi.function_constants pub function_constants: Vec<FunctionConstantDecl>
field metal2vulkan-air::abi::AirAbi.global_bindings pub global_bindings: Vec<GlobalBinding>
field metal2vulkan-air::abi::AirAbi.language pub language: Option<LanguageVersion>
field metal2vulkan-air::abi::AirAbi.limits pub limits: ModuleLimits
field metal2vulkan-air::abi::AirAbi.linkage_signature pub linkage_signature: Option<LinkageSignature>
@@ -853,6 +854,10 @@ field metal2vulkan-air::abi::FunctionConstantDecl.index pub index: u32
field metal2vulkan-air::abi::FunctionConstantDecl.name pub name: DiagName
field metal2vulkan-air::abi::FunctionConstantDecl.ty pub ty: TypeId
field metal2vulkan-air::abi::FunctionConstantDecl.type_name pub type_name: DiagName
field metal2vulkan-air::abi::GlobalBinding.global pub global: GlobalId
field metal2vulkan-air::abi::GlobalBinding.name pub name: Option<DiagName>
field metal2vulkan-air::abi::GlobalBinding.role pub role: ParamRole
field metal2vulkan-air::abi::GlobalBinding.ty pub ty: ArgTypeInfo
field metal2vulkan-air::abi::ImageblockArg.alias_implicit pub alias_implicit: bool
field metal2vulkan-air::abi::ImageblockArg.data_size pub data_size: Option<u32>
field metal2vulkan-air::abi::ImageblockArg.kind pub kind: ImageblockKind
@@ -6678,6 +6683,7 @@ struct metal2vulkan-air::abi::CoreImageOutput #[derive(Clone, Debug, PartialEq,
struct metal2vulkan-air::abi::CoreImageParam #[derive(Clone, Debug, PartialEq, Eq)] pub struct CoreImageParam
struct metal2vulkan-air::abi::EntryPoint #[derive(Clone, Debug, PartialEq, Eq)] pub struct EntryPoint
struct metal2vulkan-air::abi::FunctionConstantDecl #[derive(Clone, Debug, PartialEq, Eq)] pub struct FunctionConstantDecl
struct metal2vulkan-air::abi::GlobalBinding #[derive(Clone, Debug, PartialEq, Eq)] pub struct GlobalBinding
struct metal2vulkan-air::abi::Half #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct Half(pub u16)
struct metal2vulkan-air::abi::ImageblockArg #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct ImageblockArg
struct metal2vulkan-air::abi::IndirectArg #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct IndirectArg
@@ -7522,7 +7528,10 @@ variant metal2vulkan-air::error::Feature::IntersectionFunctionTable Intersection
variant metal2vulkan-air::error::Feature::LibraryKind LibraryKind(u8)
variant metal2vulkan-air::error::Feature::Linking Linking
variant metal2vulkan-air::error::Feature::ModuleRecord ModuleRecord { code: u32 }
variant metal2vulkan-air::error::Feature::ProgramScopeBinding ProgramScopeBinding
variant metal2vulkan-air::error::Feature::ProgramScopeLinked ProgramScopeLinked
variant metal2vulkan-air::error::Feature::ProgramScopeRead ProgramScopeRead
variant metal2vulkan-air::error::Feature::ProgramScopeResource ProgramScopeResource
variant metal2vulkan-air::error::Feature::ProgramScopeSharedSlot ProgramScopeSharedSlot
variant metal2vulkan-air::error::Feature::RayTracing RayTracing
variant metal2vulkan-air::error::Feature::Recursion Recursion
variant metal2vulkan-air::error::Feature::Stage Stage(u8)
@@ -9470,7 +9479,10 @@ variant metal2vulkan::error::Feature::PrimitiveId PrimitiveId
variant metal2vulkan::error::Feature::PrivateMemory PrivateMemory
variant metal2vulkan::error::Feature::PrivatePrimitives PrivatePrimitives
variant metal2vulkan::error::Feature::PrivateRenderState PrivateRenderState(PrivateRenderField)
variant metal2vulkan::error::Feature::ProgramScopeBinding ProgramScopeBinding
variant metal2vulkan::error::Feature::ProgramScopeLinked ProgramScopeLinked
variant metal2vulkan::error::Feature::ProgramScopeRead ProgramScopeRead
variant metal2vulkan::error::Feature::ProgramScopeResource ProgramScopeResource
variant metal2vulkan::error::Feature::ProgramScopeSharedSlot ProgramScopeSharedSlot
variant metal2vulkan::error::Feature::PullModelInterpolation PullModelInterpolation
variant metal2vulkan::error::Feature::PushWindow PushWindow
variant metal2vulkan::error::Feature::QuadOperations QuadOperations
Can't render this file because it is too large.
+10 -4
View File
@@ -26,7 +26,7 @@ Columns:
| Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed |
|---|---|---|---|---|---|---|---|
| Translator and front-end refusals | 119 | 114 | 6 | 27 | 66 | 20 | 0 |
| Translator and front-end refusals | 122 | 117 | 6 | 27 | 68 | 21 | 0 |
| Translation caps | 14 | 14 | 0 | 0 | 7 | 7 | 0 |
| Rate maps the compile layer does not compile | 5 | 5 | 0 | 0 | 4 | 1 | 0 |
| The translation deadline | 1 | 1 | 0 | 0 | 0 | 1 | 0 |
@@ -39,7 +39,7 @@ Columns:
| Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` |
|---|---|---|---|---|---|---|---|---|
| Translator and front-end refusals | 0 | 0 | 0 | 45 | 69 | 0 | 0 | 5 |
| Translator and front-end refusals | 0 | 0 | 0 | 45 | 72 | 0 | 0 | 5 |
| Translation caps | 0 | 0 | 0 | 0 | 14 | 0 | 0 | 0 |
| Rate maps the compile layer does not compile | 0 | 0 | 0 | 0 | 5 | 0 | 0 | 0 |
| The translation deadline | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
@@ -166,7 +166,10 @@ Columns:
| `IndirectRenderState` | A `depth_stencil_state` a function reads from an argument buffer or takes as a parameter, the state of an indirect render command, which no record... | every device (not implemented) | `ours` | via a helper: 2: `crates/metal2vulkan/src/lower/access/pointer.rs (unlowered)`, `crates/metal2vulkan/src/lower/select.rs (param_family)` | `rare`: render state set by a kernel on an indirect command |
| `GlobalBuiltinInFragment` | A fragment function's read of a Metal 3.1 program-scope built-in variable that Metal does not lower there | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/select.rs (route_air)` | `rare`: Metal 3.1 global built-ins in fragment functions |
| `PrivateRenderState` | A private fixed-function property of Metal's pipeline descriptor (Apple SPI, OpenGL on Metal's) set to a value whose effect the translation has... | devices without VkFeature::LogicOp; every device (not implemented) | `ours` | 5: `crates/metal2vulkan/src/lower/sampler/select.rs (clamps_reference)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (alpha_test_refused)` (+3) | `none`: Apple-private pipeline fields of OpenGL on Metal (no public header) |
| `ProgramScopeBinding` | A program-scope buffer binding of MSL 3.2 (macOS 15 and later), `constant T* constant p [[buffer(n)]];` in Apple's `!air.global_bindings` list,... | every device (not implemented) | `ours` | via a helper: 2: `crates/metal2vulkan-air/src/abi/module.rs (decode)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `app`: MSL 3.2 program-scope buffer bindings (macOS 15 and later) |
| `ProgramScopeResource` | A texture, a sampler or threadgroup memory bound at program scope (MSL 3.2's `!air.global_bindings`), one or an array, that the entry reads | every device (not implemented) | `ours` | via a helper: 2: `crates/metal2vulkan-air/src/canon/global_binding.rs (left)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `app`: MSL 3.2 textures, samplers and threadgroup memory bound at program scope (macOS 15 and later) |
| `ProgramScopeSharedSlot` | A buffer bound at program scope at a slot that a parameter of the entry, or another binding it reads, binds with another role or type | every device (not implemented) | `ours` | via a helper: 2: `crates/metal2vulkan-air/src/canon/global_binding.rs (shared_slot)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `rare`: MSL 3.2 program-scope buffers aliasing another argument of another type at one index |
| `ProgramScopeLinked` | A program-scope binding in the module of a function a pipeline links (a visible function, or a dynamic library's) | every device (not implemented) | `ours` | 1: `crates/metal2vulkan-air/src/canon/link.rs (bound)` | `rare`: MSL 3.2 program-scope bindings in a linked visible function or a dynamic library |
| `ProgramScopeRead` | A read of a buffer bound at program scope other than a load of the pointer its global holds | every device (not implemented) | `ours` | via a helper: 2: `crates/metal2vulkan-air/src/canon/global_binding.rs (left)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: a read of a program-scope buffer's global that Apple's compiler is not seen to write |
| `GenericPointer` | A generic pointer (MSL 4.1's `addrspace(8)`) that canonicalization cannot make a pointer of one address space, by how it comes to hold a space... | every device (not implemented) | `ours` | 2: `crates/metal2vulkan-air/src/canon/generic.rs (refuse)`, `crates/metal2vulkan-air/src/canon/generic.rs (refused)` | `system`: MSL 4.1 generic pointers held in memory or of two spaces (macOS 27 and later) |
| `SeqCstFence` | A sequentially consistent fence (`seq_cst` `atomic_thread_fence`, an LLVM `fence seq_cst`, or a `seq_cst` barrier ordering device memory), whose... | devices short of a Vulkan feature the site names | `device` | 1: `crates/metal2vulkan/src/lower/sync/barrier.rs (require_seq_cst)` | `rare`: a seq_cst fence in a vertex or fragment stage without its stores and atomics |
| `PostDepthCoverage` | The coverage after the depth and stencil tests (`[[sample_mask, post_depth_coverage]]`) | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)` | `rare`: the coverage after early depth and stencil tests, on every device |
@@ -482,7 +485,10 @@ Each refusal's sites, with the function that builds it.
- `feature::IndirectRenderState`: `crates/metal2vulkan/src/lower/access/pointer.rs (unlowered)`; `crates/metal2vulkan/src/lower/select.rs (param_family)`
- `feature::GlobalBuiltinInFragment`: `crates/metal2vulkan/src/lower/select.rs (route_air)`
- `feature::PrivateRenderState`: `crates/metal2vulkan/src/lower/sampler/select.rs (clamps_reference)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (alpha_test_refused)`; `crates/metal2vulkan/src/lower/texture/mod.rs (mode_rounded_write)`; `crates/metal2vulkan/src/pipeline/private_state.rs (logic_operation)`; `crates/metal2vulkan/src/pipeline/private_state.rs (refused)`
- `feature::ProgramScopeBinding`: `crates/metal2vulkan-air/src/abi/module.rs (decode)`; `crates/metal2vulkan/src/error/mod.rs (from)`
- `feature::ProgramScopeResource`: `crates/metal2vulkan-air/src/canon/global_binding.rs (left)`; `crates/metal2vulkan/src/error/mod.rs (from)`
- `feature::ProgramScopeSharedSlot`: `crates/metal2vulkan-air/src/canon/global_binding.rs (shared_slot)`; `crates/metal2vulkan/src/error/mod.rs (from)`
- `feature::ProgramScopeLinked`: `crates/metal2vulkan-air/src/canon/link.rs (bound)`
- `feature::ProgramScopeRead`: `crates/metal2vulkan-air/src/canon/global_binding.rs (left)`; `crates/metal2vulkan/src/error/mod.rs (from)`
- `feature::GenericPointer`: `crates/metal2vulkan-air/src/canon/generic.rs (refuse)`; `crates/metal2vulkan-air/src/canon/generic.rs (refused)`
- `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs (require_seq_cst)`
- `feature::PostDepthCoverage`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`
+4 -1
View File
@@ -140,7 +140,10 @@ ratemap SampleCount rare a rate map axis of more distinct samples than measured
budget Time none a translation past its deadline: a defect of ours to fix on any supported input (AGENTS.md: 20 seconds)
feature PrivateRenderState none Apple-private pipeline fields of OpenGL on Metal (no public header)
feature CommandPredication none Apple-private command predication on a device without buffer device addresses
feature ProgramScopeBinding app MSL 3.2 program-scope buffer bindings (macOS 15 and later)
feature ProgramScopeResource app MSL 3.2 textures, samplers and threadgroup memory bound at program scope (macOS 15 and later)
feature ProgramScopeSharedSlot rare MSL 3.2 program-scope buffers aliasing another argument of another type at one index
feature ProgramScopeLinked rare MSL 3.2 program-scope bindings in a linked visible function or a dynamic library
feature ProgramScopeRead none a read of a program-scope buffer's global that Apple's compiler is not seen to write
feature GenericPointer system MSL 4.1 generic pointers held in memory or of two spaces (macOS 27 and later)
feature SeqCstFence rare a seq_cst fence in a vertex or fragment stage without its stores and atomics
feature WideLines none a line under the Apple-private setLineWidth: at a width other than 1 drawn as the band, whose pipeline form the translator does not build (a selected slice or viewport, barycentric weights, multiview, synthesized geometry, too many stage outputs)
Can't render this file because it contains an unexpected character in line 17 and column 65.