Files
reims-vgpu/docs/video
Anees Iqbal eadb25fe2f 🐛 Map an imported buffer from its allocation's first byte
CUDA maps a buffer of an import made dedicated only from offset 0: from 224,
256, 4096 or 65536 bytes in, cuExternalMemoryGetMappedBuffer answers
CUDA_ERROR_INVALID_VALUE, while a mapping of any length from offset 0 maps
(measured on an RTX 2080, and at 224 on an RTX 3090). ImportedBuffer::import
mapped from the buffer's offset, so no buffer past the first byte of an
exporter's dedicated allocation was ever imported. Where a driver makes each
exportable buffer its own dedicated allocation (docs/video/devices.md says
metal2vulkan does on the RTX 5080, which no check here reaches), a device
cache whose first plane the platform places past its first byte would be
declined, and its pictures read back and copied by the CPU.

The import now maps from the allocation's first byte to the buffer's last and
gives the buffer's address as its offset into that mapping, so no exporter's
layout, on either platform or any driver, depends on CUDA taking an offset.
What the host sees changes only where the import failed before: there a
picture lands in the device cache by the GPU's copy. A test of the pattern
writes a buffer 224 bytes and one a page into a Vulkan device's dedicated
allocation through their own imports and reads where the writes landed.
2026-11-19 07:47:41 -08:00
..