Files
metal2vulkan/docs
Anees Iqbal 0043991660 RUNTIME 2269: a bit-24 no-copy buffer's blit copies read its pages in place through a read twin
Off macOS, a no-copy buffer made with Metal's read-only option bit 24 is a
copied host buffer (CopiedFor::ReadOnly) whose copy takes every write; every
commit that used it compared the whole copy against the pages (reims's
12.7.6 walk: 130,448 MiB compared, 34,462 compare threads, copy-in bytes 0).

Now such a buffer also gets a read twin: the runtime's own buffer over the
same pages, imported in place, outside the Metal address space (key bit 63),
made only under the Contained policy and only where the pages import in
place (never a copy). copyFromBuffer:toBuffer and copyFromBuffer:toTexture
read through the twin until an earlier command of the same command buffer
may have written the buffer (a write of its key, writes_unnamed, or unnoted
uses); after that they read the copy, so the command buffer reads its own
dropped write back and the next command buffer reads the pages. Every
encoder refuses a command whose own uses write a twin key: it records
nothing and fails its command buffer. The twin is placed over the bytes
before its buffer, so a twin use does not drag in the copy.

Counted: read_twins_made, read_twins_unimported, read_twins_uncontained,
read_twin_blit_reads, read_twin_reads_after_writes, read_twin_writes_refused,
copied_copy_ins_compared, copied_copy_in_bytes_compared. Docs edited in
place: the FAST-PATHS row "Off macOS, GPU writes into read-only memory",
API.md's copied-host-pages and private-resource-option rows, read_only_view.rs.

RUNTIME_VERSION 2269: blit sources of bit-24 buffers read in place.

Verified (roip, lavapipe m3-max-28537 at ad4ed6a591, 40/40 read_twin_device|copied_device):
a 29,753,344-byte (3648x2038x4) buffer's copyFromBuffer:toTexture + buffer copy
compare [0 copies, 0 bytes, 0 threads] (was [1, 29,753,344, 7]), texels and
bytes match the pages; fill + copy-out in one CB reads the fill back, pages
unchanged, next CB in place; blit fill, blit copy-in and a kernel store through
a loaded pointer at gpuAddress leave the pages; a fill of the twin is refused
(negative control: with the guard off it changes the pages); no twin when the
import is refused, over read-only pages, or under UnsafeOff. Owed after
landing: 5080, clippy x3, rustdoc. Next steps: sampled textures over the buffer,
buffer slots, resident sets.

Squashed from steelbrain/roip 4d4bef55bd..ad4ed6a591 (encoder.rs import
conflict with RUNTIME 2268's encoder_fold resolved by keeping both).
2026-11-14 01:14:50 -08:00
..