Files
metal2vulkan/docs
Anees Iqbal 131887a2e1 Merged draw replays take indexed draws, and each fragment its own command's slot table
A render execution whose records a kernel writes ran on the host step wherever the buffer's
command types held DRAW_INDEXED, and the merged form refused any fragment function that reads
buffers, since one merged draw had one fragment slot table. Now both stay on the GPU.

- Indexed draws (DrawReplay::indexed, from draw_replay_indexed over the decided writes). The
  preprocess holds an indexed record where the policy and the INDEXED flag allow it: its
  arguments are [index count, instances, base vertex, base instance], and it writes a 16-byte
  index entry per command (the device address of the first index, its offset rounded down to the
  index size; the whole indices to the buffer's end; the size, 2, 4 or 0 for a draw without
  indices). An index buffer of address 0 or a bad index type is a RECORD fault; an address no
  resident range holds draws nothing and counts a resident miss; a position past the buffer reads
  index 0, as the encoder's indexed draw reads it. The merged vertex reads its vertex as the index
  at its position plus the base vertex, a u16 from its aligned word. An indexed replay that does
  not merge is refused (ReplayRefusal::IndexedApart): the runtime host-steps it
  (HostStepCause::Rule).
- Per-command fragment tables. The merged vertex writes its command to a flat uint varying
  (IoRole::MergedCommand, VaryingKey::merged_command). A merged fragment that reads buffers takes
  it as an input and MergedDrawAddress as its push field, and reads its RootTableAddress as the
  header's tables plus command times the stride plus the fragment table's offset
  (bind::merged_fragment_table). The header grows two words (H_INDICES_AT 48, H_FRAGMENT_TABLE
  52; MERGED_HEADER_BYTES 56). A fragment that reads [[primitive_id]] keeps the merged variant
  refused, so its executions host-step, as before.
- Runtime (render/executions/gpu.rs): indexed executions take the merged form alone, no
  per-command fallback; one whose type does not merge host-steps with the rule named. The
  host-replayed-indirect-commands notice text names indexed draws that do not merge.
- The fixture icb_merged_indexed (ours: kernels writing indexed draws of 16-bit and 32-bit
  indices with per-command vertex marks and fragment tints), its AIR companions compiled by
  scripts/regen-air-fixtures on the M3, and its AIR input golden.

Verified:
- metal2vulkan's draw replay, merge, stage IO, varyings, link and API tests, among them the new
  interpreter test of seven indexed records (u16 and u32 offsets, base vertex -1 over two
  instances, indices past the buffer, a residency miss, a bad type, a null buffer): 354/354
  (potluck m3-max-20787, msi).
- Clippy in every configuration (all features, each feature alone, the runtime, --cfg m2v_gpu)
  (m3-max-20812, msi); Rustdoc of both crates and 379/379 tests of the replay, AIR goldens, stage
  IO, API tables, refusals and catalogue (m3-max-20824, msi).
- The new lane test merged_indexed_draws_draw_what_the_host_step_draws (16-bit and 32-bit: six
  commands merged on the GPU with no record read, each fragment its own command's tint, the
  same pixels as the host step's) with the other merged and range-read lanes: lavapipe 12/12
  (m3-max-20811, msi), RADV Radeon 780M 10/10 (m3-max-20814, um790).
- The golden icb_merged_indexed.txt was blessed under the pinned llvm-as (m3-max-20792); no other
  golden moved.

The semantics and artifact format bumps, the golden re-bless and the census stay with the
landing.
2026-11-12 05:39:20 -08:00
..