Pooled bound: a texture over bytes another texture was made over takes the image at its pitch

A guest's window server makes dozens of textures over each of its large Private surfaces (other
formats of the same bytes, and a new texture each frame), and past the pooled bound each was a
shadow of its linear cost of its own (216 on a Radeon 780M at a login, 1022 in 13 s on an Iris Xe).
storage_over_buffer decided each texture alone: pooled_pitched_image answered LinearCost for any
tracked texture over a Private buffer past 48 KiB, so every texture over the same bytes made a
full image of its own, copied every texel in at its first use, copied in again after a write
through any other (which lets go of its standing) and copied back whole after a kernel's write.
The shadow log names the buffer's object, not the texture's, so one object's two lines 22 ms apart
are two textures over the same surface, a frame apart.

The bound weighed one texture over the bytes. A buffer now notes the runs of bytes textures were
made over (texture_spans.rs, at most 8 runs, joined where they meet), whether those textures
still live: a texture over bytes another texture was made over takes the DRM_FORMAT_MOD_LINEAR
image at Metal's pitch at any size, as over CPU-visible memory, and the first texture's shadow of
its linear cost moves to that image once another texture is made over its bytes, through the
existing pooled move (wait_to_move_in_place: at the next quiet commit, with no copy). Both forms
give Metal's answer; the textures alias the bytes as Metal's do. The bound has no FAST-PATHS row:
it chooses between two exact speeds (6717cac4ea). API.md, HOWTO and the LinearCost docs say so.

Verified: cargo fmt; builds and device runs follow as potluck jobs.
This commit is contained in:
Anees Iqbal committed 2026-11-11 20:59:46 -08:00
1 parent 150dd334b5
commit 8cb5400e78
11 files changed
+297 -25

No files matched your search

+6 -2
View File
@@ -1894,8 +1894,12 @@ bound.
pitch, the same on every device, such a texture over a `Private` buffer, tracked, stays a shadow
too (`TextureShadowReason::LinearCost`): there a linear image renders and samples slower than the
shadow's own image with its copies, and over memory only the runtime's commands write both give
the same answer (over a `Shared` or `Managed` buffer, and for an untracked texture, the image is
taken at any size, as over host pages);
the same answer, for one texture over the bytes (over a `Shared` or `Managed` buffer, for an
untracked texture, and over bytes another texture was made over, the image is taken at any size:
there each texture's shadow would be an image of its own, copied in whole at its first use and
again after a write through any other; the first texture's shadow moves to its image once
another texture is made over its bytes, at a quiet commit,
`WorkCounts::pooled_textures_moved_in_place`);
or the buffer is over the caller's
`VkBuffer`, whose memory backs no image of the runtime's; or it is a tiled texture of more than
one level (`Buffer::new_tiled_texture`), over any buffer: no image over the buffer's memory holds