From bfcd71e5d6842e460e8d6e7f9e3d9bee3666a26d Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 8 Nov 2026 08:57:05 -0800 Subject: [PATCH] Record the short last row's shadow among the known gaps A texture over host pages whose buffer ends inside its last row's pitch is a shadow (Refused(Placement)): a linear image's last row takes the whole pitch, so the image's memory requirements reach past the buffer's bytes, over an import of the caller's pages and over a copied host buffer's copy alike, whose placement is the buffer's length. Metal reads such a texture in place, so it is a runtime cost above the driver's: docs/FAST-PATHS.md's known gaps now say so, and InPlaceRefusal::Placement's doc names the case. Seen on the Iris Xe (ANV) and the 780M and RX 550 (RADV) by a probe at the guest's shape, which stays on a branch of its own. Verified: cargo fmt; scripts/api-signatures --check (signatures unchanged; a doc change). (cherry picked from commit 9493894b26cee3b1a525d9a0916a83f3fc6a594f) --- crates/metal2vulkan-runtime/src/texture_placement.rs | 4 +++- docs/FAST-PATHS.md | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan-runtime/src/texture_placement.rs b/crates/metal2vulkan-runtime/src/texture_placement.rs index 53a8b3b5d..095b2d234 100644 --- a/crates/metal2vulkan-runtime/src/texture_placement.rs +++ b/crates/metal2vulkan-runtime/src/texture_placement.rs @@ -192,7 +192,9 @@ pub enum InPlaceRefusal { Image, /// No image the device makes lays the rows (or slices) at the buffer's pitch. Pitch, - /// The image's alignment, size or memory type misses the bytes' place. + /// The image's alignment, size or memory type misses the bytes' place: among them a texture + /// whose buffer ends inside its last row's pitch, whose image's last row takes the whole pitch, + /// past the buffer's bytes (`docs/FAST-PATHS.md`, known gaps). Placement, /// Over pages imported as dma-bufs: the caller's source made no one dma-buf of the texture's /// own pages. diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 88e23abb5..8134a2e9a 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -447,6 +447,14 @@ driver's. Each is open work. creation never fails because of a hang. Where a wait found the loss first, the call waits for the recovery and goes on. +- **A texture over host pages whose buffer ends inside its last row's pitch is a shadow** + (`InPlaceRefusal::Placement`, `WorkCounts::host_texture_shadows_refused_placement`, + `shadowed-texture`), where Metal reads it in place: a linear image's last row takes the whole + pitch, so the image's memory requirements reach past the buffer's bytes, which are not the + runtime's to bind. So over the caller's pages imported by their pointer and over a copied host + buffer's copy alike, whose bytes are the buffer's length (ANV on the Iris Xe, RADV). The shadow + copies the texels in before each command buffer that uses the texture and merges them back + after each write. - **A copied host buffer costs O(its size) at every batch's completion that may have written it, and at every commit where its pages carry no log** (`copied.rs`, `copied-host-pages`): each compares every byte of the copy with the bytes the copy and the pages last agreed on, a page at