Files
metal2vulkan/crates/metal2vulkan-runtime/examples
Anees Iqbal 76d89d87a8 See an event signal behind a copied host buffer at its completion turn
An event signal behind a copied host buffer is seen at the batch's completion turn, and the
copied host pages' cost is announced as the catalogue states it.

One work packet, landed as 4 commits on archive/development-linear-2026-10-29, in order:

* See an event signal behind a copied host buffer at its completion turn (8fc9c56dcb)

A batch's event signal is its GPU signal of the event's timeline semaphore,
and the host read the semaphore's counter directly (`EventShared::value`),
while a copied host buffer's GPU writes reach the caller's pages only at the
batch's completion turn (`completion.rs`, merge then `reached`). So a CPU
that saw the value could read the pages before the GPU's writes, and a plain
event's wait chained on the VkQueue let another queue's work start before
them: Metal's writes before a signal are in the pages once its value is
seen (the documented gap in FAST-PATHS, now closed).

A signal kept while the device holds a live copy is marked behind the merge
(`EventTimeline::keep`). No counter read observes it or any signal after it,
and no wait is handed its index (the scheduler's own host wait included); a
plain event's wait for it is held as a shared event's is. The completion
turn, which merges first, observes it and wakes every host wait and held
batch. The signal stays the batch's GPU signal: no submission is added. The
cost per such signal: its value reaches readers one completion turn later
than the counter shows it, and a GPU wait for it is a host hold plus a
vkQueueSubmit at that turn. Counted: WorkCounts::event_signals_behind_merge.
The same mechanism will hold for the GPU-kept copies.

RUNTIME_VERSION 1699 (renumbered at landing).

Verified on the M3 Max (MoltenVK), --cfg m2v_gpu, under memcap and maclock:
57 copied, event, scheduler and fast-path tests pass, among them the new
a_shared_event_s_value_is_seen_once_the_copy_s_bytes_are_in_the_pages
(six rounds, spin reads and host waits, a 64 MiB copy beside to lengthen
the merge) and the timeline unit test
a_signal_behind_a_merge_is_seen_at_its_completion_turn_alone. Negative
control: with the mark off, the device test fails on the byte check
("the write is in the pages once the value is seen"). clippy (plain and
--cfg m2v_gpu) on metal2vulkan and metal2vulkan-runtime, api_signatures
re-blessed (the new field), api_surface pass.

RUNTIME_VERSION 1700.

* Re-pin the runtime sources at the landing tip (2cef515da6)

* Announce the copied host pages' cost as the catalogue states it; list what pack.rs reaches (e9ba27478b) (its crates/metal2vulkan-runtime/src/degradation.rs part)

The final gate on 3e20b58763 failed two tests.

- degradation_catalogue: the signal-behind-merge fix (8fc9c56dcb) closed the
  shared-event gap and rewrote the API.md entry for copied-host-pages, but the
  runtime still announced "(behind a shared event's value among them)". The
  announced cost now drops it, so the catalogue's entry starts with it word
  for word again.
- the_runtime_sources_are_the_committed_ones: pack.rs became a runtime input
  (the mipmap kernel's sRGB transfers), and it also reaches
  metal2vulkan-air's intrinsics, lower/arith/math.rs and lower/arith/narrow.rs
  through its pack and unpack intrinsics, which only the compile emits. They
  are listed as not runtime with that reason. The stale comment about
  srgb.rs's encode, tables and steps (deleted by the mipmap and n7 packets)
  now says only what is true.

Verified: the two tests on the landed tip (see the landing).

* Re-pin the runtime sources at the landing tip (538f3f1161)
2026-10-29 15:43:54 +02:00
..