gfxreconstruct
gfxreconstruct copied to clipboard
Fix capture deadlock when `vkQueuePresentKHR` unlocks a CPU wait
This bug can be observed when capturing the Khronos Vulkan-Sample "timeline_semaphore"
In a situation where you have two threads:
- one waiting on a synchronization primitive (
VkSemaphore
,VkFence
....) - another on which a call to
vkQueuePresentKHR
is necessary to signal that primitive
Then if the "CPU waiting call" (vkWaitForFences
, vkWaitSemaphores
...) is reached by thread 1 before vkQueuePresentKHR
is reached by thread 2, the api_call_mutex_
of the CaptureManager
is locked by the CPU waiting call which makes it impossible to lock by the call to vkQueuePresentKHR
(which is always an exclusive lock) and we end up in a deadlock situation.
I don't see why the lock inside vkQueuePresentKHR
should be exclusive, so I propose to solve this issue by simply using the same system of shared lock as for all the other calls.