Files
metal2vulkan/docs
Anees Iqbal 8d617591f8 RUNTIME 2409: In-place textures over dma-buf pages: the image bound in the buffer's own import
A texture in place over a no-copy buffer's dma-buf pages no longer always asks the pages'
source for a new dma-buf and a dedicated import of its own. Where the pages lie in one import
dedicated to nothing (no sparse buffer over several imports, no import the driver made
dedicated to the buffer), its DRM_FORMAT_MOD_LINEAR image whose plane lies at offset 0 at the
texels' pitches is bound in that import at the texels' offset, beside the buffer
(vkBindImageMemory's memoryOffset): no udmabuf, no import, no new GPU mapping. Every fact is
asked of the driver: the image requires no dedicated allocation (VUID-vkBindImageMemory-
image-01445), the format query takes dma-bufs for it outside one (not DEDICATED_ONLY), its
alignment divides the offset (-None-10735), its size fits the pages' placement (-None-10737)
and its memory types take the import's. An import dedicated to the buffer binds no image
(-memory-10926): DmaBufPages now notes that.

A new check class, PagesClass::DmaBufInImport (CHECK_VERSION 20), measures that image; the
check's textures of each dma-buf class take that class's image alone (a thread-local of the
class the check runs). texture/route.rs takes the new class where its verdicts take the
texture, else DmaBuf's; a shadow waits on DmaBuf's verdict while both pend. Where the making
refuses the image in the import, it falls back to today's image where DmaBuf's verdicts take
it. A pending move re-routes the same way. Binding in the import reads it apart: it is kept
imported for good, as an image in a pointer import's is. A rebind remakes such an image in the
new pages' import by the same order. RADV requires a dedicated allocation of every such image,
so its check leaves the new class unchecked and it never takes the route.

New WorkCounts field: dma_buf_images_in_import. No new Degradation kind.

The route-(b) device tests (parked images, plane offset, import cycles, a texture's residency)
fail the new class's verdicts first, so they keep measuring today's image on any device. A new
device test (tests/dma_buf_in_import.rs) counts the route and its negative control.

Also: 4c3cbe2f1d and 37d2a750ce (the probe, dma_buf_linear_bind: a linear and a modifier image for
dma-bufs bound in the pages' existing import, the dedicated answers, a re-import arm), 5a40c2ef7b
(docs: API.md, HOWTO.md, FAST-PATHS.md, host_residency.rs module docs).

Why: the owner asked how to remove the per-texture dma-buf. Probe answers (Mesa 26.2.6): RADV on
the Radeon 780M refuses LINEAR images for dma-bufs (NOT_SUPPORTED x15) and requires a dedicated
allocation of every DRM_FORMAT_MOD_LINEAR image (m3-max-34443), so there it never fires. ANV on the
Iris Xe takes both images outside a dedicated allocation, bound in the existing import byte-exact;
first use of an 84 MiB texture 1.37 -> 0.21 ms (m3-max-34453).

Verified in the lane (m3-max-34571, gem10, at 5d5dee7901): clippy -D warnings -p metal2vulkan-runtime
--all-targets --all-features, plain and m2v_cpu_icd. Still running when landed: the lavapipe
in-place and dma-buf suites with the new count test (m3-max-34593), clippy m2v_gpu, PHOENIX, and the
Iris count test with its negative control.

API: adds the field WorkCounts::dma_buf_images_in_import (additive; api_signatures blessed in the lane).
2026-11-15 18:55:56 -08:00
..