Files
metal2vulkan/docs
Anees Iqbal fc021c92d8 replay: a released index is kept back until every commit before its release has retired
The runtime leaves its consumer the duty never to place at an index pending work may use: a
placement writes the index's set-1 elements, which Vulkan does not define while a pending
command buffer uses them, and a consumer keeps a released ID back until every command buffer
committed before the release has retired (runtime README, "An index has one owner"). The player
stands in for that consumer, but owed an index only to the commits of command buffers that named
its object. A command buffer that reached the object through an ID in memory, and the play's own
blits and copies, owed nothing, so a play could make the undefined write.

Indices::give now owes the released object's index to every commit so far, in commit order. The
naming path stays for command buffers not yet committed at the release, and for a live object a
later one displaces.

A placement owed to a commit held on records not yet played (its command buffer waits for an
event only a later record signals, or is behind one that does on its queue) cannot wait for it
without a deadlock. It used to take the index anyway, counted. It is now kept back: the object
takes the highest free index of its class that no commit in flight is owed, outside the
program's sequence, counted on 'indices kept back N: ...' (it replaces 'indices given while a
commit they owe is held N'). The held buffer reads the object it bound. The kept object's ID
differs from the one the program saw, and the id lines report it. A placement waits only where
no owed commit is held, so every wait can end.

An index the player chooses itself skips one still owed instead of waiting or ignoring it: a
constexpr sampler's (the highest free sampler index; it never waited before) and a texture's
outside the program's IDs (place_outside). A sampler state equal to the one placed last at its
index still takes it without waiting: the runtime writes no element for it.

Tests:
- rt_replay an_index_released_after_a_held_commit_is_kept_back_though_it_names_nothing is the
  forced-order test. Held command buffer #6 binds nothing and was committed before #5's
  release, and its event holds it past #8's placement. #8 must take the highest sampler index,
  counted.
- a_placement_a_held_commit_owes_is_kept_back_and_counted replaces the old take-without-waiting
  test.
- The Indices unit tests cover a release owing every commit before it, and top skipping an owed
  index.

Docs: docs/REPLAY-STREAM.md section 5 (resource IDs, textures outside the program's IDs) and the
backend's report paragraph; the indices.rs module doc.

Verified by the compile and suite jobs named in the hand-over.
2026-11-21 05:28:13 -08:00
..