Files
metal2vulkan/docs
Anees Iqbal edfba8ac8b Decode AIR 2.5's stride-less kernel and vertex ICB buffer setters
AIR 2.5 (Metal compiler 31001.723, macOS 12's and 13's) declares an
indirect command's kernel and vertex buffer setters without the i64
attribute stride before the buffer index:

  air.set_kernel_buffer_compute_command.p{1,2}i8
  air.set_vertex_buffer_render_command.p{1,2}i8
    void (ptr addrspace(1), i32, ptr addrspace(1|2), i32)

Decode had one form for these, (cmd, i32, ptr, i64 stride, i32 index),
so such a declaration classified as DeclClass::Mismatch and its module
was refused with InvalidInput(Intrinsic(SignatureMismatch)). The
translation census over ms01's private corpus at fd22785008 refused 8
rows this way on every committed profile, all AIR 2.5 from 31001.723;
7 of them (3 vertex functions, 4 kernels) declare these setters. The
error text and position (blocks [8, 12]) are the consumer's macOS 12 and
13 Contacts refusals'; whether those are these setters is unverified.

What the stride-less form means: it is MSL's plain setter,
set_kernel_buffer(buffer, index) and set_vertex_buffer(buffer, index).
Today's compiler spells that setter with an i64 of all ones. Evidence,
run on this Mac with Apple metal version 32023.921 (metalfe-32023.921.6),
on kernels calling the plain kernel and vertex setters on a device and
a constant buffer, compiled at -std=macos-metal2.4, metal3.0, metal3.1
and metal3.2: every standard declares all four setters with the i64,

  declare void @air.set_kernel_buffer_compute_command.p1i8(
    %struct._command_buffer_t addrspace(1)* nocapture, i32,
    i8 addrspace(1)*, i64, i32)

and call each with it as -1:

  call void @air.set_kernel_buffer_compute_command.p1i8(... %3,
    i8 addrspace(1)* %7, i64 -1, i32 0)
  call void @air.set_vertex_buffer_render_command.p2i8(... %3,
    i8 addrspace(2)* %8, i64 -1, i32 1)

(4 of 4 calls at -1 at each standard.)
All ones is the stride the encoder already writes for a stride-less
buffer (Fields::Buffer { stride: None }, "as Metal's kernel-side setter
does"), the stride the runtime's CPU-side set_kernel_buffer records.

How:
- IndirectCommand::SetBuffer gains `strided`. A kernel or vertex setter
  parses as strided; alternative() offers the stride-less form, through
  AirIntrinsic::alternative(), as for the legacy texture read and the
  AIR 2.7 to 2.9 forms. The fragment, object and mesh setters keep their
  one stride-less form.
- lower/access/encode.rs takes `strided` from the operation instead of
  deriving it from the stage, so the stride-less form writes the
  all-ones stride.
- The decode golden printouts of the engine ICB fixtures spell the new
  field.

Tests:
- families_tests: the four AIR 2.5 declarations among the observed
  ones; buffer_setter_forms_are_chosen_by_the_declaration (each form
  classifies to its own operation, keeps the command handle at 0 and
  the buffer at 2; other operand lists, and a stride on a fragment,
  object or mesh setter, stay Mismatch).
- engine_indirect_commands::air_2_5_buffer_setters_write_the_plain_
  setters_records: the compute and render ICB kernels rewritten into
  the AIR 2.5 spelling (AIR 2.5, Metal 2.4) write byte-identical records
  to today's form at stride -1, on every profile with device addresses,
  over a dynamic stride set before.
- A new owned synthetic fixture, kernel_icb_encode_plain_setters_air_2_5.ll
  (two kernels, both setters, device and constant buffers), with its
  inventory rows: ok wherever kernel_icb_encode_compute_commands is,
  refused for GpuEncodedIndirectCommands where it is. It assembles with
  the pinned LLVM 21.1.8.

docs/FAST-PATHS.md: the known gap for macOS 12's and 13's declarations
now says what is true: the setters decode, and of the 7 private rows
that declare them, 1 translates and 6 meet the typed not-implemented
ArgumentBufferObjects refusal (below); one private row stays refused
with SignatureMismatch, a kernel declaring air.intersect.triangle_data
with six trailing settings where decode's form has nine (ray tracing,
out of scope). A new known gap names the CallTypeMismatch class: a
direct call whose arguments do not line up with its callee's
parameters, which no exact form exists for and which stays refused.

SEMANTICS_VERSION 1693 -> 1694: declarations that were refused now
decode, and a row that was refused now translates.
No runtime input changes (runtime-sources.sha256 unchanged). The golden
hash table is not re-blessed here.

Verified on homelab-ms01 at the round's first composed tree plus this change:
- cargo nextest, -p metal2vulkan-air -p metal2vulkan --all-features:
  tests matching indirect or families (145 pass); then, with the
  fixture, buffer_setter_forms, observed_declarations, families_tests,
  engine_indirect_commands, public_fixtures_engine (every llvm_as part
  and the inventory order; the metal_as parts skip off macOS),
  air_input and cache:: (123 tests): all pass but air_input's golden
  printout check, which failed on exactly the 14 SetBuffer lines (7
  engine fixtures under LLVM 21 and 23). With the printouts updated,
  air_input, engine_indirect_commands and the inventory order pass
  (27 tests).
- Release corpus-triage, translation audit of the 12 rows the census
  at fd22785008 refused with Intrinsic::SignatureMismatch (8) or
  Canon::CallTypeMismatch (4), on all 20 committed profiles (--hash-file,
  ms01's corpus index copy). Per profile: 1 translated (on the 15
  profiles with GPU-encoded commands; device_capability_missing on
  lunarg, roadmap, swiftshader, vk12-bare and vk12-floor, as for the
  committed ICB fixtures), 6 unsupported not_implemented
  ArgumentBufferObjects, 1 SignatureMismatch (the ray-tracing kernel),
  4 CallTypeMismatch; defects 0, budget stops 0. Slowest row 34 ms,
  peak worker RSS 20 MB, so far inside 20 s and 500 MiB.
  The 6 ArgumentBufferObjects rows are ICB inheritance functions whose
  builds by other compilers are refused the same way in the fd22785008
  census (which raise site fires is not examined here). That is a
  separate, already typed gap, not a decode fault.
- Authoring-capability census with the fix, --reclassify-all then warm:
  total 16,602 (the 2 new public rows), classified 16,602, remaining 0,
  unresolved 39 (the same 4 families as before); the warm pass read 0
  source bytes.

Versions: SEMANTICS_VERSION 1693 -> 1694. SEMANTICS_VERSION moves: input that was refused now
translates. Version numbers quoted above are the values the work's branch built with.
2026-10-14 20:17:36 +03:00
..