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_sync
s, 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.