Files
metal2vulkan/crates
Anees Iqbal cfd7bc829e One page, one import: a buffer over a live import's pages lies inside it, else a copy
VK_EXT_external_memory_host leaves a host allocation imported twice into one device
undefined (issue 6: "Some platforms do not allow locking the same physical pages for device
access multiple times, so attempting to do it may result in undefined behavior"). The runtime
imported the same pages twice in several ways: a heap's own import was never noted in
HostAliases, so a no-copy buffer over exactly a heap's bytes, or over part of them, imported
them again (the consumer's guest heaps over 2 MiB page-block views, and the block's view as a
buffer); a buffer over part of a live buffer's bytes imported its own (counted,
object_churn.imports_inside_live: 34 in one 3090 walk); and a heap over a live buffer's bytes
imported its own.

Now:
- a heap's own import is noted (HostAliases::hold), joining no key;
- a buffer or heap over exactly a live import's bytes lies in that import (a heap keeps its
  heap identity);
- a buffer whose window a live import holds all of is bound inside that import's memory at
  its offset, with a VkBuffer of its own and no import (Device::bind_in_import,
  Placement::in_import, which holds the import; the import is exposed, so never released
  while idle); counted object_churn.buffers_bound_in_import;
- a buffer or heap whose window a live import holds some of and not all, and a heap a live
  import holds more than, is a copy (CopiedBecause::OverImport, copied_over_live_imports,
  announced copied-host-pages);
- rebinds take the same rule;
- imports_inside_live now counts only imports made where a live one held some of the pages
  all the same (two buffers made at once).

Tests: host_aliases unit test a_page_a_live_import_holds_is_never_imported_again; device
tests one_import (heap first, buffer first). Not yet run: this commit is for the build.
2026-11-11 19:01:50 -08:00
..