Pipeline: behind the agx flag a wider fragment input reads its vertex output's lanes, then zeros

The planner's ruling for the wide case of agx.allow_mismatched_component_counts: Metal
makes a render pipeline whose fragment function reads a varying at more components
than its flagged vertex function writes, and leaves the lanes past the output's
undefined (M3 Max, macOS 27.0.1, job m3-max-87586: 150 such lanes read 147 distinct
values, none written). One form on every device, decided at pipeline make by structure:

- LoweringInputs::widened_varyings (new public field, serde default): the user varyings
  a flagged vertex function writes at fewer lanes than the pipeline's fragment function
  reads, with the count it reads, of the same AIR scalar type. compile_render_pipeline
  and render_variant_key derive it from the two Function stages' specialized entries
  (compile.rs widened_varyings: return-struct field types against fragment-input
  parameter types), only where the vertex entry carries the flag; a Compiled stage on
  either side gives none. render_pipeline compiles the vertex stage, and only where its
  StageIo carries the flag and the set is not empty compiles it again under the set;
  render_variant_key hands it to the vertex inputs, so a runtime's stage-by-stage
  compile under the keys widens too, and the pipeline key matches.
- Planning declares such an output at the read count (StageIo outputs list it so, so
  link matches equal types) and marks its object in StageIoPlan::widened; store writes
  the value's lanes then a constant 0 per extra lane (OpCompositeConstruct). Colour
  outputs, whose declared components may differ from their form for other reasons, are
  never marked.
- The key appends the set only when set: every other function keeps its key.
- Link is unchanged: a wider input behind a vertex function compiled alone stays
  Unsupported{UnmatchedVarying, NotImplemented}, as does a mesh producer; flag 0 or
  absent stays Metal's link error.

