Files
metal2vulkan/docs
Anees Iqbal 4732ce6cd7 rt: a buffer bound off its argument's alignment runs at the address rounded down to it
The binder (ComputeCommandEncoder::fill_parameters) pushes each bound buffer's address,
its gpuAddress plus the bind offset, rounded down to a multiple of the alignment the
kernel takes it to have (FieldValue::BufferAddress's mask, from
RuntimeFact::AddressAlignment: the argument's air.arg_type_align_size, at most 16), for
every slot. Refusal::MisalignedBuffer and the dispatch it skipped are deleted, so
fill_parameters cannot fail.

Why: Metal's API validation refuses such a bind offset, and without validation an Apple
M3 Max (macOS 27.0.1) reaches each element at its address rounded down to the smaller of
the element's alignment and 4, for loads, stores and pointers stored in a buffer alike.
The probe that measured it is committed as
crates/metal2vulkan-conformance/probes/misaligned_buffer_binds.m. The two agree at
alignments 2 and 4 and for 8- and 16-byte arguments bound 1 to 3 bytes off a multiple of
4; an 8- or 16-byte argument bound at a multiple of 4 that is not a multiple of its
alignment is reached at the rounded address where the M3 reaches it exactly there, a bind
Metal's validation rejects. docs/API.md section 10 lists that as an accepted difference.

Tests: rt's every_device_rounds_a_bound_address_down_to_its_alignment steps a buffer bound
off each alignment (2, 4, 8 and 16; 15 binds) through the step kernel with the mask set,
and checks the words stepped start at the rounded address; at the 8- and 16-byte binds 4,
8 or 12 bytes off, an unrounded bind would step other words on any device.
an_argument_bound_off_its_alignment_runs_at_the_address_rounded_down binds
vector_word_phases' vwp_words 1 and 3 bytes and vwp_vec16 4 and 12 bytes off their
alignment and expects Metal's words for the rounded binds. They replace
an_argument_bound_off_its_alignment_is_refused and
a_misaligned_dispatch_refused_leaves_its_encoder_and_command_buffer_usable.

Docs: REFUSALS.md and api_signatures.tsv regenerated (the variant's row goes), the rt
README's compute encoders say what the binder pushes, the translator's
RuntimeFact::AddressAlignment doc and the mechanism comment say the binder rounds.
2026-11-17 18:07:45 -08:00
..