Keep a tiled texture's own image through a detach, its first level the bytes' last texels

A tiled texture of more than one level (Buffer::new_tiled_texture) over a no-copy
buffer presented the shared zero stand-in at every level while the bytes were
detached, and refused CPU access at every level (DetachedTexelAccess). On a Mac its
later levels are the texture's own memory, which a detach leaves, and its first
level the pages it took, whose last bytes its CPU access reaches.

The texture's image is its own, so it now keeps presenting it: noted with keeps
(NotedTexture::keeps), it takes no stand-in at the detach (TexturesOver::images
leaves it out, and so do the stale-reach notes) nor at its making over detached
bytes. Before anything is detached, the detach loads its first level with the
bytes' texels as they are then (keep_first_levels, Texture::keep_first_level: a
get_bytes of the pages, then a write into the image), so an unnamed read and
get_bytes read the last texels, those the CPU wrote after the last copy in
included; a replace_region of that level stays refused. The later levels are read
and written in the image as before. Once the bytes lie in pages again the first
level copies them in at its next use. The load reads the level's texels once on
the host (11.7 KB for WindowServer's 54x54) and stages one copy for the next
submission, at a detach only.

Docs: the item's rustdoc says the difference (its first level reads its last bytes
while detached, where a texture over the pages alone reads zeros), with its other
levels' rule and the copies of item 1 and 2; detach.rs, stand_in.rs,
DetachedTexelAccess's doc and docs/API.md. REFUSALS regenerated (unchanged), api
signatures checked (no change).

Verified by the device tests: see the tip's evidence.

(cherry picked from commit 87435362577424f2e7757ff69bcb292b401dc9ed)
This commit is contained in:
Anees Iqbal committed 2026-11-08 02:57:26 -08:00
1 parent 73e7638e4c
commit 3feb4b3a55
7 files changed
+175 -37

No files matched your search

+6 -1
View File
@@ -431,7 +431,12 @@ command boundaries, not an alias, and a CPU write made while a command buffer th
reaches it at the next copy in. Its other levels are its image's own memory, zero when made in a
`Shared` or `Managed` texture; blits (`generate_mipmaps` among them) and functions use every level,
and `get_bytes` and `replace_region` reach the first level in the bytes and the others in the
image. A texture of one level is `new_texture`'s, in place where that is.
image. A command that uses its other levels alone copies nothing. While the buffer's bytes are
detached (`detach_backing`) it keeps its own image: its first level holds the bytes' last texels,
which the detach loads into it and which an unnamed read and `get_bytes` read (a `replace_region`
of that level is refused, `NotImplemented(DetachedTexelAccess)`), where a texture over the bytes
alone presents a stand-in of zeros; its other levels keep their texels, read and written as before.
A texture of one level is `new_texture`'s, in place where that is.
On a discrete GPU, a `Managed` texture over a no-copy buffer's bytes (not an IOSurface plane's)
that only samples or reads, whose policy takes the image in place, over memory that carries a log
of its writes (`HostMemory::with_dirty_pages`), tracked, one slice laid out as one copy, is instead