vulkan: Add support for importing and using dma_buf memory
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
Activity
added 1 commit
- 28243811 - vulkan: Introduce a ref-counting wrapper for external memory
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
added 1 commit
- 9cd08fa7 - vulkan: Add support for importing and using dma_buf memory
Substantially updated to manage imported memory with
vk_memslice
and abandoning ref counting in favour of dup()ing the fds. This is a lot simpler and actually moves us closer to running with validations.Right now I see a finite set of binding errors at mpv startup and then the stream plays fine without errors. This seems to be related to whatever strange things it's doing at probe time. I see 5 failed bind calls, and the sizes it's complaining about are the same, regardless of what sample I play, so this might be something that's mpv specific. I will dig further.
In terms of comments, I need to add the import_caps but the rest are addressed or obsoleted.
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale
- Resolved by Philip Langdale