Skip to content

vulkan: Common synchronization code and submit fence

Faith Ekstrand requested to merge gfxstrand/mesa:wip/vk-common-sync into main

The objective here is to have common synchronization code across all Vulkan drivers along with a common implementation of threaded submit which is required for VK_KHR_timeline_semaphore for Vulkan 1.2. Most of the newer drivers (not ANV or RADV) haven't tried to tackel VK_KHR_timeline_semaphore yet and it's a beast. @llandwerlin and myself even managed to get it wrong (see !11474 (merged)) so I really have very little faith that every driver re-implementing it is a good idea.

The core idea here is the vk_sync object which is the guts of a VkSemaphore or VkFence. To be more specific, each VkSemaphore or VkFence contains either one or two vk_syncs, one for the permanent payload and one for temporary. The vk_sync object has a vk_sync_type which is a vfunc table that tells the core code how to work with it. Not all entries in the vfunc table are required.

Once we get to the end (I've not done all the typing yet), vkQueueSubmit will be replace with a vk_queue::submit() hook which will get a series of vk_queue_submit objects. If the driver uses the (also not yet typed) common VkSemaphore and VkFence implementations and implements vk_queue::submit(), it can delete its vkQueueSubmit() implementation and get VK_KHR_timeline_semaphore almost for free. It's still highly recommended that the driver add kernel support for timeline syncobj and wire that up because that's the only way to get sharable timeline semaphores. If the driver does, the common code will handle the submit thread and all the annoyance around submit threads "for free".

Of course, this all requires that I finish typing it all out. 🙃

Edited by Faith Ekstrand

Merge request reports