Files
metal2vulkan/docs
Anees Iqbal 39b0efc6e7 rt: a release waits for the command buffers committed before it, one commit-order mark for textures, samplers, idle allocations and imports
What: one mark (memory::Wait) for everything a command buffer may reach with no handle of it.
A release notes the last commit's place in the commit order. It goes once every command buffer
committed up to there is submitted (Work::settled) and that submission completed. With none in
flight (a count kept from commit to retire) it goes at once, as before.
- What waits:
  - a texture's index (its set-1 elements), views and image, and its shadow view;
  - a texture view's views;
  - a sampler state's index and its device samplers;
  - an idle allocation's free;
  - an imported or exported block's free, and with it the import's release.
- How the objects and indices go: the block-maker thread holds them in one FIFO (Pool::release)
  and hands each to the reaper once its wait is over; teardown frees what is left. With nothing
  in flight, an index is vacated on the releasing thread, so its grant may be returned at once.
- What is unchanged: a displaced index; attachment views, pipelines and modules, which their
  command buffers keep. The loose memory (texture allocations, surface plane imports, copies'
  staging) takes no second wait: it comes from the reaper's frees, or from copies.
- New: Gauges::releases_waiting counts what waits. Every device test's teardown reads it zero, and
  the harness compares it at runs 100 and 200.
- Consumer-visible: Gauges gains a field (non_exhaustive, so nothing breaks). release_indices
  refuses IndicesInUse for an index whose texture or sampler state was released under work in
  flight, until that work retires (docs/REFUSALS.md regenerated). A command buffer parked at an
  event wait holds every such release after its commit until it retires (README, in the memory
  and the set-1 paragraphs).
- Docs: new_texture's doc and the README take the new contract and Metal's own answers (the
  consumer's game tool on two Macs, from main), and api_signatures.tsv is blessed for the field.
- Test: one ordinary test, argument_tier's held release. A command buffer at an event wait holds
  a 17 MiB allocation's free and a released texture's index past twice the idle age; once it
  retires, both go. The two hazard tests of the commit before run on a CPU device always, and
  pass only with this.

Why: the consumer's game step loses the device on RTX 3090s (Xid 13, MMU faults). The game tool
remakes heap textures every frame and drops the old ones at once, while the frame in flight still
samples them through set 1 by resource ID, naming only the heap. Before this, rt nulled the
elements and destroyed the views and image at once, under that pass.

Product lines (comments left out): +171 -23 in crates/metal2vulkan-runtime/src.

Verified at this commit: cargo fmt; scripts/api-signatures --check after its bless (the one new
line is Gauges.releases_waiting); docs/REFUSALS.md regenerated (IndicesInUse's row). Before-run on
ms01's RTX 3090 at 2d0c57661d (job m3-max-62569): the address test (argument_tier) hung the GPU
(Xid 109 CTX SWITCH TIMEOUT, no loss rt saw, Xid 31 at teardown). The texture test showed no Xid,
and its lines were lost (the leg's buffered pipe). Its gate and its after-fix hazard run follow
this commit; main's landing names them.
2026-11-21 01:59:43 -08:00
..