The uint2 rasterization-rate map overloads compile to Metal's decoder

A fragment shader's map_screen_to_physical_coordinates and
map_physical_to_screen_coordinates with uint2 arguments were refused
(Unsupported{RasterizationRateMap, NotImplemented} at the lowering of
Fragment::MapCoordinates). Canon now expands them beside the float2
overloads, reusing the float2 decoder:

- screen to physical: the float2 decoder at the pixel's centre (c + 1/2),
  converted to uint saturating (a NaN to 0), the conversion the float2
  index path already uses;
- physical to screen: the bits of the float (0 - offset) * reciprocal of
  the entry of granule c >> 5 on the axis's to-screen table; the
  coordinate's value within the granule is not read.

Both are Metal's answers as our probe rate_map_integer_overloads measured
them on an Apple M3 Max under macOS 27.0.1: 20,114 coordinates over four
maps (one of two layers), at each map's layers and two past them, every
one equal to these formulas. The arithmetic is float and the device's own
(owner rule 1); where a device's denormals differ from Metal's flushed
ones the existing PrecisionNote::DeviceDenormals reading applies, as for
the float2 decoder. The boundary byte of a table entry is compared on its
low seven bits, as Metal's decoder does (the probe's maps hit an entry
with the high bit set).

The decoder's Rust models gain shader_screen_to_physical_integer and
shader_physical_to_screen_integer. Lowering's MapCoordinates arm is now an
invariant error: canon compiles every overload before lowering.

Tests:
- bind::rate_map::apple_tests::metals_integer_answers: 1,561 of the M3's
  answers (apple_integer_vectors.txt: Metal's answers to our probe on our
  maps, no Apple binary) against the Rust models, each map's bytes
  checked by sha-256;
- tests::engine_rate_map::integer: the fixture rate_map_integer (kernel
  and fragment) compiles on every tested profile, robust and not, passes
  L3 with no RasterizationRateMap note; the interpreter's answers equal
  the decoder's arithmetic at every layer and two past, and Metal's on a
  map's own layers; and the translated kernel's answers equal the M3's
  recorded ones at all 587 recorded points of the maps' own layers, bit
  for bit;
- the fixture's four expectation rows go from the refusal to ok on all
  profiles; integer_rasterization_rate_maps_are_refused is removed.

docs/REFUSALS.md regenerated: the fragment select site leaves the
RasterizationRateMap sites.
This commit is contained in:
Anees Iqbal committed 2026-11-13 08:31:52 -08:00
1 parent 32952d53e9
commit b31ce16c85
12 files changed
+2067 -97

No files matched your search

