A no-copy buffer of Metal's private option bit 24 is a copy of its pages off macOS, beside a read
twin over the pages in place. A slot that only reads a texture over such a buffer binds the
texture's read twin, but only where the twin's texture lies in place over the twin's bytes. Where
it did not (RADV lays no DRM_FORMAT_MOD_LINEAR plane whose rows or first byte are off a multiple
of 256: a window server's 48x48 textures at rows of 192 bytes, its 128x128 ones at rows of 512
from 32 bytes in), the twin's texture was made as a shadow and dropped. The slot then bound the
program's texture, itself a shadow of the copy for the same reason, so its command buffer used the
copy and its commit compared the whole copy with the pages.
Workload reason (reims's appwalk17 desktop walks, numbers only): twin textures not in place
780M 362, RTX 3090 304, Iris Xe 1; copies compared 52,537 (2,897 MB), 43,384 (2,138 MB) and 331
(35 MB); the Iris compared in one walk step only, the one that made its one twin not in place.
Copies compared plus twin slot reads come to about the same total on all three (56,775, 52,277,
54,233): every such read that missed a twin read the copy.
Now the twin's texture is kept as a shadow of the twin's bytes where the program's texture is a
shadow too, and the slots that only read the texture bind it under the same proof as before. The
program's texture lists it beside its own shadow (shadow::texture_copies, held weakly), so draws,
rebound draws, dispatches and resident textures copy it in from the pages in place at its first
use in each command buffer, where they copied the texture's own shadow in from the copy (a shadow
of a copy of Shared memory never stands). Where the pages carry a log of their writes only the
changed rows move. The command buffer names the twin's and the shadow image's keys, never the
copy's, so its commit compares nothing. No store reaches the pages: the twin's one GPU access is
the copy in's read, the shadow is the runtime's own image no call returns, the slots only read it,
and a copy back would write the twin's key, which every encoder refuses.
Discrete devices take it too: their copy lies in system memory (MemoryClass::Shared), as the
pages do, so the shadow's copy in crossed the bus before and crosses it now; what goes is the
CPU's comparison. Cost: an image of the texture's size per such texture while it lives.
- WorkCounts::read_twin_texture_shadows (new field). No new Degradation kind.
- The shadow log's twin line says whether the twin's shadow serves the read slots.
- cfg(test) DeviceShared::linear_pitch_rule_forced: RADV's LINEAR plane rule at Device::unplaced.
- Tests (read_twin_device): the two shapes sampled by a draw and the 128x128 one read by a
kernel through the twin's shadow (compares 0, a CPU write read next, a fill read back through
the copy, pages kept); over logged pages the second command buffer copies nothing in and a told
write moves its rows alone. The screen-sized texture lavapipe lays no image of now reads its
twin's shadow too.
- Docs: read_twin.rs, shadow_log.rs, API.md and the FAST-PATHS row on bit-24 memory;
api_signatures.tsv (+1).
Verified (msi lavapipe, m3-max-29778 at 69f0a567b1): clippy plain and --cfg m2v_cpu_icd 0;
read_twin_device, copied_device, copied:: units, texel_rows_device, dirty_pages_device and
waited_reads 73/73; api_signatures and fast_paths 35/35. With RADV's LINEAR rule forced (offset
and pitch multiples of 256): 48x48 at pitch 192 and 128x128 at pitch 512 offset 32 sampled by a
draw and read by a kernel: twin slot reads +1, compares 0, texels the pages', a CPU write read
in the next command buffer; a fill in the same command buffer reads back through the copy with
one compare, pages kept; over a dirty log an unchanged twin copies 0 bytes. Negative control
(serves cut back to in-place only): the 3 new tests fail, the commit compares the copy.