Files
metal2vulkan/crates
Anees Iqbal 9e335aae31 HostRam: no run imported alone where barriers miss aliased imports (MoltenVK)
What:
- RuntimeDriverDefect::AliasedImportBlitsUnordered (metal2vulkan::error): a
  pipeline barrier between two blits does not order them where they reach the
  same host pages through two imports, which Vulkan counts as aliases of one
  memory ("Memory Aliasing": memory bound through external memory import
  mechanisms). MoltenVK has it (driver_defects.rs: its barrier between blits
  ends the Metal blit encoder and leaves the order to Metal's hazard tracking,
  which is per MTLBuffer, and each import is an MTLBuffer of its own).
- On a device with it, RamOnDevice::for_object never binds an object in an
  import of its own run: the object imports the chunk, or waits for the
  thread's import of it, so every object over a chunk's pages lies in the
  chunk's one import, which Metal orders, as before the run imports.
- The HostRam device tests hold both forms (runs_alone): the window, the
  downward run and the ordering test assert the run imports where the device
  orders aliased imports, and the fallback (no run import, the chunk imported
  by the object, which waited for it) where it has the defect. The ordering
  test asserts the order on every device.
- host_ram.rs states the trade the run imports make: up to one more
  allocation and pin per object made while its chunk is not imported, for the
  object's life (128 of the bench's 256 upward heaps on the RTX 5080 laptop).
- Docs: the defect's variant and table entry, host_ram.rs, Device::use_host_ram,
  HostMemory::with_runs, WorkCounts::run_bound_buffers_made; the defects test
  lists it for MoltenVK; api_signatures.tsv. REFUSALS.md regenerated
  (unchanged: no refusal names it).

Why: on the M3 Max (macOS 27.0.1, MoltenVK 1.4.2) at 2b2419c67c,
tests::host_ram_device::a_run_bound_and_a_chunk_bound_buffer_over_the_same_pages_order_by_their_host_bytes
failed: "run to chunk: the copy in one encoder read the fill" (stale bytes;
the runtime's command barrier was recorded, command_barriers grew). The same
test passes on the RTX 5080 laptop (NVIDIA 615.71.09), in one encoder, two
encoders and across queues. HostRam on a Mac is not a product path (the
consumer uses its Metal arm there), so losing the no-wait gain on MoltenVK
costs nothing real; the ordering holds on every device.

Verified: cargo fmt; scripts/refusal-surface/refusal_surface.py (no change).
Build, clippy and tests run through potluck jobs after this commit.

(cherry picked from commit 3eb01a011f20ac5aa96c134b50b15219c93c1a34)
2026-11-05 02:08:32 -08:00
..