+5 -5
View File
@@ -67,9 +67,9 @@
//! 9. **Arm speculation**: a branch whose short arms Metal's backend runs in every lane of the
//! branch's block, and whose arms hold a group operation that answers differently there,
//! becomes a jump into its arms with a `select` for each value they join with (`speculate`).
//! **Rasterization-rate maps**: each `float2` `air.map_*_coordinates` call becomes Apple's GPU
//! decoder of Metal's parameter data (`rate_map_data`) in plain AIR: word loads through the
//! call's map pointer and Apple's arithmetic. **AIR 2.7 simdgroup-matrix block loads and
//! **Rasterization-rate maps**: each `air.map_*_coordinates` call, `float2` or `uint2`, becomes
//! Apple's GPU decoder of Metal's parameter data (`rate_map_data`) in plain AIR: word loads
//! through the call's map pointer and Apple's arithmetic. **AIR 2.7 simdgroup-matrix block loads and
//! stores** take their AIR 2.8 form, their extent, stride and origin built from the elements per
//! 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
@@ -722,8 +722,8 @@ pub fn specialize_dynamic(
};
speculate::expand(body, (&parts.types, &parts.consts), (tys, &f.params), m)?
};
// Rasterization-rate maps: each `float2` map call becomes Apple's GPU decoder of the parameter
// data, word loads through its own map pointer.
// Rasterization-rate maps: each map call, `float2` or `uint2`, becomes Apple's GPU decoder of
// the parameter data, word loads through its own map pointer.
let body = rate_map::expand(body, &mut parts, m)?;
// The AIR 2.7 simdgroup-matrix block loads and stores in their AIR 2.8 form.
let body = legacy_matrix::expand(body, &mut parts, m)?;
+121 -38
View File
@@ -16,10 +16,12 @@
//! `NaN`: Metal's on a device measured to read them so, the device's own elsewhere, noted. The
//! call's fast-math flags are not carried: the decoder's arithmetic is Apple's, not the source's.
//!
//! The `uint2` overloads (`.v2i32`) stay calls and lowering refuses them
//! (`Unsupported{RasterizationRateMap, NotImplemented}`): on Apple M3 the screen-to-physical one
//! answers `⌊map(x + 0.5)⌋` and the physical-to-screen one words of Apple's tables, so no reading
//! of the latter is established.
//! The `uint2` overloads (`.v2i32`) become Apple's GPU answers too, measured on an Apple M3 Max
//! (`rate_map_data`'s `shader_screen_to_physical_integer` and `shader_physical_to_screen_integer`):
//! screen to physical, per axis, the `float2` decoder at the pixel's centre (`uitofp` of the
//! coordinate plus 1/2) and the saturating conversion of its answer to `uint`; physical to screen,
//! the entry of granule `c >> 5` and the bits of `(0 - offset) · reciprocal`, the coordinate's
//! value not read, as Apple's GPU answers.
use crate::budget::Meter;
use crate::error::Error;
@@ -40,8 +42,36 @@ enum Direction {
ToScreen,
}
/// The call's decoded direction, when it is a `float2` map.
fn decoded(kind: &InstKind) -> Option<(Direction, &Call)> {
/// What a decoded call maps: its direction, and whether it is a `uint2` overload.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct Shape {
dir: Direction,
integer: bool,
}
impl Shape {
const ALL: [Shape; 4] = [
Shape {
dir: Direction::ToPhysical,
integer: false,
},
Shape {
dir: Direction::ToScreen,
integer: false,
},
Shape {
dir: Direction::ToPhysical,
integer: true,
},
Shape {
dir: Direction::ToScreen,
integer: true,
},
];
}
/// The call's decoded shape, when it is a rate-map call.
fn decoded(kind: &InstKind) -> Option<(Shape, &Call)> {
let InstKind::Call(call) = kind else {
return None;
};
@@ -50,29 +80,31 @@ fn decoded(kind: &InstKind) -> Option<(Direction, &Call)> {
op:
AirIntrinsic::Fragment(Fragment::MapCoordinates {
to_physical,
integer: false,
integer,
}),
..
} => Some((
if to_physical {
} => {
let dir = if to_physical {
Direction::ToPhysical
} else {
Direction::ToScreen
},
call,
)),
};
Some((Shape { dir, integer }, call))
}
_ => None,
}
}
/// The integer constants the decoder uses.
const INTS: [u32; 10] = [
const INTS: [u32; 12] = [
0,
1,
u32::MAX,
format::ENTRY_WORDS,
format::GRANULE_SHIFT,
format::OFFSET_SHIFT,
format::NO_BOUNDARY,
format::BOUNDARY_MASK,
format::TABLE_WORDS,
format::HORIZONTAL_TO_PHYSICAL,
format::VERTICAL_TO_SCREEN,
@@ -87,6 +119,7 @@ struct Vocab {
i1t: TypeId,
ptr: TypeId,
v2f32: TypeId,
v2i32: TypeId,
ints: Vec<(u32, ConstId)>,
zero_f: ConstId,
saturation_f: ConstId,
@@ -96,6 +129,7 @@ struct Vocab {
two_f: ConstId,
offset_unit_f: ConstId,
poison_v2: ConstId,
poison_v2i: ConstId,
}
impl Vocab {
@@ -111,6 +145,7 @@ impl Vocab {
m,
)?;
let v2f32 = parts.types.intern(Type::Vector { elem: f32t, len: 2 }, m)?;
let v2i32 = parts.types.intern(Type::Vector { elem: i32t, len: 2 }, m)?;
let mut c = |ty, value| parts.consts.intern(Constant { ty, value }, m);
let mut ints = Vec::new();
for v in INTS {
@@ -124,6 +159,7 @@ impl Vocab {
i1t,
ptr,
v2f32,
v2i32,
ints,
zero_f: f(0.0)?,
saturation_f: f(format::SHADER_INDEX_SATURATION)?,
@@ -133,6 +169,7 @@ impl Vocab {
two_f: f(2.0)?,
offset_unit_f: f(format::OFFSET_UNIT)?,
poison_v2: c(v2f32, Const::Poison)?,
poison_v2i: c(v2i32, Const::Poison)?,
})
}
@@ -304,9 +341,11 @@ impl Sink<'_> {
let at = self.entry(table, j, m)?;
let at = self.int_k(BinOp::Add, at, 1, m)?;
let packed = self.load(map, at, i32t, m)?;
let boundary = self.int_k(BinOp::And, packed, format::NO_BOUNDARY, m)?;
let byte = self.int_k(BinOp::And, packed, format::NO_BOUNDARY, m)?;
let none = self.v.int(format::NO_BOUNDARY)?;
let some = self.icmp(IntPredicate::Ne, boundary, none, m)?;
let some = self.icmp(IntPredicate::Ne, byte, none, m)?;
// Its low seven bits are compared (`rate_map_data::BOUNDARY_MASK`).
let boundary = self.int_k(BinOp::And, packed, format::BOUNDARY_MASK, m)?;
let jf = self.cast(CastOp::UIToFP, f32t, j, m)?;
let g = Value::Const(self.v.granularity_f);
let start = self.float(BinOp::FMul, jf, g, m)?;
@@ -342,33 +381,72 @@ impl Sink<'_> {
}
}
/// The decoder of one call: coordinate `c`, map pointer `map`, layer `layer`. Its last
/// instruction is the result.
fn decode(
/// One axis of a `uint2` overload over the table at word `table`, of the `uint` coordinate
/// `c` (`rate_map_data`'s `shader_screen_to_physical_integer` and
/// `shader_physical_to_screen_integer`).
fn integer_axis(
&mut self,
dir: Direction,
map: Value,
table: Value,
c: Value,
m: &mut Meter,
) -> Result<Value, Error> {
let (i32t, f32t) = (self.v.i32t, self.v.f32t);
match dir {
Direction::ToPhysical => {
// The `float2` decoder at the pixel's centre, its answer converted saturating.
let cf = self.cast(CastOp::UIToFP, f32t, c, m)?;
let half = Value::Const(self.v.half_f);
let centre = self.float(BinOp::FAdd, cf, half, m)?;
let r = self.axis(Direction::ToPhysical, map, table, centre, m)?;
self.index(r, m)
}
Direction::ToScreen => {
// The granule's entry; the coordinate's value is not read.
let k = self.int_k(BinOp::LShr, c, format::GRANULE_SHIFT, m)?;
let at = self.entry(table, k, m)?;
let reciprocal = self.load(map, at, f32t, m)?;
let at = self.int_k(BinOp::Add, at, 1, m)?;
let offset = self.load(map, at, f32t, m)?;
let zero = Value::Const(self.v.zero_f);
let d = self.float(BinOp::FSub, zero, offset, m)?;
let r = self.float(BinOp::FMul, d, reciprocal, m)?;
self.cast(CastOp::Bitcast, i32t, r, m)
}
}
}
/// The decoder of one call of `shape`: coordinate `c`, map pointer `map`, layer `layer`. Its
/// last instruction is the result.
fn decode(
&mut self,
shape: Shape,
c: Value,
map: Value,
layer: Value,
m: &mut Meter,
) -> Result<Value, Error> {
let Shape { dir, integer } = shape;
let to_physical = dir == Direction::ToPhysical;
// The layer's horizontal table, unclamped (`rate_map_data::table`); the vertical one is
// every layer's.
let offset = self.int_k(BinOp::Mul, layer, format::TABLE_WORDS, m)?;
let horizontal = self.int_k(BinOp::Add, offset, format::table(0, 0, to_physical), m)?;
let vertical = self.v.int(format::table(0, 1, to_physical))?;
let mut v = Value::Const(self.v.poison_v2);
let (elem, vec, mut v) = match integer {
false => (self.v.f32t, self.v.v2f32, Value::Const(self.v.poison_v2)),
true => (self.v.i32t, self.v.v2i32, Value::Const(self.v.poison_v2i)),
};
for (axis, table) in [(0u32, horizontal), (1, vertical)] {
let lane = self.v.int(axis)?;
let ca = self.push(
self.v.f32t,
InstKind::ExtractElement { vec: c, idx: lane },
m,
)?;
let r = self.axis(dir, map, table, ca, m)?;
let ca = self.push(elem, InstKind::ExtractElement { vec: c, idx: lane }, m)?;
let r = match integer {
false => self.axis(dir, map, table, ca, m)?,
true => self.integer_axis(dir, map, table, ca, m)?,
};
v = self.push(
self.v.v2f32,
vec,
InstKind::InsertElement {
vec: v,
elt: r,
@@ -381,38 +459,43 @@ impl Sink<'_> {
}
}
/// The number of instructions one call of `dir` becomes.
fn decoder_len(dir: Direction, v: &Vocab, m: &mut Meter) -> Result<u32, Error> {
/// The number of instructions one call of `shape` becomes.
fn decoder_len(shape: Shape, v: &Vocab, m: &mut Meter) -> Result<u32, Error> {
let mut scratch = Body::default();
let mut s = Sink {
out: &mut scratch,
v,
};
let any = Value::Const(v.poison_v2);
s.decode(dir, any, any, any, m)?;
s.decode(shape, any, any, any, m)?;
let len = scratch.insts.len();
scratch.release(m);
u32::try_from(len).map_err(|_| invariant("decoder length"))
}
/// Replace every `float2` rate-map call of `body` by its decoder.
/// Replace every rate-map call of `body` by its decoder.
pub(super) fn expand(body: Body, parts: &mut ModuleParts, m: &mut Meter) -> Result<Body, Error> {
if !body.insts.iter().any(|(_, i)| decoded(&i.kind).is_some()) {
return Ok(body);
}
let v = Vocab::new(parts, m)?;
let lens = [
decoder_len(Direction::ToPhysical, &v, m)?,
decoder_len(Direction::ToScreen, &v, m)?,
];
let mut lens = [0u32; Shape::ALL.len()];
for (len, shape) in lens.iter_mut().zip(Shape::ALL) {
*len = decoder_len(shape, &v, m)?;
}
let len_of = |shape: Shape| {
(Shape::ALL.iter().zip(lens))
.find(|&(s, _)| *s == shape)
.map(|(_, len)| len)
.ok_or_else(|| invariant("a decoder shape not measured"))
};
// Each old instruction's id in the output: a decoded call's is its decoder's last.
let mut result = Vec::new();
m.reserve(&mut result, body.insts.len())?;
let mut next = 0u32;
for (_, inst) in body.insts.iter() {
let n = match decoded(&inst.kind) {
Some((Direction::ToPhysical, _)) => lens[0],
Some((Direction::ToScreen, _)) => lens[1],
Some((shape, _)) => len_of(shape)?,
None => 1,
};
next = next
@@ -439,7 +522,7 @@ pub(super) fn expand(body: Body, parts: &mut ModuleParts, m: &mut Meter) -> Resu
.get(i)
.ok_or_else(|| invariant("instruction out of range"))?;
match decoded(&inst.kind) {
Some((dir, call)) => {
Some((shape, call)) => {
let [c, ptr, layer] = call.args.as_ref() else {
return Err(invariant("a rate-map call without three operands"));
};
@@ -448,7 +531,7 @@ pub(super) fn expand(body: Body, parts: &mut ModuleParts, m: &mut Meter) -> Resu
out: &mut out,
v: &v,
};
s.decode(dir, c, ptr, layer, m)?;
s.decode(shape, c, ptr, layer, m)?;
}
None => {
let mut kind = inst.kind.clone();
@@ -68,7 +68,8 @@
//! - screen to physical, as the map answers it (Apple's CPU, `physicalCoordinates`, the layer
//! clamped to the map's by the caller): `j` the integer part of `s / 32` clamped to the table's
//! last written entry (`NaN` reading 0); where the entry's boundary byte `b` is not
//! [`NO_BOUNDARY`] and `2·(s - 32·j) ≥ b`, entry `j + 1` instead; the result is
//! [`NO_BOUNDARY`] and `2·(s - 32·j) ≥ b`, `b` read as its low seven bits
//! ([`BOUNDARY_MASK`]), entry `j + 1` instead; the result is
//! `fma(s, scale, O / 256)`, one rounding. Past either end of the screen the first or last
//! tile's line extends without limit;
//! - screen to physical, as a shader answers it (Apple's GPU, `map_screen_to_physical_coordinates`):
@@ -80,7 +81,17 @@
//! `⌈E/32⌉·32 + 32` physical to screen it answers 0 where the data's entries end;
//! - physical to screen: `k` the integer part of `p / 32`, the map's clamped to the table's last
//! written entry, a shader's saturating and unclamped as above, and `(p - offset) · reciprocal`,
//! two roundings.
//! two roundings;
//! - a shader's `uint2` overloads (`.v2i32`): screen to physical answers the `float2` decoder's
//! answer at the pixel's centre, `c + 1/2`, converted to `uint` (its integer part, saturating);
//! physical to screen reads the entry of granule `c >> 5` as the `float2` decoder does and
//! answers the bits of the `float` `(0 - offset) · reciprocal`, two roundings: the coordinate's
//! value is not read, so every coordinate of a granule answers alike and the answer is a
//! `float`'s bits, not a screen coordinate. Measured on an Apple M3 Max under macOS 27.0.1 (our
//! probe `rate_map_integer_overloads`): every coordinate along each axis of four maps (64 by 64
//! of quality 1; 256 by 128 falling to 0.25; 200 by 96 of two layers; 3648 by 1734 falling to
//! 0.3), from 0 to 48 past the larger of the axis's screen and physical extents, at each map's
//! layers and two past them, 20,114 coordinates in all, both overloads, every answer.
//!
//! The shader's operations read Metal's `float` denormals: each operand and result that is
//! denormal is the zero of its sign, and a `NaN` result is Metal's `0x7fc00000` (the translated
@@ -120,10 +131,17 @@ pub const VERTICAL_TO_PHYSICAL: u32 = VERTICAL_TO_SCREEN + TABLE_WORDS;
pub const GRANULARITY: u32 = 32;
/// `1 / GRANULARITY`, exact.
pub const INV_GRANULARITY: f32 = 1.0 / 32.0;
/// `GRANULARITY`'s power of two: a shader's `uint` physical coordinate's granule is the
/// coordinate shifted right this many bits.
pub const GRANULE_SHIFT: u32 = GRANULARITY.trailing_zeros();
/// The largest screen extent the tables hold (512 granules; entry 512 lies past it).
pub const MAX_EXTENT: u32 = LAST_ENTRY * GRANULARITY;
/// A screen-to-physical entry's boundary byte where no tile starts inside its granule.
pub const NO_BOUNDARY: u32 = 0xff;
/// The bits of a boundary byte the decoders compare: its low seven. A boundary is at most 64 half
/// pixels; a byte of `0x80`, which a shader reads only in another table's words (a layer past the
/// map's), compares as 0 on Apple's GPU (measured on an Apple M3 Max, macOS 27.0.1).
pub const BOUNDARY_MASK: u32 = 0x7f;
/// A screen-to-physical entry's second word holds the boundary byte below this many bits.
pub const OFFSET_SHIFT: u32 = 8;
/// The unit of a screen-to-physical entry's offset: `1/256` pixel.
@@ -373,10 +391,10 @@ fn axis_to_physical(words: &[u32], table: u32, s: f32, decoder: Decoder) -> f32
};
let j = decoder.index(t);
let (_, packed) = entry(words, table, j);
let boundary = packed & NO_BOUNDARY;
let (byte, boundary) = (packed & NO_BOUNDARY, packed & BOUNDARY_MASK);
let start = r(j as f32 * GRANULARITY as f32);
let into = r(r(s - start) * 2.0);
let j = if boundary != NO_BOUNDARY && into >= boundary as f32 {
let j = if byte != NO_BOUNDARY && into >= boundary as f32 {
j.wrapping_add(1)
} else {
j
@@ -453,5 +471,27 @@ pub fn shader_physical_to_screen(words: &[u32], layer: u32, c: [f32; 2]) -> [f32
]
}
/// A shader's `uint2` `map_screen_to_physical_coordinates(c, layer)` over parameter data
/// `words`, as Apple's GPU answers it (the module docs): per axis, the `float2` decoder's answer
/// at the pixel's centre, `c + 1/2`, converted to `uint` as a shader converts, saturating.
pub fn shader_screen_to_physical_integer(words: &[u32], layer: u32, c: [u32; 2]) -> [u32; 2] {
let centre = c.map(|v| v as f32 + 0.5);
shader_screen_to_physical(words, layer, centre).map(shader_index)
}
/// A shader's `uint2` `map_physical_to_screen_coordinates(c, layer)` over parameter data
/// `words`, as Apple's GPU answers it (the module docs): per axis, the bits of the `float`
/// `(0 - offset) · reciprocal` of the entry of granule `c >> 5`, the coordinate's own value not
/// read.
pub fn shader_physical_to_screen_integer(words: &[u32], layer: u32, c: [u32; 2]) -> [u32; 2] {
let r = |x| Decoder::Shader.read(x);
let axis = |axis: u32, p: u32| {
let (reciprocal, offset) = entry(words, table(layer, axis, false), p >> GRANULE_SHIFT);
let (reciprocal, offset) = (r(f32::from_bits(reciprocal)), r(f32::from_bits(offset)));
canonical(r(r(0.0 - offset) * reciprocal)).to_bits()
};
[axis(0, c[0]), axis(1, c[1])]
}
#[cfg(test)]
mod tests;
+6 -2
View File
@@ -17,7 +17,11 @@
//! which differs from the CPU's (the granule of the coordinate plus half a pixel, two roundings
//! where the CPU fuses, denormals flushed, the layer unclamped). Measured on an Apple M4: the bytes
//! of 45 maps, and every CPU and GPU answer probed over them, bit for bit, the sign of a zero
//! included. The translated decoder's `float` arithmetic is the device's: it computes the shader's
//! included. A shader's `uint2` overloads answer as `air::canon::rate_map_data`'s
//! `shader_screen_to_physical_integer` and `shader_physical_to_screen_integer` (measured on an
//! Apple M3 Max): the `float2` decoder at the pixel's centre converted to `uint`, and the bits of
//! a `float` the coordinate's granule gives, not a screen coordinate. The translated decoder's
//! `float` arithmetic is the device's: it computes the shader's
//! answers bit for bit on a device that reads `float` denormals as Metal does, and with the
//! device's own denormals elsewhere (`PrecisionNote::DeviceDenormals`), as the SPIR-V interpreter
//! keeps them. The buffer is then bound like any other ([`BoundBuffer::Buffer`]).
@@ -800,4 +804,4 @@ pub use regions::{RateMapRegion, RateMapRegions, RegionError, RegionLimits};
mod tests;
#[cfg(test)]
mod apple_tests;
pub(crate) mod apple_tests;
File diff suppressed because it is too large. Load diff
@@ -3,7 +3,8 @@
//! and GPU answers, bit for bit, the sign of a zero and a `NaN`'s bits included: inside the screen,
//! in the half pixel before a tile boundary at a multiple of 32, past both ends, at denormals,
//! `NaN`s, infinities and far values, at offsets that lie near a half step, and a shader's layers 1
//! to 5 over the bytes followed by a pattern.
//! to 5 over the bytes followed by a pattern. A shader's `uint2` answers, measured on an Apple M3
//! Max by our probe `rate_map_integer_overloads`, are `apple_integer_vectors.txt`.
use super::*;
use crate::air::canon::rate_map_data as format;
@@ -11,6 +12,8 @@ use sha2::{Digest, Sha256};
use std::collections::BTreeMap;
const VECTORS: &str = include_str!("apple_vectors.txt");
/// A shader's `uint2` answers on an Apple M3 Max (the file's header has its format).
pub(crate) const INTEGER_VECTORS: &str = include_str!("apple_integer_vectors.txt");
/// The words past the parameter data in the probe's padded buffer: word `i` of the buffer.
fn pattern(i: u32) -> u32 {
@@ -35,7 +38,7 @@ fn sha(bytes: &[u8]) -> String {
}
/// The descriptor of a vector line's layers: `h:...|v:...` per layer, `;` between, `-` for none.
fn descriptor(width: &str, height: &str, layers: &str) -> RateMapDescriptor {
pub(crate) fn descriptor(width: &str, height: &str, layers: &str) -> RateMapDescriptor {
let size = |v: &str| v.parse::<u32>().expect("extent");
let mut d = RateMapDescriptor::new([size(width), size(height)]);
if layers != "-" {
@@ -125,6 +128,58 @@ fn metals_bytes_and_answers() {
);
}
/// A shader's `uint2` maps answer as Metal's, bit for bit, over each measured map's bytes, which
/// are Metal's (`apple_integer_vectors.txt`, an Apple M3 Max under macOS 27.0.1): screen to
/// physical the `float2` decoder's answer at the pixel's centre converted to `uint`, physical to
/// screen the bits of a `float` the granule's entry gives, at the maps' layers and two past them.
#[test]
fn metals_integer_answers() {
let mut maps = BTreeMap::new();
let (mut points, mut mismatches) = (0usize, Vec::new());
for line in INTEGER_VECTORS.lines().filter(|l| !l.starts_with('#')) {
let f: Vec<&str> = line.split_whitespace().collect();
match f.as_slice() {
["map", id, width, height, layers, want] => {
let map = RasterizationRateMap::new(&descriptor(width, height, layers))
.unwrap_or_else(|e| panic!("{id}: {e}"));
assert_eq!(
sha(&map.to_bytes()),
*want,
"{id}: the bytes are not Metal's"
);
maps.insert(id.to_string(), map);
}
[id, layer, axis, input, to_physical, to_screen] => {
let words = maps[*id].words();
let number = |v: &str| v.parse::<u32>().expect("number");
let (layer, axis) = (number(layer), number(axis) as usize);
let mut c = [0u32; 2];
c[axis] = number(input);
let got = [
format::shader_screen_to_physical_integer(words, layer, c)[axis],
format::shader_physical_to_screen_integer(words, layer, c)[axis],
];
let want = [
number(to_physical),
u32::from_str_radix(to_screen, 16).expect("bits"),
];
points += 1;
if got != want {
mismatches.push(format!("{line}: got {} {:08x}", got[0], got[1]));
}
}
other => panic!("{other:?}"),
}
}
assert_eq!(points, 1561, "the file's answers, every one read");
assert!(
mismatches.is_empty(),
"{} of {points} answers are not Metal's:\n{}",
mismatches.len(),
mismatches[..mismatches.len().min(20)].join("\n")
);
}
/// A reset to and from a map of a zero screen extent writes Metal's words (an Apple M3 Max under
/// macOS 27.0.1, our probe `vec`, one map per process): a 64 by 64 map of quality 0.5 reset to 0
/// by 64 keeps the entries the narrower map does not write, and the same map reset the other way
@@ -52,9 +52,8 @@
//! - **Pull-model interpolation** (`interpolate`): each `interpolate_at_*` call of an
//! `interpolant` reads the interpolant's variable where it says (`stage_io::interpolate`); the
//! interpolant itself is planned by `lower::stage_io`.
//! - Refused: the `uint2` overloads of `map_screen_to_physical_coordinates` and its inverse
//! (canon compiles the `float2` ones to the rate map's decoder; no reading of the
//! physical-to-screen `uint2` one is established).
//! - `map_screen_to_physical_coordinates` and its inverse never reach lowering: canon compiles
//! every overload, `float2` and `uint2`, to the rate map's decoder (`air::canon::rate_map`).
mod color;
mod coverage;
@@ -1016,9 +1015,9 @@ pub fn select(cx: &mut SelectCx<'_>, at: InstId, inst: &Inst) -> Result<Fragment
Ok(FragmentStrategy::Discard)
}
Fragment::Discard => Err(not_lowered()),
// Canon compiled every `float2` map; the `uint2` ones reach here.
// Canon compiled every map, `float2` and `uint2`, to its decoder.
Fragment::MapCoordinates { .. } => {
Err(Unsupported::not_implemented(Feature::RasterizationRateMap).into())
Err(cx.invariant("a rasterization-rate map call canon compiles reached lowering"))
}
Fragment::NumSamples if cx.stage == Stage::Fragment => num_samples(cx, inst, &call.args),
Fragment::NumSamples => Err(not_lowered()),
@@ -20,7 +20,8 @@
//! The kernel is the shape Apple's compiler emits for
//! `out[tid] = float4(dec.map_screen_to_physical_coordinates(in[tid], layer),
//! dec.map_physical_to_screen_coordinates(in[tid], layer))` (fast math, denormals off).
//! `llvm-as` assembles it; without it the tests skip visibly.
//! `llvm-as` assembles it; without it the tests skip visibly. The `uint2` overloads are
//! `integer`'s.
use std::sync::atomic::{AtomicU64, Ordering};
@@ -39,6 +40,8 @@ use crate::pipeline::testing::{
use crate::pipeline::PrecisionNote;
use crate::spirv::interp::{run, Buffer, Config, Resources};
mod integer;
const PROFILES: [&str; 4] = [
"moltenvk-m3",
"lunarg-desktop-baseline-2023",
@@ -146,9 +149,10 @@ fn kept(words: &[u32], layer: u32, c: [f32; 2], to_physical: bool) -> [f32; 2] {
return (x - f32::from_bits(offset)) * f32::from_bits(reciprocal);
}
let j = format::shader_index((x + format::SHADER_GRANULE_OFFSET) * format::INV_GRANULARITY);
let boundary = entry(table, j).1 & format::NO_BOUNDARY;
let packed = entry(table, j).1;
let (byte, boundary) = (packed & format::NO_BOUNDARY, packed & format::BOUNDARY_MASK);
let into = (x - j as f32 * format::GRANULARITY as f32) * 2.0;
let j = if boundary != format::NO_BOUNDARY && into >= boundary as f32 {
let j = if byte != format::NO_BOUNDARY && into >= boundary as f32 {
j.wrapping_add(1)
} else {
j
@@ -0,0 +1,244 @@
//! The `uint2` overloads end to end, in the fixture `rate_map_integer` (compiled from our MSL by
//! `scripts/regen-air-fixtures`): its kernel and its fragment function compile on every tested
//! profile, pass L3 and record no `RasterizationRateMap` note. On the CPU interpreter, which keeps
//! `float` denormals as lavapipe does, the kernel answers what `rate_map_data`'s shader decoders
//! compute with denormals kept ([`kept_integer`]), for every layer and two past a map's, inside
//! the screen, at and around each multiple of 32, past both extents and, under the in-shader
//! containment encoding, at far coordinates; where no denormal arises, that is Metal's answer
//! (`shader_screen_to_physical_integer` and `shader_physical_to_screen_integer`, measured on an
//! Apple M3 Max).
use super::*;
const FIXTURE: &str = "../metal2vulkan-validation/fixtures/public/engine/rate_map_integer.ll";
/// The fixture's module, assembled; `None` (the test skips visibly) without `llvm-as`.
fn fixture() -> Option<Vec<u8>> {
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(FIXTURE);
assemble(&std::fs::read_to_string(path).expect("the fixture"))
}
/// A shader's `uint2` map of `c` over parameter data `words` in layer `layer`, to physical
/// coordinates if `to_physical`, as the translated decoder computes it on a device that keeps
/// `float` denormals: screen to physical the `float2` decoder's arithmetic ([`kept`]) at the
/// pixel's centre, converted saturating; physical to screen the bits of `(0 - offset) ·
/// reciprocal` of granule `c >> 5`'s entry, IEEE `f32`, a read past the words 0.
fn kept_integer(words: &[u32], layer: u32, c: [u32; 2], to_physical: bool) -> [u32; 2] {
if to_physical {
let centre = c.map(|v| v as f32 + 0.5);
return kept(words, layer, centre, true).map(format::shader_index);
}
let word = |i: u32| words.get(i as usize).copied().unwrap_or(0);
let axis = |axis: u32, p: u32| {
let at = format::table(layer, axis, false)
.wrapping_add((p >> format::GRANULE_SHIFT).wrapping_mul(format::ENTRY_WORDS));
let (reciprocal, offset) = (word(at), word(at.wrapping_add(1)));
((0.0 - f32::from_bits(offset)) * f32::from_bits(reciprocal)).to_bits()
};
[axis(0, c[0]), axis(1, c[1])]
}
/// Bit for bit; a physical-to-screen answer that is a `NaN`'s bits matches any `NaN`'s (the
/// module leaves a `NaN`'s bits to the device, which the interpreter does not model).
fn same_answer(got: [u32; 4], want: [u32; 4]) -> bool {
let nan = |b: u32| f32::from_bits(b).is_nan();
got[..2] == want[..2]
&& (got[2..].iter())
.zip(&want[2..])
.all(|(&g, &w)| g == w || (nan(g) && nan(w)))
}
/// The coordinates every map is decoded at: the first granule's, each multiple of 32 and its
/// neighbours past both extents, and (`far`) coordinates whose index reads far past the words.
fn integer_points(screen: [u32; 2], far: bool) -> Vec<[u32; 2]> {
let reach = screen[0].max(screen[1]) + 96;
let mut out: Vec<[u32; 2]> = (0..34).map(|i| [i, 33 - i]).collect();
for edge in (32..reach).step_by(32) {
for (i, c) in [edge - 1, edge, edge + 1].into_iter().enumerate() {
out.push([c, reach - c + i as u32]);
}
}
if far {
out.extend([[16_383, 1 << 20], [1 << 24, 7], [u32::MAX, 1 << 31]]);
}
out
}
fn uints(c: &[[u32; 2]]) -> Vec<u8> {
c.iter()
.flat_map(|p| p.iter().flat_map(|v| v.to_le_bytes()))
.collect()
}
/// Both `uint2` maps of every layer, as the shader decoders' arithmetic computes them with the
/// device's denormals ([`kept_integer`]), on every profile, with no `RasterizationRateMap` note;
/// Metal's answers at every point of a map's own layers.
#[test]
fn the_integer_maps_answer_as_metal() {
let Some(bc) = fixture() else {
return;
};
let (mut metals, mut apart) = (0, 0);
for stem in PROFILES {
for robust in [true, false] {
let what = format!("{stem} robust={robust}");
let p = profile_with(stem, robust);
for entry in ["rate_map_integer", "rate_map_integer_pixel"] {
let a = compile(&bc, entry, &p).unwrap_or_else(|e| panic!("{what} {entry}: {e}"));
assert!(
!a.precision.contains(&PrecisionNote::RasterizationRateMap),
"{what} {entry}: {:?}",
a.precision
);
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what} {entry}: L3: {e}"));
}
let (plan, m) = typed_module(&bc, "rate_map_integer", &p).expect("module");
for (name, map) in maps() {
let words = map.words();
// Robust descriptors contain a far read on a device, which the interpreter traps
// on (the module docs), so with them only the near points run.
let pts = integer_points(map.screen_size(), !robust);
for layer in 0..map.layer_count() + 2 {
let res = Resources {
buffers: vec![
bound(0, &map.to_bytes()),
bound(1, &uints(&pts)),
bound(2, &vec![0u8; pts.len() * 16]),
bound(3, &layer.to_le_bytes()),
],
push: push_bytes(&plan),
spec: Default::default(),
};
let cfg = Config {
workgroups: [pts.len() as u32, 1, 1],
..Config::default()
};
let out = run(&m, &cfg, res).unwrap_or_else(|e| panic!("{what}: {e:?}"));
for (i, &c) in pts.iter().enumerate() {
let mut got = [0u32; 4];
for (k, b) in out.buffers[2][i * 16..i * 16 + 16].chunks(4).enumerate() {
got[k] = u32::from_le_bytes([b[0], b[1], b[2], b[3]]);
}
let [s, t] = [true, false].map(|to| kept_integer(words, layer, c, to));
let want = [s[0], s[1], t[0], t[1]];
assert!(
same_answer(got, want),
"{what}: {name} layer {layer} at {c:?}: {got:x?}, kept {want:x?}"
);
let [s, t] = [
format::shader_screen_to_physical_integer(words, layer, c),
format::shader_physical_to_screen_integer(words, layer, c),
];
if same_answer(want, [s[0], s[1], t[0], t[1]]) {
metals += 1;
} else {
assert!(
layer >= map.layer_count(),
"{what}: {name} layer {layer} at {c:?}: {want:x?}, Metal's \
{s:?} {t:x?}"
);
apart += 1;
}
}
}
}
}
}
// Both kinds of point were decoded, so neither comparison is vacuous.
assert!(
metals > 0 && apart > 0,
"{metals} points Metal's, {apart} apart"
);
}
/// The translated kernel answers Metal's recorded `uint2` answers (`apple_integer_vectors.txt`,
/// an Apple M3 Max under macOS 27.0.1) at every recorded point of each map's own layers, on the
/// CPU interpreter, every tested profile: screen to physical and physical to screen, bit for bit.
/// The points of layers past a map's read other tables' words, whose `float`s may be denormal,
/// which the interpreter keeps where Metal flushes them (the device's own denormals,
/// `PrecisionNote::DeviceDenormals`); [`the_integer_maps_answer_as_metal`] holds them to the
/// decoder's arithmetic instead.
#[test]
fn the_translated_integer_maps_answer_metals_recorded_answers() {
use crate::bind::rate_map::apple_tests::{descriptor, INTEGER_VECTORS};
use std::collections::BTreeMap;
let Some(bc) = fixture() else {
return;
};
// Each map, and its recorded points by layer: the axis, the coordinate and both answers.
let mut maps: BTreeMap<&str, RasterizationRateMap> = BTreeMap::new();
let mut points: BTreeMap<(&str, u32), Vec<(usize, u32, [u32; 2])>> = BTreeMap::new();
for line in INTEGER_VECTORS.lines().filter(|l| !l.starts_with('#')) {
let f: Vec<&str> = line.split_whitespace().collect();
let number = |v: &str| v.parse::<u32>().expect("number");
match f.as_slice() {
["map", id, width, height, layers, _] => {
let map = RasterizationRateMap::new(&descriptor(width, height, layers))
.unwrap_or_else(|e| panic!("{id}: {e}"));
maps.insert(id, map);
}
[id, layer, axis, input, to_physical, to_screen] => {
let to_screen = u32::from_str_radix(to_screen, 16).expect("bits");
let point = (
number(axis) as usize,
number(input),
[number(to_physical), to_screen],
);
points.entry((id, number(layer))).or_default().push(point);
}
other => panic!("{other:?}"),
}
}
let mut compared = 0usize;
for stem in PROFILES {
let p = profile_with(stem, false);
let (plan, m) = typed_module(&bc, "rate_map_integer", &p).expect("module");
for (&(id, layer), recorded) in &points {
let map = &maps[id];
if layer >= map.layer_count() {
continue;
}
let coordinates: Vec<[u32; 2]> = (recorded.iter())
.map(|&(axis, c, _)| {
let mut at = [0u32; 2];
at[axis] = c;
at
})
.collect();
let res = Resources {
buffers: vec![
bound(0, &map.to_bytes()),
bound(1, &uints(&coordinates)),
bound(2, &vec![0u8; coordinates.len() * 16]),
bound(3, &layer.to_le_bytes()),
],
push: push_bytes(&plan),
spec: Default::default(),
};
let cfg = Config {
workgroups: [coordinates.len() as u32, 1, 1],
..Config::default()
};
let out = run(&m, &cfg, res).unwrap_or_else(|e| panic!("{stem}: {e:?}"));
for (i, &(axis, c, want)) in recorded.iter().enumerate() {
let word = |k: usize| {
let at = i * 16 + k * 4;
let b = &out.buffers[2][at..at + 4];
u32::from_le_bytes([b[0], b[1], b[2], b[3]])
};
let got = [word(axis), word(2 + axis)];
assert_eq!(
got, want,
"{stem}: {id} layer {layer} axis {axis} at {c}: got {got:x?}, Metal's {want:x?}"
);
compared += 1;
}
}
}
// Every recorded point of a map's own layers, on every profile.
assert_eq!(
compared,
587 * PROFILES.len(),
"the recorded points compared"
);
}
@@ -285,38 +285,6 @@ fn imageblocks_are_refused() {
assert_at_instruction(&u, "k");
}
/// The `uint2` rasterization-rate map overloads are refused at the coordinate mapping, in both
/// directions (canon compiles the `float2` ones; no reading of the physical-to-screen `uint2` one
/// is established).
#[test]
fn integer_rasterization_rate_maps_are_refused() {
for name in [
"map_physical_to_screen_coordinates",
"map_screen_to_physical_coordinates",
] {
let text = format!(
"define void @k(ptr addrspace(2) %0, ptr addrspace(1) %1) {{\n %m = call <2 x i32> \
@air.{name}.v2i32.p2i8.i32(<2 x i32> zeroinitializer, ptr addrspace(2) %0, i32 0)\n \
%x = extractelement <2 x i32> %m, i64 0\n store i32 %x, ptr addrspace(1) %1, align \
4\n ret void\n}}\n\ndeclare <2 x i32> @air.{name}.v2i32.p2i8.i32(<2 x i32>, ptr \
addrspace(2), i32)\n\n!air.kernel = !{{!0}}\n!0 = !{{ptr @k, !1, !2}}\n!1 = !{{}}\n\
!2 = !{{!3, !4}}\n!3 = !{{i32 0, !\"air.buffer\", !\"air.location_index\", i32 0, i32 \
1, !\"air.read\", !\"air.address_space\", i32 2, !\"air.arg_type_name\", \
!\"metal::rasterization_rate_map_data\", !\"air.arg_name\", !\"map\"}}\n!4 = !{{i32 \
1, !\"air.buffer\", !\"air.location_index\", i32 1, i32 1, !\"air.read_write\", \
!\"air.address_space\", i32 1, !\"air.arg_type_size\", i32 4, \
!\"air.arg_type_align_size\", i32 4, !\"air.arg_type_name\", !\"uint\", \
!\"air.arg_name\", !\"out\"}}\n"
);
let Some(bc) = assemble(&format!("rate-map-{name}"), &text) else {
return;
};
let u = refusal(&bc, "k");
assert_refused(&u, Feature::RasterizationRateMap);
assert_at_instruction(&u, "k");
}
}
/// A fragment function's threadgroup memory (a `[[threadgroup(0)]]` buffer, which the corpus's
/// splat rasterizers set bits in) is its tile's memory, kept across the render pass: it compiles on
/// every committed profile with `fragmentStoresAndAtomics`, binding the pass's tile memory buffer
@@ -2194,10 +2194,10 @@ engine/px_samplers.ll px_const_linear_zero ok ok ok ok ok ok ok ok ok ok ok ok o
engine/px_samplers.ll px_const_linear_border ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok
engine/quad_shuffle.air.ll quad_shuffle_rotate ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok
engine/quad_shuffle.ll quad_shuffle_rotate ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok
engine/rate_map_integer.air.ll rate_map_integer Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented}
engine/rate_map_integer.air.ll rate_map_integer_pixel Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented}
engine/rate_map_integer.ll rate_map_integer Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented}
engine/rate_map_integer.ll rate_map_integer_pixel Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented} Unsupported{RasterizationRateMap; NotImplemented}
engine/rate_map_integer.air.ll rate_map_integer ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok
engine/rate_map_integer.air.ll rate_map_integer_pixel ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok
engine/rate_map_integer.ll rate_map_integer ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok
engine/rate_map_integer.ll rate_map_integer_pixel ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok
engine/rch_guarded_effects.air.ll rch_guarded_vertex ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok
engine/rch_guarded_effects.air.ll rch_guarded_store ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(FragmentStoresAndAtomics)]]}
engine/rch_guarded_effects.air.ll rch_guarded_atomic ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(FragmentStoresAndAtomics)]]}
Can't render this file because it is too large.
+2 -2
View File
@@ -130,7 +130,7 @@ Columns:
| `Imageblocks` | An imageblock outside the forms implemented | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`missing`); drivers with a defect; every device (not implemented) | `ours` | 10: `crates/metal2vulkan/src/lower/access/imageblock.rs (imageblocks)`, `crates/metal2vulkan/src/lower/access/mod.rs (select_param)` (+7) | `rare`: imageblocks (Apple GPU families) |
| `RayTracing` | | devices without a capability the site computes (`missing`); every device (no Vulkan mechanism); every device (not implemented) | `ours` | 12: `crates/metal2vulkan/src/bind/acceleration.rs (instance_record, 2 sites)`, `crates/metal2vulkan/src/lower/raytracing/mod.rs (instance_count)` (+5) | `rare`: ray tracing (out of scope by ruling) |
| `Tensors` | | every device (not implemented) | `ours` | 2: `crates/metal2vulkan-air/src/canon/matmul2d/synth.rs (refuse)`, `crates/metal2vulkan/src/lower/select.rs (route_air)` | `rare`: shader tensors |
| `RasterizationRateMap` | | devices without VkFeature::MultiViewport; devices without VkFeature::ShaderDrawParameters; devices without VkFeature::ShaderOutputViewportIndex; devices without VkLimit::MaxGeometryTotalOutputComponents; devices without a capability the site computes; devices without a capability the site computes (`vec![Capability::Feature(lacks)]`); every device (not implemented) | `ours` | 7: `crates/metal2vulkan/src/lower/fragment/mod.rs (select)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)` (+2) | `rare`: rasterization rate maps |
| `RasterizationRateMap` | | devices without VkFeature::MultiViewport; devices without VkFeature::ShaderDrawParameters; devices without VkFeature::ShaderOutputViewportIndex; devices without VkLimit::MaxGeometryTotalOutputComponents; devices without a capability the site computes; devices without a capability the site computes (`vec![Capability::Feature(lacks)]`); every device (not implemented) | `ours` | 6: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)`, `crates/metal2vulkan/src/pipeline/link/geometry.rs (check_limits)` (+1) | `rare`: rasterization rate maps |
| `GpuEncodedIndirectCommands` | | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism); every device (not implemented) | `ours` | 20: `crates/metal2vulkan/src/bind/replay.rs (preprocess)`, `crates/metal2vulkan/src/bind/replay.rs (replay_preprocess_module)` (+13) | `rare`: indirect command buffers encoded by a kernel |
| `VulkanVersion` | The device's Vulkan version is below the 1.2 floor | devices without ApiVersion::V1_2 | `device` | 2: `crates/metal2vulkan/src/ash_interop/query.rs (query)`, `crates/metal2vulkan/src/device/derive.rs (with_deviations)` | `none`: a device below Vulkan 1.2 |
| `Constant` | A constants-block record LLVM defines that the typed model has no form for (a block address, a `select` and the other constant expressions of... | - | `-` | via a helper: 3: `crates/metal2vulkan-air/src/bitcode/constants.rs (record, 2 sites)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: LLVM constant forms AIR does not emit |
@@ -655,7 +655,7 @@ Each refusal's sites, with the function that builds it.
- `feature::Imageblocks`: `crates/metal2vulkan/src/lower/access/imageblock.rs (imageblocks)`; `crates/metal2vulkan/src/lower/access/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (plan_tests, 2 sites)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (reach)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (require)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/slice.rs (imageblocks)`; `crates/metal2vulkan/src/pipeline/link/imageblock.rs (fragment_imageblock)`
- `feature::RayTracing`: `crates/metal2vulkan/src/bind/acceleration.rs (instance_record, 2 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (instance_count)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (intersect, 5 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (primitive_data_read)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (slot_of)`; `crates/metal2vulkan/src/lower/select.rs (route_air)`
- `feature::Tensors`: `crates/metal2vulkan-air/src/canon/matmul2d/synth.rs (refuse)`; `crates/metal2vulkan/src/lower/select.rs (route_air)`
- `feature::RasterizationRateMap`: `crates/metal2vulkan/src/lower/fragment/mod.rs (select)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (check_limits)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (fan_plan, 3 sites)`
- `feature::RasterizationRateMap`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (check_limits)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (fan_plan, 3 sites)`
- `feature::GpuEncodedIndirectCommands`: `crates/metal2vulkan/src/bind/replay.rs (preprocess)`; `crates/metal2vulkan/src/bind/replay.rs (replay_preprocess_module)`; `crates/metal2vulkan/src/bind/replay/draws.rs (draw_replay_module)`; `crates/metal2vulkan/src/bind/replay/draws.rs (draw_replay_preprocess)`; `crates/metal2vulkan/src/bind/replay/flat.rs (flat_dispatch_module)`; `crates/metal2vulkan/src/bind/replay/merged.rs (draw_merge_module)`; `crates/metal2vulkan/src/lower/access/encode.rs (needs, 2 sites)`; `crates/metal2vulkan/src/lower/access/encode.rs (select_command)`; `crates/metal2vulkan/src/lower/access/mod.rs (plan_replay, 3 sites)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (plan_partial_groups)`; `crates/metal2vulkan/src/lower/select.rs (finish, 2 sites)`; `crates/metal2vulkan/src/lower/simd/divergent.rs (barriers)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (merged)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`; `crates/metal2vulkan/src/pipeline/compile.rs (plan_one, 2 sites)`
- `feature::VulkanVersion`: `crates/metal2vulkan/src/ash_interop/query.rs (query)`; `crates/metal2vulkan/src/device/derive.rs (with_deviations)`
- `feature::Constant`: `crates/metal2vulkan-air/src/bitcode/constants.rs (record, 2 sites)`; `crates/metal2vulkan/src/error/mod.rs (from)`