Off macOS, drop the GPU's writes to bit-24 no-copy memory through a copy
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)
This commit is contained in:
1 parent
3525993ad2
commit
3eb84d76c6
24 files changed
+333
-212
No files matched your search
+13
-8
@@ -2133,11 +2133,11 @@ bound.
|
||||
Metal placed one.
|
||||
- `metal2vulkan-degrade-private-resource-option` (precision). `PrivateResourceOption`: A heap of
|
||||
the runtime's memory or an indirect command buffer made with `MTLResourceOptions` bit 24
|
||||
(`ResourceOptions::PRIVATE_BIT`), or off macOS a no-copy buffer or heap over the caller's bytes,
|
||||
which Metal makes and keeps the GPU's writes from the memory of, is made as without it, and
|
||||
reports its options without it, as Metal's does. On macOS a no-copy buffer or heap with the bit
|
||||
drops the GPU's writes as Metal's does, its pages imported through a read-only view of them,
|
||||
announcing nothing. A buffer of the runtime's memory or a texture descriptor with the bit is
|
||||
(`ResourceOptions::PRIVATE_BIT`), which Metal makes and keeps the GPU's writes from the memory
|
||||
of, is made as without it, and reports its options without it, as Metal's does. A no-copy
|
||||
buffer or heap with the bit drops the GPU's writes as Metal's does: on macOS its pages are
|
||||
imported through a read-only view of them, announcing nothing; elsewhere it is made over a copy
|
||||
of them that drops the GPU's writes (`copied-host-pages`). A buffer of the runtime's memory or a texture descriptor with the bit is
|
||||
refused, as Metal ends the process there; a buffer placed in a heap without the bit is made as
|
||||
without it, announcing nothing. Cost: the GPU's writes reach the resource's memory, the CPU and
|
||||
later command buffers, where Metal's never reach them.
|
||||
@@ -2812,7 +2812,12 @@ bound.
|
||||
with plain loads where the process maps every page readable. Pages not mapped, or mapped
|
||||
without read permission, are never copied: the buffer is refused, as their import is. A copy
|
||||
whose own allocation fails refuses the call (`OutOfMemory`). Memory whose GPU writes Metal's
|
||||
private option bit 24 drops is never copied. A buffer's or heap's rebind is copied the same way,
|
||||
private option bit 24 drops is copied off macOS alone, where no import keeps the GPU's writes
|
||||
out of the pages, the gate not asked (`copied_read_only_memory`): the copy drops the GPU's writes
|
||||
as a copy of read-only pages does, though a command buffer committed before the writer's batch
|
||||
completed may still read them, and a render pass's store-out into it completes where Metal's
|
||||
faults its command buffer. On macOS the pages are imported through a read-only view of them. A
|
||||
buffer's or heap's rebind is copied the same way,
|
||||
its heap's bound textures and its images in place made again over the copy, and a buffer's
|
||||
rebind to bytes at another offset in their page under a texture planned at the old one is a copy
|
||||
laid out there (the detail says which). A buffer made over exactly the bytes (the same first
|
||||
@@ -2823,8 +2828,8 @@ bound.
|
||||
accesses; a rebind to them does too where its textures were planned at the copy's offset and no
|
||||
image in place rides on it. A heap's own buffer and memory whose GPU writes are dropped keep
|
||||
their own. Counted: `WorkCounts::copied_host_buffers_made`, of them
|
||||
`copied_host_buffers_refused`, `copied_host_buffers_degraded` and `copied_rebind_pages_moved`
|
||||
(and `copied_heaps_made`, `copied_rebind_pages_made`, `copied_rebind_images_made`); each such
|
||||
`copied_host_buffers_refused`, `copied_host_buffers_degraded`, `copied_rebind_pages_moved` and
|
||||
`copied_read_only_memory` (and `copied_heaps_made`, `copied_rebind_pages_made`, `copied_rebind_images_made`); each such
|
||||
buffer, and each buffer placed in such a heap, answers `Buffer::host_backing` with
|
||||
`HostBacking::Copied` until its next rebind or detach. Cost: the GPU
|
||||
uses a copy of
|
||||
|
||||
Reference in new issue
Block a user