A dma-buf block's images name an opaque file descriptor where the device takes no dma-buf image in a shared block

On the 780M (RADV PHOENIX) the runtime's memory exported as dma-bufs
kept every texture a shadow: the device's image format query refuses
the dma-buf handle type to a plain linear image and takes it for a
DRM_FORMAT_MOD_LINEAR image only in a dedicated allocation, so the
in-place check of that memory made no image and its verdicts stayed
Unchecked (m3-max-10261). RADV takes an opaque file descriptor for the
same images in a shared block (the opaque-descriptor planes are in
place there, alignment 256).

The remedy, decided from documented queries alone:

- exported_memory.rs: FdExport::new asks
  vkGetPhysicalDeviceExternalBufferProperties for the dma-buf and the
  opaque handle types with the runtime's buffer usage. Where the
  dma-buf's compatible types hold the opaque one, and the opaque one is
  exportable, not DEDICATED_ONLY, and compatible with both, a shared
  block of dma-bufs is allocated exportable as DMA_BUF | OPAQUE_FD
  (Memory::export_dma_bufs_as). Elsewhere, and for a buffer's dedicated
  allocation, it stays the dma-buf alone. The buffer still names the
  dma-buf type (VUID-vkBindBufferMemory-memory-02726 needs one in
  common) and export_memory_dma_buf is unchanged: vkGetMemoryFdKHR of
  the dma-buf type, a dma-buf of the same memory.
- memory.rs: Exported carries the export set beside the handle type;
  bound_memory answers the set.
- texture.rs: alias_unbound tries the image naming the dma-buf type,
  then, where the block exports both, the one naming the opaque type,
  each through the same linear-then-DRM_FORMAT_MOD_LINEAR route
  (alias_unbound_in). An image takes a handle type only where
  vkGetPhysicalDeviceImageFormatProperties2 with that type reports it
  exportable, not DEDICATED_ONLY, and lists every type the block is
  exported as among its compatible types (external_image_limits,
  modifier_image_limits; LinearRefusal::Incompatible). Where neither
  takes it, the shadow and its notice name both refusals.
- in_place.rs: the class follows the memory (ExportedDmaBuf for any
  block of dma-bufs); the check's own textures go through the same
  route, so its verdicts are of the image a texture names.
  CHECK_VERSION 13 -> 14: 13's records kept ExportedDmaBuf Unchecked as
  a cause that lasts.
- WorkCounts::exported_dma_buf_images_named_opaque_fd counts the images
  that name the opaque type over a dma-buf block (api_signatures.tsv).

Test: exported_textures'
a_dma_buf_block_s_planes_name_an_opaque_fd_where_its_images_take_no_dma_buf_in_a_shared_block
asks the buffer and image queries itself, apart from the runtime: it
asserts the block's export set matches the buffer queries, the
buffer's export is a dma-buf (fdinfo exp_name), and, where the block
exports both and the dma-buf type takes no image of the plane's format
in a shared block, each plane is in place naming the opaque type
(counted) or a shadow of a byte the check found changed, never
Unchecked; no VUID under the layer. Without the change it fails on
RADV: the block exports the dma-buf alone where the buffer queries
answer both.

Docs: API.md's shadow rule, HOWTO section 7, the runtime README and the
module docs.

Verification: to run on the 780M, the RX 550 and lavapipe, then the
5080 through an entry.

(cherry picked from commit 1acb4f1fbf1fd4df8fcee2948417dcc089909fe4)
This commit is contained in:
Anees Iqbal committed 2026-11-08 18:30:27 -08:00
1 parent 9bad038087
commit 6d5c7b8e92
13 files changed
+616 -91

No files matched your search

+10 -4
View File
@@ -1657,10 +1657,16 @@ bound.
pending, failed or unchecked, as over host pages, a pending one moving to the image once the
verdict passes, at a quiet commit, with no copy (`WorkCounts::pooled_textures_moved_in_place`);
over memory the runtime exports (`MemoryExport`, a runtime extension), where either image names
the memory's handle type as Vulkan requires and so starts `UNDEFINED`, its check of that exported
memory has not passed for the texture's accesses (a pending one moving the same way), the
device's image format query takes the handle type for no such image but in a dedicated
allocation, or the memory is the buffer's dedicated allocation, to which no image may be bound;
a handle type the memory is exportable as, as Vulkan requires, and so starts `UNDEFINED`: its
check of that exported memory has not passed for the texture's accesses (a pending one moving
the same way), the device's image format query takes none of those handle types for such an
image but in a dedicated allocation, or lists not every one the memory is exportable as among
those compatible with it, or the memory is the buffer's dedicated allocation, to which no image
may be bound (a block of dma-bufs is exportable as an opaque file descriptor too where the
device's buffer queries answer both together, each compatible with the other, and its image then
names the opaque handle type where the query takes no dma-buf for it, as RADV's does for linear
images, `WorkCounts::exported_dma_buf_images_named_opaque_fd`; the buffer's export stays a dma-buf
of the same memory);
for one that renders, whose rows each to its
pitch share no line with bytes past them, the check of renders that lets the rows' padding
change, as the declaration does, and no byte past the last row's pitch); past a bound in bytes of its rows to their