wsi/x11: Fix present ID signal when IDLE comes before COMPLETE.
It appears to be possible that IDLE is observed before COMPLETE. In this case, an application may access present_id in subsequent QueuePresentKHR and race against the fence worker reading present_id.
Solve this by adding a separate signal_present_id that is used when completing to avoid the race.
Signed-off-by: Hans-Kristian Arntzen post@arntzen-software.no
This bug manifests as a scenario where present ID is signaled too quickly, leading to a pumping pattern. For example, a possible sequence of events:
- IDLE present ID 100, index 1
- Application acquires index 1
- Application vkQueuePresentKHRs index 1, writes ID 110
- FIFO worker thread observed COMPLETE for index 1, reads present ID for image and signals 110 instead 100.
With the timeline semaphore wait in WaitForPresentKHR, the wait may be moved to the time GPU work is done, rather than being driven by present wait callback. It does not cause stability issues since there is code ensuring monotonicity of the completed present ID, but would cause very odd frame pacing.