Docs: docs/API.md accepted differences gains the line (Metal undefined, we give zeros;
no precision note, per the ruling); the UnmatchedVarying, StageIo and link docs say
where the gap now remains; reach.tsv's line likewise; REFUSALS.md regenerated; the API
signature table blessed (LoweringInputs.widened_varyings); the inputs-encoding and serde
round-trip tests cover the field. SEMANTICS_VERSION stays at 2394 (the narrow
form's bump).

Tests: the red tests of 3f0fa825f4 (jobs m3-max-87655 lavapipe + translator, m3-max-87661
RTX 5080) go green in the jobs named in the READY message.
This commit is contained in:
Anees Iqbal committed 2026-12-04 21:23:45 -08:00
1 parent 3b921fc5eb
commit 255f758265
17 files changed
+261 -21

No files matched your search

+3 -1
View File
@@ -751,7 +751,9 @@ pub enum Feature {
/// vertex or mesh function whose module states `agx.allow_mismatched_component_counts` as 1
/// (`StageIo::mismatched_component_counts`), Metal links (measured for a vertex function).
/// Link places a narrower one behind a vertex function at its output, where the description
/// states `maintenance4`; a wider one, one behind a mesh function, and a narrower one on a
/// states `maintenance4`, and a render pipeline's compile declares a vertex output a wider
/// one reads at its count (`LoweringInputs::widened_varyings`); a wider one behind a vertex
/// function compiled without that, one behind a mesh function, and a narrower one on a
/// description without `maintenance4` are not implemented (`NotImplemented`).
UnmatchedVarying,
/// A vertex buffer layout stepped per instance at a rate above 1, on a profile that fetches
@@ -397,6 +397,10 @@ pub struct StageIoPlan {
/// The color outputs a fragment function compiled under `LoweringInputs::zeroed_colors`
/// stores zero to at every return, one per such color.
pub zeroed: Vec<Link>,
/// The varying objects a vertex function compiled under `LoweringInputs::widened_varyings`
/// declares wider than it writes them: [`store`] writes the value's lanes and 0 in every lane
/// past them.
pub widened: BTreeSet<usize>,
/// The shape of the returned value.
pub returned: Returned,
/// The `PointSize` object a vertex function without a point-size output writes 1.0 to.
@@ -2641,6 +2645,36 @@ fn store(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, link: &Link, x: SVal
} else {
x
};
// A varying declared wider than the value (`LoweringInputs::widened_varyings`): its lanes
// first, 0 in every lane past them.
let sp = &cx.plan.families.stage_io;
let widened = match sp.objects.get(link.object) {
Some(&IoObject::User {
numeric,
components,
..
}) if sp.widened.contains(&link.object) => Some((numeric, components)),
_ => None,
};
let x = match widened {
Some((numeric, components)) if components > link.form.lanes => {
let elem = io_elem(fb.module(), numeric)?;
let zero = fb.module().constant(Constant::Scalar {
ty: elem,
bits: ConstBits(0),
})?;
let zero = fb.module().const_value(zero)?;
let ty = fb.module().ty(SType::Vector {
elem,
len: components,
})?;
let mut parts = vec![x];
parts.resize(usize::from(components - link.form.lanes) + 1, zero);
fb.composite_construct(ty, &parts)?
}
Some(_) => return Err(cx.fail("a varying widened to no more lanes than it holds")),
None => x,
};
match link.place {
Place::Weights { .. } => Err(cx.fail("an output stored through the barycentric weights")),
Place::Whole | Place::Element0 => {
+15 -2
View File
@@ -2708,12 +2708,25 @@ fn output(cx: &mut SelectCx<'_>, o: &OutputBinding, ty: AirTypeId) -> Result<Lin
OutputRole::VertexOutput(k) if vertex => {
let f = varying_form(cx, ty)?;
let key = VaryingKey::user(&k.0);
// Widened to the count the pipeline's fragment function reads
// (`LoweringInputs::widened_varyings`): `store` writes 0 past the value's lanes.
let declared = match cx.inputs.widened_varyings.get(&key) {
Some(&n) if n > f.lanes && n <= 4 => IoType {
components: n,
..io_type(f)
},
Some(_) => return Err(cx.invariant("a varying widened to no more lanes")),
None => io_type(f),
};
let sp = &mut cx.families.stage_io;
let deco = IoDecor {
packed: true,
..IoDecor::default()
};
let object = user(sp, key.clone(), IoDir::Output, io_type(f), deco)?;
let object = user(sp, key.clone(), IoDir::Output, declared, deco)?;
if declared.components > f.lanes {
sp.widened.insert(object);
}
push_var(
&mut sp.interface.outputs,
IoVariable {
@@ -2722,7 +2735,7 @@ fn output(cx: &mut SelectCx<'_>, o: &OutputBinding, ty: AirTypeId) -> Result<Lin
user: AirUserKey(k.0.clone()),
interpolation: None,
},
ty: io_type(f),
ty: declared,
},
);
Link {
@@ -268,6 +268,7 @@ mod serde_round_trips {
rotated_blends: BTreeSet::from([4, 6]),
texture_write_rounding: metal::TextureWriteRoundingMode::NearestEven,
uniform_varyings: BTreeSet::from([VaryingKey::user(b"user(tint)")]),
widened_varyings: BTreeMap::from([(VaryingKey::user(b"user(tint)"), 4)]),
instanced_attributes: BTreeSet::from([1]),
object_payload: Some(64),
region_viewports: true,
+96 -2
View File
@@ -94,12 +94,16 @@ pub enum InputsFrom<'a> {
/// and whether the pipeline state is made for indirect command buffers
/// (`supportIndirectCommandBuffers`): a vertex function then pulls every attribute it reads
/// and tests its command against the execution range (`LoweringInputs::indirect_range`).
/// Last, the varyings the pipeline's fragment function reads wider than the entry writes them
/// ([`widened_varyings`], `LoweringInputs::widened_varyings`); [`NO_WIDENED_VARYINGS`] for
/// none.
Vertex(
Option<&'a VertexDescriptor>,
&'a VariantKey,
u32,
bool,
bool,
&'a BTreeMap<VaryingKey, u8>,
),
/// The fragment stage of this render pipeline under a variant key: the key's fragment-stage
/// inputs, the attachments among the pipeline's color attachments that the specialized entry
@@ -133,6 +137,10 @@ pub enum InputsFrom<'a> {
/// a mesh render pipeline's.
pub(crate) static NO_PRIMITIVE_VARYINGS: BTreeSet<VaryingKey> = BTreeSet::new();
/// No varying widened: a vertex stage's whose fragment function reads none wider
/// ([`InputsFrom::Vertex`]).
pub(crate) static NO_WIDENED_VARYINGS: BTreeMap<VaryingKey, u8> = BTreeMap::new();
/// The pipeline state a fragment stage compiles under ([`InputsFrom::Fragment`]): its render
/// pipeline's, or its mesh render pipeline's, which has no call stack depth of its own (Metal's
/// default, 1).
@@ -1643,6 +1651,90 @@ pub(crate) fn reads_primitive_id_varying(
})
}
/// A user varying's AIR scalar type and lane count: a scalar's own, or a vector's element and
/// length.
type VaryingShape = (air::ir::Type, u32);
/// The shape of type `ty` of `spec`'s module ([`VaryingShape`]); `None` for a type that is no
/// scalar or vector.
fn varying_shape(spec: &air::Entry, ty: air::ir::TypeId) -> Option<VaryingShape> {
let types = spec.module.types();
match types.get(ty)? {
air::ir::Type::Vector { elem, len } => Some((types.get(*elem)?.clone(), *len)),
t @ (air::ir::Type::Int(_)
| air::ir::Type::Half
| air::ir::Type::BFloat
| air::ir::Type::Float
| air::ir::Type::Double) => Some((t.clone(), 1)),
_ => None,
}
}
/// The user varyings vertex function `spec` writes, by key, with their shapes.
fn written_shapes(spec: &air::Entry) -> BTreeMap<VaryingKey, VaryingShape> {
let types = spec.module.types();
let ret = match spec.module.func(spec.func).and_then(|f| types.get(f.ty)) {
Some(air::ir::Type::Function { ret, .. }) => *ret,
_ => return BTreeMap::new(),
};
let fields: &[air::ir::TypeId] = match types.get(ret) {
Some(air::ir::Type::Struct { fields, .. }) => fields,
_ => std::slice::from_ref(&ret),
};
(spec.ep.outputs.iter())
.filter_map(|o| match &o.role {
OutputRole::VertexOutput(k) => {
let ty = *fields.get(o.field as usize)?;
Some((VaryingKey::user(&k.0), varying_shape(spec, ty)?))
}
_ => None,
})
.collect()
}
/// The user varyings fragment function `spec` reads, by key, with their shapes.
fn read_shapes(spec: &air::Entry) -> BTreeMap<VaryingKey, VaryingShape> {
let types = spec.module.types();
let params: &[air::ir::TypeId] = match spec.module.func(spec.func).and_then(|f| types.get(f.ty))
{
Some(air::ir::Type::Function { params, .. }) => params,
_ => &[],
};
(spec.ep.params.iter())
.filter_map(|p| match &p.role {
ParamRole::FragmentInput(v) => {
let ty = *params.get(p.param as usize)?;
Some((VaryingKey::user(&v.key.0), varying_shape(spec, ty)?))
}
_ => None,
})
.collect()
}
/// The varyings vertex function `vertex` writes at fewer lanes than fragment function `fragment`
/// reads them, of the same scalar type, each with the lanes `fragment` reads
/// (`LoweringInputs::widened_varyings`): decided from the two entries' types alone, and only
/// where `vertex`'s module states `agx.allow_mismatched_component_counts` as 1, under which Metal
/// makes that pipeline (measured). Empty for any other pair.
pub(crate) fn widened_varyings(
vertex: &air::Entry,
fragment: &air::Entry,
) -> BTreeMap<VaryingKey, u8> {
if !vertex.ep.mismatched_component_counts {
return BTreeMap::new();
}
let reads = read_shapes(fragment);
written_shapes(vertex)
.into_iter()
.filter_map(|(key, (elem, lanes))| match reads.get(&key) {
Some((read, n)) if *read == elem && *n > lanes => {
Some((key, u8::try_from(*n).ok().filter(|&n| n <= 4)?))
}
_ => None,
})
.collect()
}
/// Run `g` on the compile request of function `f`. A visible function is not a stage: it is
/// `EntryNotFound`, as for a module that does not declare the entry.
fn with_request<T>(
@@ -2507,7 +2599,7 @@ fn lower_inputs(
match inputs {
InputsFrom::Given(i) => Ok(given_inputs(spec, i)),
// A post-tessellation vertex function pulls every attribute it reads.
InputsFrom::Vertex(desc, variant, depth, primitive_id, indirect)
InputsFrom::Vertex(desc, variant, depth, primitive_id, indirect, widened)
if matches!(spec.ep.stage, AbiStage::Vertex { patch: Some(_) }) =>
{
let attributes = crate::lower::tessellation::attributes_read(spec);
@@ -2521,9 +2613,10 @@ fn lower_inputs(
// A state made for indirect command buffers tests each evaluation's command against
// the execution range, as a plain vertex function tests its vertex's.
out.indirect_range = indirect;
out.widened_varyings = widened.clone();
Ok(key::canonical_inputs(&out))
}
InputsFrom::Vertex(desc, variant, depth, primitive_id, indirect) => {
InputsFrom::Vertex(desc, variant, depth, primitive_id, indirect, widened) => {
let attributes = declared_attributes(spec);
// The primitive ID's de-indexed form, the private list form and a state made for
// indirect command buffers pull every attribute, whatever the caller's projection
@@ -2544,6 +2637,7 @@ fn lower_inputs(
out.primitive_id_varying = primitive_id && primitive_id_varying_on(p);
out.indirect_range = indirect;
out.instanced_attributes = instanced_attributes(spec, &out, desc, m)?;
out.widened_varyings = widened.clone();
Ok(key::canonical_inputs(&out))
}
InputsFrom::Fragment(d, variant, written, primitive, varyings, uniform) => {
@@ -41,7 +41,8 @@ use crate::pipeline::compile::key::{function_key, pipeline_key, queried_render_d
use crate::pipeline::compile::{
compile_stage, compile_stage_from, dynamic_order, guarded, kernel_observes_partition,
linked_keys, primitive_id_varying_on, reads_primitive_id_varying, stage_inputs,
vertex_push_end, FragmentPass, InputsFrom, RawIndices, StageEntries, NO_PRIMITIVE_VARYINGS,
vertex_push_end, widened_varyings, FragmentPass, InputsFrom, RawIndices, StageEntries,
NO_PRIMITIVE_VARYINGS, NO_WIDENED_VARYINGS,
};
use crate::pipeline::descriptor::{
ComputePipelineDescriptor, FunctionDescriptor, MeshPipelineDescriptor,
@@ -360,6 +361,9 @@ impl Device {
)?,
false => false,
};
// The varyings the vertex function writes narrower than the fragment function reads
// them, which it declares wider (`render_pipeline`).
let widened = widened_for(d, entries, &mut Meter::new(b))?;
let from = || {
InputsFrom::Vertex(
d.vertex_descriptor.as_ref(),
@@ -367,6 +371,7 @@ impl Device {
d.max_vertex_call_stack_depth,
primitive_id,
d.support_indirect_command_buffers,
&widened,
)
};
let (vertex, vertex_inputs, written, varyings, uniform, push_end) = match &d.vertex {
@@ -805,7 +810,7 @@ impl Device {
)?,
None => false,
};
let vertex = self.stage(
let mut vertex = self.stage(
&d.vertex,
InputsFrom::Vertex(
d.vertex_descriptor.as_ref(),
@@ -813,9 +818,36 @@ impl Device {
d.max_vertex_call_stack_depth,
primitive_id,
d.support_indirect_command_buffers,
&NO_WIDENED_VARYINGS,
),
m,
)?;
// Behind a vertex function whose module states `agx.allow_mismatched_component_counts`
// as 1, the varyings it writes narrower than the fragment function reads them, which it
// compiles again declaring wider (`LoweringInputs::widened_varyings`), decided from the
// two entries alone.
if vertex.artifact().interface.io.mismatched_component_counts {
let own;
let e = match &entries {
Some(e) => e,
None => {
own = StageEntries::new();
&own
}
};
let widened = widened_for(d, e, m)?;
if !widened.is_empty() {
let inputs = InputsFrom::Vertex(
d.vertex_descriptor.as_ref(),
v,
d.max_vertex_call_stack_depth,
primitive_id,
d.support_indirect_command_buffers,
&widened,
);
vertex = self.stage(&d.vertex, inputs, m)?;
}
}
check_call_stack(vertex.artifact(), d.max_vertex_call_stack_depth)?;
// On the floor the fragment function's push fields follow the vertex function's.
let base = vertex.fragment_push_base();
@@ -1616,6 +1648,28 @@ fn stage_module(c: &CompiledFunction, linked: &Linked, i: usize) -> Result<Stage
})
}
/// The `LoweringInputs::widened_varyings` of render pipeline `d`'s vertex stage: from its
/// `Function` vertex and fragment stages' specialized entries, which `entries` holds or makes now
/// ([`widened_varyings`]); none behind a `Compiled` stage on either side, whose entry is not at
/// hand, so link answers such a pair `Unsupported{UnmatchedVarying, NotImplemented}`.
fn widened_for(
d: &RenderPipelineDescriptor,
entries: &StageEntries,
m: &mut Meter,
) -> Result<std::collections::BTreeMap<VaryingKey, u8>, Error> {
let (StageSource::Function(vertex), Some(StageSource::Function(fragment))) =
(&d.vertex, &d.fragment)
else {
return Ok(std::collections::BTreeMap::new());
};
let vertex = entries.specialized(vertex, d.max_vertex_call_stack_depth, false, m)?;
if !vertex.spec.ep.mismatched_component_counts {
return Ok(std::collections::BTreeMap::new());
}
let fragment = entries.specialized(fragment, d.max_fragment_call_stack_depth, false, m)?;
Ok(widened_varyings(&vertex.spec, &fragment.spec))
}
/// The user varyings `a` writes when it is a vertex function, or a mesh function's per-vertex
/// and per-primitive ones (`LoweringInputs::absent_varyings`).
fn varyings_written(a: &FunctionArtifact) -> std::collections::BTreeSet<VaryingKey> {
@@ -20,7 +20,7 @@ use crate::pipeline::artifact::StrategyUse;
use crate::pipeline::compile::api::CompileReport;
use crate::pipeline::compile::{
census, compile_one, guarded, lower_inputs, ordered_entry, plan_one, specialize_one, EntryRef,
InputsFrom, LinkedSource, Request,
InputsFrom, LinkedSource, Request, NO_WIDENED_VARYINGS,
};
use crate::pipeline::descriptor::VertexDescriptor;
use crate::pipeline::layout::PipelineLayout;
@@ -158,7 +158,14 @@ impl DeviceProfile {
let mut m = Meter::new(budget);
let variant = VariantKey::new();
guarded(|| {
let r = d.request(InputsFrom::Vertex(vertex, &variant, 1, false, false));
let r = d.request(InputsFrom::Vertex(
vertex,
&variant,
1,
false,
false,
&NO_WIDENED_VARYINGS,
));
let spec = specialize_one(&r, &mut m)?.spec;
lower_inputs(&spec, r.inputs, self, &mut m)
})
@@ -405,6 +405,12 @@ pub fn function_key(
h.bytes(b"uniform-varyings")
.bytes(format!("{:?}", inputs.uniform_varyings).as_bytes());
}
// Appended only when set, as `uniform_varyings` (an ordered map of byte keys to counts): a
// vertex function whose fragment function reads none of its varyings wider keeps its key.
if !inputs.widened_varyings.is_empty() {
h.bytes(b"widened-varyings")
.bytes(format!("{:?}", inputs.widened_varyings).as_bytes());
}
// Appended only when set, as `uniform_varyings` (an ordered set of attribute indices): a
// vertex function no per-instance attribute makes write a varying alike keeps its key.
if !inputs.instanced_attributes.is_empty() {
@@ -678,6 +678,7 @@ fn the_inputs_encoding_is_the_earlier_derived_debug() {
.replace(", rotated_blends: {}", "")
.replace(", texture_write_rounding: TowardZero", "")
.replace(", uniform_varyings: {}", "")
.replace(", widened_varyings: {}", "")
.replace(", instanced_attributes: {}", "")
.replace(", object_payload: None", "")
.replace(", tessellation: None", "")
@@ -13,8 +13,12 @@
//! components reads the output's first lanes, as Metal's does (measured), and takes the
//! output's location and component: Vulkan matches it there under `maintenance4`, which the
//! runtime's floor enables, and a description without it is this translator's gap
//! (`UnmatchedVarying`, `NotImplemented`). An input of more components, or any behind a mesh
//! function, is that gap too. Unmatched vertex outputs stay (legal in both APIs). A fragment function alone numbers its inputs densely in declaration order.
//! (`UnmatchedVarying`, `NotImplemented`). An input of more components never reaches link from
//! a render pipeline's compile, whose vertex function declares such an output at the input's
//! count, 0 in the lanes past its own (`LoweringInputs::widened_varyings`); behind a vertex
//! function compiled without that, and any behind a mesh function, it is that gap too.
//! Unmatched vertex outputs stay (legal in both APIs). A fragment function alone numbers its
//! inputs densely in declaration order.
//! The raw viewport index (`IoRole::ViewportIndex`) is such a varying, of its own key, which the
//! fragment stage reads flat: one more flat input component under the limits below. A fragment
//! function reads it exactly when compiled for a vertex function that writes
@@ -87,7 +91,7 @@ fn invariant(detail: &str) -> Error {
/// The refusal of fragment input `input` of type `read` whose producer `producer` writes its key
/// as `written` (`None`: not at all): Metal's link error, but for a type that differs in
/// component count alone behind a producer of [`StageIo::mismatched_component_counts`], which
/// Metal links and this translator does not yet (see the module docs).
/// Metal links and this translator does not here (see the module docs).
fn unmatched(producer: &StageIo, written: Option<IoType>, read: IoType) -> Error {
if written.is_some_and(|w| counts_alone(w, read)) && producer.mismatched_component_counts {
Unsupported::not_implemented(Feature::UnmatchedVarying).into()
@@ -641,6 +641,21 @@ pub struct LoweringInputs {
/// any other function.
#[cfg_attr(feature = "serde", serde(default))]
pub uniform_varyings: BTreeSet<VaryingKey>,
/// The user varyings a vertex function whose module states
/// `agx.allow_mismatched_component_counts` as 1 (`StageIo::mismatched_component_counts`)
/// writes at fewer components than its render pipeline's fragment function reads them, each
/// with the count the fragment function reads, of the same scalar type: the function declares
/// each such output at that count, its own lanes first and 0 in every lane past them, and
/// lists it so among its `StageIo::outputs`, so the two match. Metal makes that pipeline, and
/// its input reads values past the output's lanes that are no constant (measured on an Apple
/// M3 Max, job m3-max-87586): Metal defines none, so the 0 there emulates nothing
/// (docs/API.md, Accepted differences). `Device::compile_render_pipeline` and
/// `Device::render_variant_key` set it for a `Function` vertex stage behind a `Function`
/// fragment stage, from the two specialized entries' types; behind a vertex function compiled
/// without it, link answers such a pipeline `Unsupported{UnmatchedVarying, NotImplemented}`.
/// Empty for any other function.
#[cfg_attr(feature = "serde", serde(default))]
pub widened_varyings: BTreeMap<VaryingKey, u8>,
/// The attributes, by Metal attribute index, that the vertex function fetches in fixed
/// function from layouts its vertex descriptor steps per instance, which every vertex of one
/// instance (so of one primitive) reads alike; set only where one of them makes a varying the
+6 -4
View File
@@ -347,10 +347,12 @@ pub struct StageIo {
/// makes a render pipeline whose fragment function reads one of the function's user
/// varyings at another component count than the function writes (measured for a vertex
/// function). Behind a vertex function link places a narrower input at its output, which
/// Vulkan matches under `maintenance4` (`pipeline::link`'s varyings), and answers a wider one,
/// or either behind a mesh function, `Unsupported{UnmatchedVarying, NotImplemented}`; the same
/// mismatch behind a function without it is Metal's link error, `NotRepresentable`. False for
/// every other function.
/// Vulkan matches under `maintenance4` (`pipeline::link`'s varyings); a render pipeline's
/// compile declares the output a wider input reads at the input's count
/// (`LoweringInputs::widened_varyings`), and link answers a wider one behind a vertex
/// function compiled without that, or either behind a mesh function,
/// `Unsupported{UnmatchedVarying, NotImplemented}`; the same mismatch behind a function
/// without it is Metal's link error, `NotRepresentable`. False for every other function.
#[cfg_attr(feature = "serde", serde(default))]
pub mismatched_component_counts: bool,
}
@@ -221,9 +221,10 @@ fn location(a: &FunctionArtifact, words: &[u32], key: &VaryingKey) -> u32 {
/// A vertex function whose module states the agx flag as 1 carries it to its stage interface
/// (`StageIo::mismatched_component_counts`); one stating 0 or nothing, and a fragment function,
/// do not. Without it, a fragment function reading the varying at another component count, wider
/// or narrower, is Metal's link error (`NotRepresentable`); behind it a wider one is this
/// translator's gap (`Unsupported{UnmatchedVarying, NotImplemented}`), whose lanes past the
/// output's Metal leaves undefined. At the same count it links, flag or not.
/// or narrower, is Metal's link error (`NotRepresentable`); behind it a wider one, linked from
/// stages compiled alone, is this translator's gap (`Unsupported{UnmatchedVarying,
/// NotImplemented}`): only a render pipeline's compile declares the output at the input's count.
/// At the same count it links, flag or not.
#[test]
fn the_agx_flag_reaches_link_and_a_wider_input_is_our_gap() {
let p = profile("lavapipe").expect("profile");
@@ -2623,6 +2623,7 @@ field metal2vulkan::pipeline::LoweringInputs.unattached_colors pub unattached_co
field metal2vulkan::pipeline::LoweringInputs.uniform_varyings pub uniform_varyings: BTreeSet<VaryingKey>
field metal2vulkan::pipeline::LoweringInputs.vertex_fetch pub vertex_fetch: Option<VertexFetchProjection>
field metal2vulkan::pipeline::LoweringInputs.viewport_index_varying pub viewport_index_varying: bool
field metal2vulkan::pipeline::LoweringInputs.widened_varyings pub widened_varyings: BTreeMap<VaryingKey, u8>
field metal2vulkan::pipeline::LoweringInputs.word_bound_buffers pub word_bound_buffers: BTreeSet<SlotRef>
field metal2vulkan::pipeline::LoweringInputs.word_colors pub word_colors: BTreeMap<u32, metal::format::WordAttachment>
field metal2vulkan::pipeline::LoweringInputs.zeroed_colors pub zeroed_colors: BTreeMap<u32, metal::PixelFormat>
Can't render this file because it is too large.
+5
View File
@@ -2789,6 +2789,11 @@ named states the rule in full.
27.0.1) refuses it outside the private OpenGL mode with "depthAttachmentPixelFormat is not valid
and shader writes to depth" (the probe `metal2vulkan-conformance/probes/opengl_mode.m`), a
refusal no Metal document states (`MTLRenderPipeline.h`, `depthAttachmentPixelFormat`).
- **A fragment input wider than its vertex output reads 0 in the lanes past the output's**, behind
a vertex function whose module states `agx.allow_mismatched_component_counts` as 1
(`LoweringInputs::widened_varyings`). Metal makes that pipeline and leaves those lanes
undefined: measured on an Apple M3 Max (macOS 27.0.1, job m3-max-87586), 150 such lanes read
147 distinct values, none of them written by the function.
**Resource IDs and identifiers**
+1 -1
View File
@@ -115,7 +115,7 @@ Columns:
| `DivergentInterpolation` | Metal's pull-model interpolation at a sample or an offset (`interpolate_at_sample`, `interpolate_at_offset`) outside the fragment function's first... | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant_reads)` | `rare`: an interpolant read at a sample or an offset in a branch, a loop or after a discard |
| `PixelCoverageAtSampleRate` | The pixel's coverage (`[[sample_mask]]` read) in a fragment function that runs once per sample | every device (no Vulkan mechanism); every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/simd/mod.rs (select_param)`, `crates/metal2vulkan/src/pipeline/link/graphics.rs (sample_invocations)` | `rare`: coverage read at sample rate |
| `InterfaceComponents` | Too many interface components or locations | devices short of a device limit the site names; devices without VkLimit::MaxColorAttachments; devices without VkLimit::MaxVertexInputAttributes | `device` | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state)`, `crates/metal2vulkan/src/pipeline/link/varyings.rs (assign)` (+1) | `rare`: too many varyings or attachments for a device |
| `UnmatchedVarying` | A fragment input without a vertex or mesh output of its key and type | every device (no Vulkan mechanism); every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/pipeline/link/varyings.rs (unmatched, 2 sites)`, `crates/metal2vulkan/src/pipeline/link/varyings.rs (varyings)` | `rare`: a varying read at another component count than written, behind a vertex module stating agx.allow_mismatched_component_counts as 1 (seen in modules Apple's Metal shader converter wrote); otherwise a Metal link error |
| `UnmatchedVarying` | A fragment input without a vertex or mesh output of its key and type | every device (no Vulkan mechanism); every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/pipeline/link/varyings.rs (unmatched, 2 sites)`, `crates/metal2vulkan/src/pipeline/link/varyings.rs (varyings)` | `rare`: a varying read wider than written behind a vertex function compiled alone, or at another component count behind a mesh function, under agx.allow_mismatched_component_counts as 1 (seen in modules Apple's Metal shader converter wrote); otherwise a Metal link error |
| `VertexStepRate` | A vertex buffer layout stepped per instance at a rate above 1, on a profile that fetches every attribute in fixed function (the identity domains,... | devices without a capability the site computes (`needs`) | `device` | 1: `crates/metal2vulkan/src/metal/vertex.rs (divided)` | `app`: instanced vertex layouts stepped at a rate above 1 |
| `VertexInputLayout` | A vertex attribute whose layout fixed-function input cannot fetch, on a profile that fetches every attribute in fixed function (the identity... | devices without a capability the site computes (`limit`); every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/pipeline/link/vertex.rs (resolve, 4 sites)` | `rare`: vertex offsets or strides off their format's alignment, or past a device's limits |
| `Tessellation` | Tessellation | devices without VkFeature::TessellationShader; devices without VkLimit::MaxTessellationGenerationLevel; every device (not implemented) | `ours` | 5: `crates/metal2vulkan-air/src/canon/mod.rs (post_check, 2 sites)`, `crates/metal2vulkan/src/error/mod.rs (tessellation)` (+2) | `rare`: tessellation |
+1 -1
View File
@@ -65,7 +65,7 @@ feature PullModelInterpolation rare interpolant inputs read at the centroid, a s
feature DivergentInterpolation rare an interpolant read at a sample or an offset in a branch, a loop or after a discard
feature PixelCoverageAtSampleRate rare coverage read at sample rate
feature InterfaceComponents rare too many varyings or attachments for a device
feature UnmatchedVarying rare a varying read at another component count than written, behind a vertex module stating agx.allow_mismatched_component_counts as 1 (seen in modules Apple's Metal shader converter wrote); otherwise a Metal link error
feature UnmatchedVarying rare a varying read wider than written behind a vertex function compiled alone, or at another component count behind a mesh function, under agx.allow_mismatched_component_counts as 1 (seen in modules Apple's Metal shader converter wrote); otherwise a Metal link error
feature VertexStepRate app instanced vertex layouts stepped at a rate above 1
feature VertexInputLayout rare vertex offsets or strides off their format's alignment, or past a device's limits
feature Tessellation rare tessellation
Can't render this file because it contains an unexpected character in line 17 and column 65.