level.rs stated Metal's rule as "every sampler magnifies where L + q is 0", with L + q taken after
the clamp into the texture's levels, and left a texture of one level unmeasured. A Metal probe of
the Apple M3 Max on macOS 27.0.1 (job m3-max-87718) measured it: a 16 x 4 rgba8Unorm texture of
one level, through runtime samplers without a mip filter whose filters differ (min nearest / mag
linear and the reverse), at level() and a kernel's bias() of -2, -0.5, 0, 1/64, 1/4, 1/2, 1, 2 and
5, 60 positions each, takes the magnification filter at -2, -0.5 and 0 and the minification
filter at every level from 1/64 up. The stated rule would have magnified at every level. So the
choice reads the level after the half rounding and the sampler's clamp, before the clamp into
the texture's levels. On a texture of more than one level the two readings agree, so the 2,230-
level probes the module cites still hold.
Comment-only. No code takes this choice where the module reads texels itself: an extended-range
sample's constexpr sampler with differing filters is refused, and a runtime word with mixed
filters reads nearest (extended's open gap). The device path follows Vulkan's rule (λ after the
sampler's [minLod, maxLod], before the view's levels), which the device paragraph now says matches
Metal's choice. No translation changes, so SEMANTICS_VERSION stays. level.rs is not a
runtime-sources input: pin-compute.py on this tree prints the committed e8f7cd09...6798, so
the pin does not move.
The golden table re-blessed at 6495aabffd (varyflag step 2 rebased on step 1's 47c09be7ae), on
the Apple M3 Max, job m3-max-87793 (inventory, golden, printouts, linkhalf and chains each exit 0):
- the semantics line moves 2393 -> 2394, step 2's own number (2392 at that bless, renumbered
when the stack moved onto pin AB');
- no cell moves and no row is added.
scripts/api-docs (ci-gaps leg m3-max-87688 at ae5f9bcd2f) refuses a lab job id in docs/API.md's
prose: the measurement is stated by its card and OS (Apple M3 Max, macOS 27.0.1 26A434); the
job, m3-max-87586, stays in the commit messages.
clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd (job m3-max-87679 at ae5f9bcd2f) refused
chunks_exact with a constant size in mismatched_varyings (clippy::chunks_exact_with_const_size,
-D warnings). The texels are read as words, then as four-word arrays, both by as_chunks.
Verified by the rerun of both clippy configurations and the lavapipe run of the test in
the job named in the READY message.
serde_round_trips::lower_inputs failed at 5ab16afb13 (job m3-max-87672, on the
translator suite's focused run): JSON refuses a map whose keys are VaryingKey ("key
must be a string"). The field takes serde_pairs, with its default, as extended_range
and storage_images do.
Verified by the same job's rerun in the suites job named in the READY message.
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.
The planner's ruling for the wide case of agx.allow_mismatched_component_counts: Metal
makes the pipeline and leaves the lanes past the vertex output's undefined (M3 Max,
macOS 27.0.1, job m3-max-87586: 150 such lanes read 147 distinct values), so the vertex
function declares the output at the count the fragment function reads, decided at
pipeline make from the two entries, and writes 0 in every lane past its own.
Two tests, red until that form lands:
- engine_converter_module_flags: on lavapipe's profile, compile_render_pipeline of a
flagged vertex function writing 1 to 3 lanes behind a fragment function reading 2 to
4 (float perspective, no-perspective, flat; uint and int flat) compiles; every stage
passes L3; the vertex Output and fragment Input at the varying's Location have the
input's count; the stored composite carries a constant 0 for each lane past the
output's; the pipeline's key is render_pipeline_key's. Flag 0 stays Metal's link
error.
- metal2vulkan-runtime mismatched_varyings (device cfg): the same classes drawn into a
32-bit target of the class on every device: the output's lanes exact, 0 past them,
the fragment's sentinel past the input's; the narrow rows (4 to 2, 3 to 1) read the
output's first lanes.
Red expected: the wide rows fail with Unsupported{UnmatchedVarying, NotImplemented}.
Metal makes a render pipeline whose fragment function reads a user varying at
fewer components than the vertex function writes when the vertex module states
agx.allow_mismatched_component_counts as 1, and the input reads the output's
first lanes (Apple M3 Max, macOS 27.0.1, job m3-max-87586: 90 rows of float
under perspective, center_no_perspective and flat, uint and int flat). Link
answered it Unsupported{UnmatchedVarying, NotImplemented}.
Link now matches such an input to its output (reads_first_lanes: the same
class, fewer components, a vertex function of
StageIo::mismatched_component_counts, a description stating maintenance4), so
the input takes the output's location and component. Vulkan matches an input
of fewer components there under maintenance4 (spec 19.1.3; without it
VUID-RuntimeSpirv-maintenance4-06817 forbids it), which the runtime's floor
requires and enables: one form on every device, no query. A description without
maintenance4 keeps the gap, as do a wider input and any mismatch behind a mesh
function. No module changes: the fragment's input keeps its own width.
Docs: the varyings module docs, StageIo::mismatched_component_counts and
Feature::UnmatchedVarying say so. SEMANTICS_VERSION 2394 (a refusal becomes a
link).
The draw probe (Apple M3 Max, macOS 27.0.1, job m3-max-87586) measured that a
fragment input narrower than its vertex output reads the output's first lanes
when the vertex module states agx.allow_mismatched_component_counts as 1, for
float under perspective, center_no_perspective and flat interpolation and for
uint and int flat. Vulkan matches exactly that under maintenance4 (spec 19.1.3,
Interface Matching: "if the maintenance4 feature is enabled, they are declared
as OpTypeVector variables, and the output has a Component Count value higher
than that of the input but the same Component Type"; without it
VUID-RuntimeSpirv-maintenance4-06817 forbids it). The runtime's floor requires
and enables maintenance4 (Vulkan 1.3), so this is one form on every device.
The tests:
- link: a narrower vector or scalar input, float or uint, smooth or flat,
beside matched varyings, takes its output's location and component; a
description without maintenance4 answers the gap; a wider input stays the
gap, a mesh producer's either way, and no flag stays Metal's link error;
- engine, over text modules on lavapipe's profile: for each class and
interpolation, 4 to 2, 4 to 1 and 3 to 2 lanes link, both relocated modules
pass L3 (spirv-val under the profile's settings, maintenance4 among them),
and the input's Location is the output's, past a second varying.
Red: link still answers the narrower input with the gap.
The golden table re-blessed at 39e5964c2a (varyflag step 1 rebased on 9e7034c214), on the Apple
M3 Max, job m3-max-87716 (inventory, golden, printouts, linkhalf and chains each exit 0):
- the semantics line moves 2392 -> 2393, step 1's own number (2391 at that bless, renumbered
when the stack moved onto pin AB', whose PR 30 and fix-forwards took 2391 and 2392);
- no cell moves and no row is added.
The draw probe (Apple M3 Max, macOS 27.0.1, job m3-max-87586; 720 render
pipelines, one draw each, a pixel read back) measured what 87508 left open:
- flag 0 refuses every count mismatch, as no flag does (180 each); 1 makes all
180;
- under 1, a narrower fragment input reads the vertex output's first lanes
(90 rows: float under perspective, center_no_perspective and flat, uint and
int flat, a second varying absent, after or before);
- a wider input reads the output's lanes, and past them no constant: 150 lanes
read 147 distinct values, none of them 0, 1 or a value either varying wrote.
EntryPoint::mismatched_component_counts's doc now states these facts. Docs only.
Job m3-max-87508 ran each vertex and fragment module with the agx flag at 1
(alone or beside irc.version_*) and with no flag at all; it never ran a module
stating 0. The field's doc, and the commit messages of 7285b878a1 and
02b5d3d1a4, said the pipeline is refused at 0: unmeasured. The doc now says
the refusals measured (no flag on the vertex module, whatever the fragment's)
and that 0 is read as no flag, which is not measured. The decoder is unchanged.
Metal makes a render pipeline whose fragment function reads a user varying at
another component count than the vertex function writes when the vertex
function's module states agx.allow_mismatched_component_counts as 1 (Apple M3
Max, macOS 27.0.1, job m3-max-87508; float4 written and float2 read, and float2
written and float4 read; refused at 0, with no flag, and with the flag on the
fragment module alone; irc.version_* changed nothing). Link answered every such
pipeline Unsupported{UnmatchedVarying, NotRepresentable}, Metal's link error,
for a pipeline Metal makes.
- AIR: module_flags returns whether the agx flag is 1, and the decoder sets
EntryPoint::mismatched_component_counts on each vertex (post-tessellation
included) and mesh function the module defines; fragment, kernel and object
functions never carry it. The flag's docs state the probe's facts.
- Lowering copies it to StageIo::mismatched_component_counts.
- Link (varyings, mesh_fragment): a fragment input whose type differs from
its producer's output in component count alone (same numeric class and source
width), behind a producer carrying the flag, is
Unsupported{UnmatchedVarying, NotImplemented}; everything else stays
NotRepresentable. A mesh producer is not probed yet, so it stays the typed gap.
- Feature::UnmatchedVarying's doc says both; reach.tsv marks it rare;
docs/REFUSALS.md regenerated (it also drops TextureSwizzle's four translator
sites, which a49e4a61c4 and its neighbours removed without a regeneration).
- SEMANTICS_VERSION 2393 (a refusal's class and an interface fact change;
2392 is PR 30's and its fix-forwards', pin AB').
Verified: the red tests of 7285b878a1 (red in job m3-max-87576) pass here;
the green job is named in the lane's report.
The red commit's EntryPoint field left two test literals in the translator
crate without it (memory plan and simd uniformity tests); the red job
m3-max-87574 stopped at the build on them.
Metal makes a render pipeline whose fragment function reads a user varying at
another component count than the vertex function writes when the vertex
function's module states agx.allow_mismatched_component_counts as 1 (Apple M3
Max, macOS 27.0.1, job m3-max-87508: float4 written and float2 read, and float2
written and float4 read; refused at 0, with no flag, and with the flag on the
fragment module alone). Link refuses it as Metal's link error
(Unsupported{UnmatchedVarying, NotRepresentable}).
This adds the fact's two fields, set nowhere yet, and the tests that hold the
label:
- EntryPoint::mismatched_component_counts (AIR): the decoder test expects it on
the module's vertex and mesh functions under 1, nowhere else, and nowhere
under 0 or no flag.
- StageIo::mismatched_component_counts, encoded (ARTIFACT_FORMAT_VERSION 617).
- A link test: a flagged vertex or mesh producer writing wider or narrower than
the fragment input expects NotImplemented; an unflagged one, the flag on the
fragment alone, another numeric class or an unwritten key stay the link error.
- An engine test over text modules compiled on lavapipe's profile: the vertex
module's flag reaches the stage interface and the link answers as above; the
same count links.
Red: these three fail at this commit (the field is never set, link answers
NotRepresentable).
The golden table re-blessed at b991ca5474 (PR 30's head 6d9f774d63, its fix-forwards and SEMANTICS
2392), on the Apple M3 Max, job m3-max-87900 (inventory, golden, printouts, linkhalf and chains each
exit 0):
- the semantics line moves 2390 -> 2392 (PR 30's 2391 and the fix-forwards' 2392);
- no cell moves and no row is added: no committed fixture declares a memory intrinsic in the older
form.
A legacy memory intrinsic's alignment that is not a power of two (or above 2^32) is now refused
as a malformed record, not ImmediateNotConstant (f32b143935), and a legacy call whose volatile flag
is not a constant now meets the verifier the current form meets instead of failing decode's verify
(3e311ec8ac). Both change what decode answers for a module, so cached answers keyed by the old
version must not be reused.
Decode upgrades a call of the older LLVM's llvm.memcpy, llvm.memmove or llvm.memset (an i32
alignment before the volatile flag) by removing the alignment operand. Where the volatile flag is
not a constant in the function that makes the call, decode keeps the upgraded call
Callee::Unbound with its template, as it keeps a current-form call (bitcode/function.rs). The
verifier's legacy arm took only Callee::Llvm, so such a call failed Verify(OperandType) in the
Module::new that decode runs (bitcode/decoded.rs), refusing the whole module. The arm now also
takes Callee::Unbound { template: Template::Llvm(Memset | Memcpy | Memmove) }, under the same
conditions: not variadic, one operand short, and a five-parameter declaration whose fourth
parameter is i32 and fifth i1.
What such a call then meets, read on the current form's path (not run): canonicalization's SCCP
binds an Unbound call with Template::bind over its four operands and the current signature
(canon/sccp.rs), so where inlining makes the flag a constant the call becomes Callee::Llvm, the
form the PR already verifies and translates; where the flag stays a kernel parameter or a value
the run computes, the post-check refuses it at the call in the inlined entry as
InvalidInput(Intrinsic(ImmediateNotConstant)) (canon/mod.rs), the refusal a current-form call
with that flag meets (docs/API.md, OpenCL C kernels).
Makes a_legacy_memory_intrinsic_with_an_unbound_volatile_flag_verifies pass (expected; not run:
the brief holds every build and test until PR 30 merges). No SEMANTICS_VERSION bump here: PR 30's
2391 covers its decode change, of which this is part. Checked: cargo fmt clean.
New test a_legacy_memory_intrinsic_with_an_unbound_volatile_flag_verifies: a kernel
@k(ptr addrspace(1) %p, i1 %v) calls the older LLVM's llvm.memcpy.p1i8.p1i8.i64, declared
void (ptr, ptr, i64, i32, i1), as memcpy(%p, %p, 400, i32 16, %v). It expects decode to upgrade
the call (four operands, align 16 on both pointers), keep it Callee::Unbound with the template
Llvm(Memcpy), as a current-form call whose flag is not a constant is kept, and the module to
verify (verify_module_level, the Module::new that decode runs).
At ace196acec the verifier takes a call one operand short of the legacy declaration only when its
callee is Callee::Llvm, so this one, whose flag is a parameter, fails Verify(OperandType), and
the whole module is refused at decode. Expected to fail here; the next commit makes it pass.
legacy_copy_module gains LegacyAlign::VolatileParameter(bytes): a constant alignment, and the
volatile flag the kernel's second parameter, an i1. The other variants build the same module as
before.
Not run: the brief holds every build and test until PR 30 merges. Checked: cargo fmt clean.
Decode upgrades a call of the older LLVM's llvm.memcpy, llvm.memmove or llvm.memset (an i32
alignment before the volatile flag) by moving the alignment to the pointers' align. A constant
alignment that is not a power of two (or is above 2^32) was refused as
Intrinsic(ImmediateNotConstant), whose own doc says the operand is not a constant. It is now
Bitcode(MalformedRecord { block: FUNCTION_BLOCK, code: FUNC_CALL }), the decoder's answer to an
align attribute of such a value (attrs.rs). An alignment that is not a constant stays
Intrinsic(ImmediateNotConstant) at the call.
How: upgrade_legacy_memory returns a crate-private LegacyAlignmentError, Intrinsic(e) for the
immediate read's error and Malformed for a value Align::from_bytes refuses; the call's decode maps
Malformed to the CALL record's malformed-record error and Intrinsic(e) to the input error at the
record, as before. No public type changes; the outcome class is InvalidInput either way.
Makes a_legacy_memory_intrinsic_s_alignment_must_be_a_constant_power_of_two pass (expected; not
run: the brief holds every build and test until PR 30 merges). No SEMANTICS_VERSION bump here:
PR 30's 2391 covers the decode change, and only the error kind of an input refused either way
changes. Checked: cargo fmt clean.
a_legacy_memory_intrinsic_s_alignment_must_be_a_constant_power_of_two now expects a constant
alignment of 24 on the older LLVM's llvm.memcpy declaration to fail decode as
Bitcode(MalformedRecord { block: FUNCTION_BLOCK, code: FUNC_CALL }), and an alignment that is the
kernel's i32 parameter to fail as ImmediateNotConstant, as before.
Why: IntrinsicError::ImmediateNotConstant says "An operand that must be an immediate is not a
constant", and 24 is a constant. The decoder's precedent for a value that is not a power of two
where an alignment must be one is the align attribute's: MalformedRecord (attrs.rs).
Expected to fail at ace196acec, which reports both alignments as ImmediateNotConstant; the next
commit makes it pass. Not run: the brief holds every build and test until PR 30 merges.
Checked: cargo fmt clean.
Modules from older LLVM-based Metal frontends couldn't be translated. They declare llvm.memcpy,
llvm.memmove and llvm.memset with an i32 alignment before the volatile flag, and that declaration
was refused as Intrinsic(DeclaredSignatureMismatch).
The declarations involved:
- llvm.memcpy and llvm.memmove: void (ptr, ptr, i64, i32 align, i1 volatile)
- llvm.memset: void (ptr, i8, i64, i32 align, i1 volatile)
- seen in typed-pointer bitcode from metalfe-32023.35
What changes: decode upgrades such a call the way LLVM's own reader does (UpgradeIntrinsicCall): the
alignment operand is removed, and its value becomes the align of the pointer operands. In detail:
- the removed operand's attributes go with it, and later attributes move down one place;
- the alignment replaces any align the call states, and an alignment of 0 removes it
(setDestAlignment, setSourceAlignment);
- a non-constant alignment, or one that is not a power of two, is refused as ImmediateNotConstant;
- the verifier accepts the one-short call only when the declaration has exactly that legacy form.
No public API changes.
Evidence:
- On 466 real libraries from one metalfe-32023.35 game, all refused before: 66 now translate (48
render or compute functions, plus 18 kernels given a stage-input descriptor). Each is
byte-identical to the translation of the same library after llvm-dis upgrades it with LLVM's
reader. The other 400 stop at an unrelated later refusal (Lowering(StageIo)), the same on both
forms.
- New tests: a_legacy_memory_intrinsic_states_its_alignment_on_its_pointers,
a_legacy_memory_intrinsic_s_alignment_must_be_a_constant_power_of_two,
a_legacy_memory_intrinsic_s_attributes_move_with_its_operands,
a_memory_intrinsic_call_one_short_only_of_the_legacy_declaration. Undoing each part of the change
on its own makes at least one of them fail.
- Linking a legacy-form module with a current-form one is not tested.
Version: SEMANTICS_VERSION becomes 2391, because inputs refused before can now compile.
Golden table: unchanged; this change adds no fixture.
Not run: the GPU device tests, the Windows clippy legs and the CI matrix.
The golden table re-blessed at 3c3d214397 (PR 29's head 8f117956ef and its docs fix-forward), on
the Apple M3 Max, job m3-max-87637 (inventory, golden and printouts each exit 0):
- the semantics line moves 2389 -> 2390, PR 29's own number;
- one row is added, the new fixture vertex_stack_return_aggregate.ll (stack_return_vertex), the
same hash on every profile.
No existing cell moves, as the PR's reading predicted: no committed fixture loads or stores a
whole aggregate in thread memory.
The fix-forward of PR 29's reading (lane pr29read; docs only, no code):
- engine_stack_return_aggregate.rs says it compiles on one profile, `nvidia-rtx50-linux`, and
that its expectations row holds the fixture to `ok` on every committed profile, as the
converter-flags engine test does since d3316d621e.
- canon/aggregates.rs's module doc drops "left whole, it was refused" (history); the refusal a
whole access of a larger aggregate meets is named where the doc says lowering refuses it.
- The PR's new comment lines over 100 columns are wrapped: aggregates.rs's opening paragraph,
canon/mod.rs's pass list and its call-site comment, and tests/aggregates.rs's module doc.
Checked: cargo fmt --all makes no change; the comment lines the PR added are at most 100
columns.
Vertex functions that build their return value on the stack couldn't be translated. A whole struct
stored to or loaded from an alloca reached lowering, which handles only scalars and vectors there,
and was refused as Lowering(Access) AccessType.
The shape involved, seen in modules Apple's Metal shader converter wrote:
- a store of zeroinitializer to an alloca of the return struct;
- stores to its members;
- one load of the whole struct.
What changes: the split that already turns a whole-aggregate access of device, constant and
threadgroup memory into its members' accesses now covers stack memory too. Still kept whole, and
refused by lowering as before:
- a volatile access;
- an aggregate that holds a pointer;
- an aggregate with more members than the split takes.
No public API changes.
Evidence:
- a_stack_aggregate_is_split checks the member stores and loads, their alignments and byte offsets,
the two insertvalues, and that no whole-struct access is left.
- what_is_not_split_stays_whole gains the three stack cases above.
- The new fixture compiles, links and validates.
- a_stack_aggregate_is_split and a_return_value_built_in_a_stack_slot_compiles fail without this
change.
- No release-mode timing was taken; the split adds a bounded walk per whole stack access.
Version: SEMANTICS_VERSION 2389 -> 2390, because inputs refused before can now compile.
Golden table: left for the bless on development; golden_hashes_match_the_table lists the new
fixture's cells. The fixture's expectations row is included.
Not run: the GPU device tests, the Windows clippy legs and the CI matrix.
CI run 47469915099 at 69664cbc1a failed "Clippy under each feature alone" on both
legs: with no feature, `slot` in pipeline/api_tests.rs is never used (dead_code under
-D warnings). a49e4a61c4 removed its last caller outside `serde_round_trips`, and the
merge check runs clippy only with all features, so nothing caught it before the push.
The helper and the three `sym` types it names move into `serde_round_trips`, where
every caller is. The empty `bind_serde_round_trips` module goes with it: it holds
nothing.
Checked: cargo fmt clean. The per-feature clippy (metal2vulkan none, serde, ash,
cli; metal2vulkan-air none, serde) runs on this commit as its own leg.
PR 28 (74e4ad9d3a) added the owned fixture kernel_converter_module_flags, whose cells the
contribution left for this bless, and the hoist containment (7a066a4b80) checks a load the
translator makes where the program did not run it in the address form, which moves that form's
cells. golden_hashes.tsv gains the fixture's row and 23 rows move, re-blessed on macOS (M3 Max,
job m3-max-87519, BLESS_JOBS=4); after the bless the job's golden, inventory, printouts, linkhalf
and chains checks report 0. Data only: no source changes.
7a066a4b80 (a load made where the program did not run it is checked in the address form) bumped
SEMANTICS_VERSION from 2387 to 2388. Rebased onto d3316d621e, whose development already says
2388 (1c685f0524, the hoist's number after PR 28 took 2387), the same textual change merged
without a conflict, so the containment shared the hoist's number. A cache written at the hoist
alone holds unchecked entry loads in the address form; 2389 keys the checked ones apart.
Verified: the version line diffed against d3316d621e at staging (2388 at the base, 2389 here);
the touched suites at this tip run in the CPU job named at landing.
engine_hoist_contain gains a second kernel: a short arm beside a quad_broadcast_first, which
Metal's backend speculates, reads k, a 4-byte constant reference, behind a store to out that
keeps the hoist away. canon's arm speculation runs that load in every lane of the branch's block
and marks it speculative (99bcd849f6); the test asks that on every identity profile the address
form reads k's SlotBounds and the zero range, and loads it through a selected address. At
8f8617ca5d, where speculate marked nothing, the load is at a constant offset and unchecked, so
the test is expected to fail there (not run at the base).
Evidence for 99bcd849f6 and this branch, recorded here as that commit is already reported:
- Consumer use of InstKind (the public field InstKind::Load::speculative): the consumer's
checkout at development 985ecd39f0 and its 27 steelbrain/* tips younger than a day,
git grep -w -F InstKind and git grep -F metal2vulkan_air::ir over *.rs: 0 code hits.
- The three guest kernels the hoist was timed on: their SPIR-V is equal at 8f8617ca5d and at
960999d529 on all 10 committed RADV, ANV and NVIDIA profiles (job m3-max-87433, release
command line), and equal to the hoist lane's measured tip build, so the hoist's gains on the
RX 7900 XTX, the Iris Xe and the RTX 3090 are expected (same SPIR-V as the measured build on
the bound-form profile). It differs only on the address-form profiles (lavapipe,
gate-lavapipe-x86_64, moltenvk-m3), where the hoisted load is now checked.
- Golden table at 960999d529 (job m3-max-87441, every changed cell listed): 60 cells move, all
on the five address-form profiles, none on a RADV, ANV or NVIDIA profile.
- Authored-compile census at 960999d529 (job m3-max-87432): 2390 cases, 0 differences,
0 regressions, 0 failed, 0 table rows changed; slowest compile 1120 ms.
On a profile with the bound form, flag's slot is a storage view, so the module has one
device-address load (extra's, selected), not two. Job m3-max-87420 at 99bcd849f6 failed only this
count on amd-780m-hawkpoint-radv ([1, 0] against [1, 1]); its bounds and zero-range assertions
held, as did every other engine_hoist_contain, engine_identity_contain, engine_bound_buffers and
engine_word_phases test and the api_signatures table.
The constant-reference hoist makes a kernel's load of a constant T& at a fixed offset in its entry
block, so every thread of every dispatch reads it where the program read it only behind a
branch. Metal requires the reference's binding only where the program reads it, so an app may
leave it unbound, or bound shorter than the object, while that branch is not taken. In the
bound form the pipeline's robust buffer access contains the read (a null descriptor or a short
range reads zero), but where the slot is reached by its device address an access at a constant
offset was never checked: a short binding was read past its end by every thread, and an unbound
one past the nil buffer's 64 KiB under a larger object, a GPU fault where a mapping ends.
The mark: InstKind::Load gains `speculative`, false for every decoded load. const_hoist sets it
on each load it moves; speculate sets it on each load of an arm it flattens (a constant
reference's, at offset 0, run in every lane of the branch's block: the same window, narrower);
aggregates carries it to a split load's members. Lowering reads it: a speculative load's slots
are noted as reached at a variable offset (SlotBounds and, for a device-address read, the zero
range), and emit::prepare checks it against the slot's buffer whatever its offset, reading zero
outside, as an access at a run-time offset is. The bound form is unchanged: a bound slot drops
its bounds and its view is not checked in the shader. Covered: a device without the bound form's
queries, a slot bound below its argument's alignment on one with them, and every render stage.
const_hoist also leaves a reference whose pointer another root may share (the parameter or an
address step from it as a phi, select or insert operand, a stored value or the result): such a
pointer may meet one loaded from memory, and lowering then reaches the reference by a device
address no check bounds.
Docs: const_hoist's and speculate's module docs, canon's list, ARCHITECTURE.md, API.md sections
1 and 5, the runtime README's bounds paragraphs and push layout, PushField::SlotBounds. The
public signature table is re-blessed for InstKind::Load (no consumer use of InstKind: zero hits
in the consumer's development and its day-old steelbrain/* tips). SEMANTICS_VERSION 2388.
Tests: engine_hoist_contain (red at the base in jobs m3-max-87402 and m3-max-87403: no
SlotBounds for the hoisted load's slot on any identity profile or for a word-bound slot on a
bound-form profile, and the interpreter traps OutOfBounds at EXTRA+98304 and NIL+98304 with the
flag off); constant_hoist's loads are speculative where moved and a shared reference keeps its
loads; speculate's arm load is speculative where speculated and not where kept.
The case loop stopped at the first trap, so the red showed only the short binding. Each case now
runs and every failing one is named, so the base shows the unbound case (an object over the nil
buffer's 64 KiB) as well.
Verified at the base in job m3-max-87402 on the parent commit: the short case traps OutOfBounds
at the hoisted load.
The constant-reference hoist makes a kernel's plain load of a constant T& at a fixed offset in its
entry block, so every thread of every dispatch reads it where the program read it only behind a
branch. Where the slot is reached by its device address, a load at a constant offset is never
checked against the slot's bounds, so a binding shorter than the object, or an unbound one (the
runtime's 64 KiB nil buffer) under an object over 64 KiB, is read past its end by every thread.
engine_hoist_contain's kernel reads extra (a 128 KiB constant reference) at byte 98304 only
under a flag from another buffer. The new tests ask that, in the address form, the hoisted load
read its slot's bounds and go through an address selected toward the zero range on every
identity profile; that a slot bound below its argument's alignment on a bound-form profile do
the same, and a bound view stay unchecked; and that on the CPU interpreter, with the flag off,
extra bound 16 bytes long or unbound reads nothing outside (no trap) and out keeps its words.
Expected red at the base: the three assertions on the check fail, and the interpreter traps
OutOfBounds at the hoisted load for the short and unbound cases.
PR 28's engine test compiles its fixture on nvidia-rtx50-linux alone, while its row in
public_fixture_expectations_engine.tsv holds it to ok on all 15 committed profiles. The module
doc now says which test covers what. Documentation only; no behaviour changes.
PR 28 (74e4ad9d3a, the converter's module flags, merged on GitHub by fast-forward) bumped
SEMANTICS_VERSION from 2386 to 2387. The constant-reference hoist (062b71cf63, rebased onto the
PR head) made the same textual change, 2386 to 2387, so the rebase merged the two without a
conflict and both changes shared one number. A cache written under the PR alone and one written
with the hoist must not match, so the hoist's translation takes 2388.
Verified: the rebased development differs from its pre-rebase tip (8f8617ca5d, kept as
steelbrain/dev-before-pr28) by exactly the PR's diff less its version line (6 files, +115/-3).
The hoist (494bf5f743) moves a kernel's constant-reference loads into its entry block, so the SPIR-V of
the kernels it reaches changes. 11 rows of golden_hashes.tsv move, re-blessed on macOS (M3 Max, job
m3-max-87341, BLESS_JOBS=4); after the bless the job's golden, inventory, printouts, linkhalf and chains
checks report 0. Data only: no source changes.
A kernel often reads a constant T& parameter only behind its bounds branch
(if (gid >= n) return; out[gid] = in[gid] * scale;). canon::const_hoist
moves each such load into the entry block, its value reaching its uses by
dominance, where all of these hold, each read from the body's structure and
the entry's ABI:
- a plain load (not volatile, not atomic) of an integer, a float or a vector
of them; a pointer's or an aggregate's load stays;
- its address is a parameter the ABI binds as a constant-space buffer with a
stated air.buffer_size and no function-constant predicate (a constant T&),
or that parameter plus GEPs at constant, non-negative indices and bitcasts,
which move with it; the bytes read lie inside [0, air.buffer_size). The
address is then one address for every thread, and each form contains it at
the entry as where it stood: the same slot, a bound storage view under its
robust buffer access, or a device address at a constant offset, which no
check clamps in either place. A constant T* (no size), an offset past the
object and an offset the run computes stay;
- no instruction on any path from the function's start to the load may write
device memory or order another thread's writes before it: a store or
memory intrinsic whose destination is not thread or threadgroup memory, an
atomic or atomic load of any space, a fence or barrier, a texture write,
or any call but arithmetic, conversions, group operations, built-in reads
and texture reads and queries. A forward reach from every writing block
marks the blocks a write may precede; a load's own block counts up to it.
Where it lives: a new canon pass beside speculate, not inside it.
speculate.rs is a fidelity pass: it gives Metal's measured if-conversion of
group operations, keyed by Metal's budgets, and its moves change what a
program observes. This one changes nothing a program observes and its rule
is soundness alone (no write before, the access contained), so it has no
place in speculate's measured decisions; it shares rewrite::BodyEdit's moves
with it. It runs after aggregates::expand, so an aggregate load of a
reference, split into its members' loads, moves too, and before the
OpenCL hidden buffers and the program-scope bindings add parameters. Kernels
only: the measured kernels are compute kernels.
The planner's measurement (the audit seat's lab pass, which moved every load
at a constant parameter itself) on the compute benchmark's guest kernels FM
copy, FM vertical and Fluid's pressure step, GPU time of 20 dispatches, arms
alternated, output digests equal in every pair: the RTX 3090 -3.6%, -0.1%,
-9.5%; the RX 7900 XTX -7.3%, -0.7%, -12.2%; the Iris Xe +0.4%, 0.0%,
0.0%. On the Iris, ANV sinks the loads back into the branches: FM copy's
compiled code goes from 134 to 132 instructions (1026 to 912 cycles), its 8
SENDs unchanged (read from INTEL_DEBUG=cs, not from Mesa's source).
SEMANTICS_VERSION 2386 -> 2387: a kernel whose constant-reference loads move
translates to other words.
Verified: pending the green job.
canon/tests/constant_hoist.rs builds the bounds-branch shape of the three
compute kernels the hoist was measured on, synthetic and ours:
kernel k(device float* out, constant uint& n, constant float& scale,
constant P& p, uint gid) { if (gid >= n) return; out[gid] = float(gid) *
scale + p.bias; }, and specializes it.
- Positive: the loads of scale (the parameter itself) and p.bias (a GEP at
byte 4 of the 8-byte object) are made in the entry block beside n's, and
the store stays behind the branch. Red today: both loads stay behind it.
- Refusals, each keeping its load behind the branch: a store to out before
the loads; an AIR atomic add before them; a callee that stores to out and
then reads scale (inlined); p.bias read at an offset the branch's block
computes ((&p.first)[gid & 1]); scale as a constant float* (no
air.buffer_size); p.bias read at byte 8, past p's 8 bytes. These pass
today (nothing moves); each goes red with its guard removed.
Verified: pending the red job.
Extends every_device_imports_host_memory_and_releases_it_after_the_free: the fill of the import's
second half is committed held for a shared event's value, and the buffer and then the block, the
consumer's last handles of the import, drop while it is pending. The release must not have run 20 ms
later; once the event's value lets the fill run, the release runs, the gauges come back, and the
pages hold what the fill wrote (the first half the host's bytes). The test then writes the pages
again as their owner, commits a later command buffer, waits for the device to go idle, and checks
the pages hold its own bytes: nothing of the runtime wrote them after the release. Before, the test
waited for the fill and read the pages while the import was still held.
A texture made in place over host memory's import (integrated or CPU devices) restores the
import's bytes with a save, a move home and a write-back in one batch of the runtime's own, and the
make waits for that batch through Done::wait. Done::wait returned any result of vkWaitSemaphores
other than VK_TIMEOUT as an Error::Vulkan. Where that result was VK_ERROR_OUT_OF_HOST_MEMORY,
VK_ERROR_OUT_OF_DEVICE_MEMORY or VK_ERROR_UNKNOWN on a live device, the make returned Err while the
batch, and with it the write-back of the saved bytes, was still pending: the import's pages were
written after the caller saw the make fail, and may have released or reused them.
Vulkan's words: vkWaitSemaphores lists those results as failures and says nothing of the wait's
condition with them (only that with a loss the call "must return in finite time with either
VK_SUCCESS or VK_ERROR_DEVICE_LOST"); a failed call leaves every submitted batch pending, executing
as the queue runs it, whatever the host's wait returned. Only a loss ends what is pending: "for the
purpose of determining whether a command buffer is in the pending state ... a return value of
VK_ERROR_DEVICE_LOST is equivalent to VK_SUCCESS" (Lost Device).
So Done::wait now makes such a call again through complete::wait_through, as the device's idle wait
and an import's bind wait already do, until it succeeds or the device is lost, and returns Err only
at a loss, as its doc already said. Every caller of Done::wait gets that: the restoring make's
drain and batch waits, the upload room and staging span waits, a surface making's wait, and a
texture read's staging wait (whose span went back while its copy could still write it). A lasting
failure on a live device waits as long as it lasts. The README's restore paragraph says the make's
wait returns only once the batch completed or the device is lost.
The tests' stand-in for a failed wait (Core::fail_waits, inside wait_through) now reaches
Done::wait. New device test failed_waits::a_failed_restore_wait_is_made_again: with a Busy gate
holding the device's queue, a make in place whose batch wait fails at its first call must not
return while the gate holds the batch, then returns the texture in place once it opens, counted as
one restoring make with its two restore copies, and the pages hold the host's bytes.
crates/metal2vulkan/src/device/mechanism.rs moved in fddfdd2ce1, so the
runtime-sources fingerprint moves with it. The validation suite at the
lane's tip (job m3-max-87020) failed only this guard and printed the new
hash; pin-compute over development's tree gives the same value.
- crates/metal2vulkan-runtime/src/error.rs: both RuntimeFact causes
(the draw's and the kernel's) gave "ResourcePresence" as an example
fact name; that fact no longer exists. The example is now "FlatGrid"
(RuntimeFact::name of RuntimeFact::FlatGrid, which neither the
kernel's nor the draw's fact match in the runtime names). The
kernel's cause also named "a resource's presence or a sampler's
coordinates" as facts the runtime does not name; neither is a
RuntimeFact now, so the examples go.
- crates/metal2vulkan/src/tests/engine_extended_range/levels.rs: the
module doc and the 3D test's doc told of development's resident-table
tests and "the one form, as development's default policy did". They
now say what holds: the conformance probe extended_linear_mip_blends
measures Metal's mip filters, and the identity domains refuse such a
sample with its texture argument.
- crates/metal2vulkan-validation/src/executor_contract/out_of_bounds/
tests.rs: the identity-domains containment test's doc ended with a
sentence on the resident table and the handle table, which the test
no longer runs; it goes.
Searches: git grep -n 'ResourcePresence\|resident-table' over crates and
docs -> 0 hits after (3 before, all these sites).
refusal_surface.py --check passes.
Correction to 6d3a51f4fe's body: open_cl_1d_images at f6fc9cf282 is
8 hits in crates/metal2vulkan-air and 3 in crates/metal2vulkan, not 7
and 4. The total, 11, was right.
Entry.open_cl_1d_images held the texture indices of an OpenCL-mode
kernel's 1D images. No caller in this tree read it: metal2vulkan's two
readers were test literals setting it to the default, and
pipeline::compile's bound_entry dropped canon::opencl::entry's set
(`let (ep, _) = ...`). Deleted:
- the field, and its binding in canon::specialize;
- the set canon::opencl::entry built, along with the AbiInt match that
filled it; entry now returns the EntryPoint alone, and its retyping
of each 1D image to the 2D texture Apple's OpenCL binds is unchanged;
- the BTreeSet imports of opencl.rs and tests/opencl.rs;
- the two test literals.
opencl_1d_images_take_their_2d_textures_types now checks, in place of
the set, that without the mode each image keeps its own 1D type: the
names bound_texture leaves at indices 1 to 3.
Searches:
- this tree at f6fc9cf282: git grep -n open_cl_1d_images -> 11 hits
(crates/metal2vulkan-air 7, crates/metal2vulkan 4 with the signatures
table); 0 after.
- reims-vgpu c16328ee3d (and cc1f47b30b): git grep -n open_cl_1d_images
-> 0 hits.
The signatures table is blessed: exactly one record removed
(metal2vulkan-air::Entry.open_cl_1d_images).
Correction to 141dabb1e8's body: its swizzled_storage count at
f6fc9cf282 is 33 hits, not 32 (crates/metal2vulkan/src/cache/mod.rs has
5, not 4).
LoweringInputs::swizzled_storage and VariantKey::swizzled_storage have
no setter outside the translator's own tests. Since the identity domains
refuse any slot whose SlotPlan::swizzle is set
(IdentityCause::TextureState), a slot of the variant could only lead to
a refusal or to nothing. Nothing else reads the swizzle any more: the
emit side went in 6a08124f54.
Deleted with it:
- the cache key's "swizzled-storage" block;
- lower::texture::swizzled_storage and ::swizzles;
- SlotPlan::swizzle (identity_lowered now tests offset_base alone);
- the NotImplemented(TextureSwizzle) refusals of the variant's ulong,
short-lane and imageblock-slice accesses (Feature::TextureSwizzle
stays: bind/heap.rs refuses with it);
- the bicubic and packed-normalized sampling arms that read the
variant, and the read path's storage_swizzle alpha term;
- the public RuntimeFact::TextureSwizzle, which only swizzles()
produced, with its codec entry, mechanism, identity_unsourced arm and
name. The mechanism test's variant index 35 now holds PrivateList and
the covered range is 0..55.
Tests: tests/engine_swizzled_storage.rs goes (its reference rules
checked only its own helpers once the emit side was gone), and
engine_extended_range/bicubic.rs loses its swizzled cases. Docs fixed:
LoweringInputs, VariantKey, the sampler select and extended module
docs, IdentityCause::TextureState's examples, and the runtime README's
identity refusal list (TextureSwizzle no longer named).
No compile with empty inputs changes: every deleted arm was gated on
the set. The RuntimeFact encoding loses a variant; the
ARTIFACT_FORMAT_VERSION bump to 616 in 9cc7dd223a on this branch covers
it.
Searches:
- this tree at f6fc9cf282: git grep -n swizzled_storage in
crates/metal2vulkan{,-runtime,-air,-validation,-harness,-devtools}
and docs, fixture names (rrp_swizzled_storage) and the conformance
case module aside -> 32 hits, all in crates/metal2vulkan; 0 after
(crates/metal2vulkan-runtime: 0 before).
- reims-vgpu c16328ee3d (and cc1f47b30b): git grep -n swizzled_storage
-> 0 hits; git grep -n RuntimeFact -> 0 hits.
The signatures table is blessed: exactly 3 records removed
(VariantKey.swizzled_storage, LoweringInputs.swizzled_storage,
RuntimeFact::TextureSwizzle). refusal_surface.py --check passes, so
docs/REFUSALS.md does not change.
StageSpec.unread_bits and the public SpecConstant.unread_bits were set
and never read. spirv::spec_bits::mark_unread computed them on every
compiled module, and link::specialize intersected them per key. Nothing
read the result: not the runtime (crates/metal2vulkan-runtime has no
hit), not the validation or conformance crates, and not the consumer.
Deleted:
- both fields, with their codec entries (cache/codec.rs);
- link::specialize's unread map and its doc sentence;
- compile.rs's mark_unread call;
- spirv/spec_bits.rs (the demanded-bits pass, 299 lines);
- its test module tests/engine_spec_bits.rs (149 lines);
- api_tests.rs's literal field.
engine_skeleton's expected StageSpecs are now plain StageSpec::new.
The SPIR-V a compile emits does not change: the pass only wrote the
interface fields.
ARTIFACT_FORMAT_VERSION goes from 615 to 616: StageInterface and
SpecializationLayout lose a field from their encoding.
Searches:
- this tree at f6fc9cf282: git grep -n unread_bits -> 13 hits, all in
crates/metal2vulkan (the fields, codec, link, spec_bits, three tests,
the signatures table); 0 after.
- reims-vgpu c16328ee3d (and cc1f47b30b): git grep -n unread_bits -> 0
hits.
- reims-vgpu c16328ee3d: git grep -n spec_bits -> 3 hits, all in
crates/reims-vgpu-c/link-order.txt (a link order list of symbol
names; its doc says a function removed since is skipped and costs
only the order's speed).
The signatures table is blessed: exactly one record removed
(SpecConstant.unread_bits). The proof jobs at the branch tip carry the
suites and clippy.
The engine's candidate now draws object and mesh cases through the
runtime's mesh pipeline, so the Linux qualification step runs the 13
committed mesh and object cases that draw on lavapipe against their
Metal rows. Two committed cases stay out: the object function's
threadgroup memory (3ff818075803), which the runtime refuses at the
state's make and the candidate meets as mesh_threadgroup_memory, and
the mesh function that numbers its primitive from its payload
(d2c517d1426d), whose mesh function aborts lavapipe's LLVM ("Cannot
emit physreg copy instruction").
Verified: the 13 cases matched Metal on lavapipe through corpus-vulkan
at c1bdd1e491 (job m3-max-86906); this commit's script run follows.
The previous commit also raised mesh_threadgroup_memory from a case's authored threadgroup_memory
(executor_contract::case_requirements). The mesh case's mapping refuses the case's literal
families (require_case_families), so the authored compile census's preparation, which sets the
requirement aside to compile the case, was refused too (the lavapipe validation suite, job
m3-max-86881: the_census_compiles_the_mesh_pipelines, engine_case_families_follow_the_case_literals
and the engine_mesh threadgroup test failed). The function's reflection alone raises it
(mesh_threadgroup_memory_requirement), as it raised the requirement this one narrows.
The runtime makes and draws mesh render pipeline states (Device::new_mesh_render_pipeline_state,
the render encoder's set_object_*, set_mesh_* and draw_mesh_* calls), so the engine's candidate
now draws an object or mesh case as the Metal oracle draws it, instead of refusing every one as
mesh_render_pipeline. candidate::platform::runtime_mesh makes one mesh render pipeline state of
the oracle's descriptor (MeshTemplate::descriptor: the case's own function and the partners its
draw names from the row's library, the generated stages of an observation or object launch from
the companion's, its color formats or the 1x1 R8Unorm sink without rasterization), makes and
binds the own stage's buffers, argument-buffer members, textures and samplers through that
stage's setters (runtime_render's Stages, which now binds a stage of either pipeline kind and
selects a stage's output for both), makes each color target a Shared 2D texture of one sample
written from the case's bytes (Targets::of_colors), draws once (draw_mesh_threadgroups or
draw_mesh_threads), and reads the output back. A threadgroup within Metal's maximum and past the
state's on the device (Limit::MeshThreadgroupThreads) records not_enabled, as a sample count the
device makes no texture of does.
One vocabulary: mesh_render_pipeline is retired, and the one shape the runtime refuses keeps a
requirement of its own, mesh_threadgroup_memory (Limit::Runtime): an object or mesh function that
declares a [[threadgroup(n)]] argument (its reflected threadgroup buffer), and a case that authors
an object function's threadgroup_memory. Its doc names the runtime's refusal it mirrors, in the
runtime README's words: "An object or mesh function with a [[threadgroup(n)]] argument is refused
at the creation (Gap::RenderPipeline), as setObjectThreadgroupMemoryLength:atIndex: and its mesh
form are not built". The authored compile census still prepares such a case to compile it
(prepare_compile), so no compile cell changes. Classification, the case checker, the executor,
the triage, census, executor-contract, requirement and compile-census tests, the validation
README, docs/VALIDATION.md and the runtime README's sentence about validation's mesh cases follow.
Versions: the structural-triage analyzer v87 (rows' requirements change). ENGINE_EXECUTOR_ABI is
not bumped: no recorded row observes the change, as the executor refused every object and mesh
case before any device and stored no row of one. SEMANTICS_VERSION is untouched: translation
output does not change. The authored compile census version is untouched: no cell changes.
Venue: lavapipe lists VK_EXT_mesh_shader with taskShader, meshShader and multiDrawIndirect, the
runtime's mesh set, so lavapipe draws mesh pipelines and is the device test's venue.
A device test (candidate::tests::engine_mesh, under m2v_cpu_icd and m2v_gpu on Linux) admits each
owned object and mesh fixture of mesh_cases for the engine's candidate, prepares it and runs it as
a run of the candidate does (run_prepared, now pub(crate)), and holds the output to the words
Metal drew for it: a mesh grid through its fragment partner, an object case through its mesh and
fragment partners, a mesh function's device write without rasterization, a mesh grid through the
generated observer, an object case's launch through the generated mesh function, and the payload
a generated object function writes (payload_order on a GPU only, as its fixture states). The
fixtures now compile for the Linux device tests too.
At this commit the test fails: the candidate refuses every object and mesh case before it maps
(mesh_render_pipeline). The next commit makes the candidate draw them through the runtime.
Verified: the red run is named in the lane's report.