rt surface: every allocation of a dma-buf surface's memory takes device addresses

The Iris Xe (ANV, Mesa 26.2.6) refused Surface::buffer's import of a dma-buf surface with
VK_ERROR_INVALID_EXTERNAL_HANDLE at vkAllocateMemory (m3-max-53411), after the fd's query and the
buffer's requirements listed the type and the planes' imports into it had succeeded. The buffer's
import asks device addresses, which rt's buffers need (VUID-vkBindBufferMemory-bufferDeviceAddress-03339);
the allocation the dma-buf came from and the planes' imports did not. The expected cause is a
driver that keeps one set of flags per payload in a device. The allocation and each plane's import
now take device addresses too, one form on every device, so every allocation of one payload in
the device asks the same.

Verified: nothing yet; the Iris rerun decides whether this is the cause.
This commit is contained in:
Anees Iqbal committed 2026-11-19 10:50:42 -08:00
1 parent 786e780393
commit 699d9bdc1d
2 files changed
+20 -3

No files matched your search

+4 -1
View File
@@ -551,7 +551,10 @@ writes reach with no copy. What a consumer passes to get it, by handle:
must take both. Each plane's image lies on its own dedicated import of the surface's dma-buf,
bound at its first byte, sized to the larger of its requirement and its stated offset plus its
subresource; the allocation the dma-buf came from is freed once the imports and the consumer's
handle exist, so a surface is two allocations, counted in `Gauges::surface_imports`.
handle exist, so a surface is two allocations, counted in `Gauges::surface_imports`. That
allocation and every import of it take device addresses, which the surface's buffer needs: one
payload's allocations in one device take one set of flags (ANV, of Mesa 26.2, refused a buffer's
import with device addresses beside plane imports without them).
- `ExportHandle::OpaqueFd` and `ExportHandle::OpaqueWin32`: each plane's format's `LINEAR` tiling
offers sampling, rendering and both copies, exportable and importable as the handle, not only
in an allocation of its own. The pitch is the driver's own for each plane's `LINEAR` image: the
+16 -2
View File
@@ -992,10 +992,16 @@ impl Device {
}
};
let mut export = vk::ExportMemoryAllocateInfo::default().handle_types(spec.handle.vk());
// The allocation, each plane's import and the buffer's ([`Surface::buffer`]) take device
// addresses alike: one payload's allocations in one device take one set of flags (ANV, of
// Mesa 26.2, refused the buffer's import with device addresses beside planes' imports
// without them, `VK_ERROR_INVALID_EXTERNAL_HANDLE`).
let mut flags = address_flags();
let info = vk::MemoryAllocateInfo::default()
.allocation_size(len)
.memory_type_index(index)
.push_next(&mut export);
.push_next(&mut export)
.push_next(&mut flags);
// SAFETY: an exportable allocation of a type every image takes, bound to nothing.
let block = match unsafe {
memory::allocate(device, &core.counters, core.max_allocations, &info, None)
@@ -1071,11 +1077,13 @@ impl Device {
.handle_type(spec.handle.vk())
.fd(fd.as_raw_fd());
let mut dedicated = vk::MemoryDedicatedAllocateInfo::default().image(image);
let mut flags = address_flags();
let info = vk::MemoryAllocateInfo::default()
.allocation_size(size)
.memory_type_index(import_type)
.push_next(&mut import)
.push_next(&mut dedicated);
.push_next(&mut dedicated)
.push_next(&mut flags);
// SAFETY: an import of the dma-buf, dedicated to the image, of a type both take, at
// least the image's requirement and its stated rows.
let memory = match unsafe {
@@ -1351,3 +1359,9 @@ fn acquire(from: u32, to: u32, buffer: vk::Buffer) -> vk::BufferMemoryBarrier2<'
.offset(0)
.size(vk::WHOLE_SIZE)
}
/// The flags every allocation of a surface's memory takes: device addresses, which its buffer
/// needs (`VUID-vkBindBufferMemory-bufferDeviceAddress-03339`).
fn address_flags() -> vk::MemoryAllocateFlagsInfo<'static> {
vk::MemoryAllocateFlagsInfo::default().flags(vk::MemoryAllocateFlags::DEVICE_ADDRESS)
}