Metal drops what a shader or the blit engine writes into no-copy memory
made with its private option bit 24: the write completes with no error,
a later command of the same command buffer may read it back, and neither
a later command buffer nor the CPU sees it (probes/readonly_gpu_writes.m,
an M3 Max under macOS 27.0.1; the owner's ruling of 10-23: drop, never
refuse, on every driver). macOS imports the pages through a read-only
view of them. Elsewhere the import was of the caller's own pages, so the
GPU's writes reached the pages, the CPU and later command buffers
(host-page-writes-kernel-store-read-only and
host-page-writes-visibility-read-only diverged on llvmpipe and the RTX
5080), announced as private-resource-option. No import can keep the
writes out there: Linux drivers pin imported pages for writing, and ANV
lost the device and RADV failed every submission over read-only imported
pages.
So off macOS such a buffer, heap or rebind is made over a copy of the
pages whose GPU writes are dropped, the mechanism copied.rs already has
for pages the process maps read-only: each commit copies in what the CPU
changed, later commands of the batch read the GPU's writes, and the
batch's completion puts every byte the GPU changed back, writing nothing
to the pages. The gate is not asked (nothing is imported), the copy joins
no other buffer over the bytes, and a rebind whose bytes moved in their
page is now a copy laid out at the old offset rather than refused.
- buffer_descriptor.rs: buffer_over_host_memory makes the copy
(CopiedFor::ReadOnly) where drops_writes and the system maps no
read-only view; the rebind path copies the same way (read_only_copy);
copied_buffer takes why it copies, and passes read_only to
CopiedBuffers::add and drops_writes to the buffer's HostCell.
no_copy_options moves here from degradation.rs and no longer
announces private-resource-option off macOS (that notice stays for a
heap of the runtime's memory and an indirect command buffer).
- copied.rs: add() takes read_only, which drops the copy's GPU writes
whatever the pages' protection.
- buffer.rs: BufferParts carries drops_writes into host_lie.
- New: CopiedBecause::ReadOnly, WorkCounts::copied_read_only_memory.
- Docs: read_only_view.rs, copied.rs, capabilities.rs (the answer stays
no off macOS), values.rs, host_backing.rs, interop.rs, host_aliases.rs,
error.rs (RebindTextures is macOS-only now), degradation.rs, docs/API.md
(private-resource-option, copied-host-pages), docs/HOWTO.md and the
docs/FAST-PATHS.md known gap: off macOS a command buffer committed while
the writer is in flight still reads its writes, and a render pass's
store-out into the copy completes where Metal's faults.
- Tests: degrade_notices' bit-24 lane tests assert the writes are
dropped on every driver and count the copies (3 and 1 off macOS, 0 on
it) and the kinds (copied-host-pages off macOS, none on it);
copied_surfaces' dropping buffer is a copy of its own off macOS.
- host-page-writes read-only rows declare copied-host-pages in place of
private-resource-option; their 8 ledger rows are removed.
- api_signatures.tsv blessed for the new field.
Verified: see the replay and lane-test jobs named in the branch report
(lavapipe, the RTX 5080 through b5080, MoltenVK on the M3).
(cherry picked from commit 1f24b1f035d61f093ecf2c76fae4b9c2e4b541d9)