Skip to content

vulkan: Add support for importing and using dma_buf memory

Philip Langdale requested to merge philipl/libplacebo:dma_buf into master

This change introduces a set of vulkan-specific functions to support importing dma_buf backed memory and then creating textures over that memory.

The specific use-case is supporting interop with vaapi hardware decoding, where dma_buf is used to export decoded video surfaces.

The API is a little rough as the VkDeviceMemory objects have to be directly exposed in the API. Due to the memory not corresponding 1:1 with the textures, the caller has to manage them explicitly.

I have a corresponding mpv change that demonstrates this all works.

Note that this code does not pass validation right now. We get errors reporting that the image is too big to fit into the memory it is being bound to, when offset and size are considered together.

Clearly it works in practice, and I think the issue is that the pitch of the VA Surface is different (smaller) than what would be used for a normal Vulkan image allocation. I suspect this cannot be fixed without using VK_EXT_image_drm_format_modifier which is not yet available. When this is used, there is a special tiling mode which tells Vulkan to expect a special pitch.

Merge request reports