Files
metal2vulkan/docs
Anees Iqbal ea9b65a972 rt: Device::new_exported_block, one dedicated exportable allocation per block
The consumer's video path shares decode surfaces with a hardware decoder: the decoder imports
rt's memory and writes decoded frames into it. Metal has no counterpart, as it has none of
presenting.

The form is one on every device: an allocation of its own in the Private memory type,
dedicated to the one buffer that spans it (VkMemoryDedicatedAllocateInfo), exportable as the
handle the consumer names, never a range of a pooled allocation. Vulkan lets a driver require a
dedicated allocation for an export (VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT), so the
dedicated form is the one every driver takes, and what exportable memory costs each submission
falls on these allocations alone.

- ExportHandle: OpaqueFd (unix), DmaBuf (unix), OpaqueWin32 (Windows). A handle is offered
  where the device lists its extensions and vkGetPhysicalDeviceExternalBufferProperties says its
  buffers export it; elsewhere Limit::NoExport, before anything is allocated.
- A dma-buf's other side is another driver, which an ownership transfer names as
  VK_QUEUE_FAMILY_FOREIGN_EXT; without VK_EXT_queue_family_foreign that family may not be named
  (VUID-VkBufferMemoryBarrier2-srcQueueFamilyIndex-09099), so a dma-buf export there is
  Limit::ExportType { listed: None }. A buffer whose memory requirements do not list the
  Private type is Limit::ExportType { listed: Some(bits) }.
- Export carries the new handle (the consumer's to close), the allocation's size and its memory
  type, which an import of an opaque handle names again
  (VUID-VkMemoryAllocateInfo-allocationSize-01742, and the dedicated import of
  VUID-VkMemoryDedicatedAllocateInfo-buffer-01879).
- The extensions stay out of the floor: VK_KHR_external_memory_win32 and
  VK_EXT_queue_family_foreign join the optional list, enabled where listed.
- Gauges::exports counts exported blocks whose memory is not yet freed; the block-maker thread
  frees them as it frees imports (memory::Own).
- No image is made in an exported block's memory, which is dedicated to its buffer
  (VUID-vkBindImageMemory-memory-10926): a texture over a buffer in it takes the counted copy,
  as over an import, and a heap texture in it is Gap::HeapTexture.

docs/REFUSALS.md regenerated; api_signatures blessed; the rt README has the call, its
extensions and its known gap.

Tests (src/tests/export.rs, device cfgs): every offered handle exports, is written by rt,
released by the test's own barrier and read back through a second device's import of the
handle, with the gauge back after the free; every other handle is refused typed; an exported
block holds no image; and the submit cost with 64 live exports against none, printed.

Verified at this commit: cargo fmt only. The lane's build (clippy plain and under both device
cfgs, Rustdoc, signatures, refusals) and device legs run on the tip that carries it.
2026-11-19 01:50:13 -08:00
..