vulkan/wsi/wayland: Avoid spurious discard event at startup

When we start using timestamps, the current code will generate an event
stream like:

feedback
set barrier
wait barrier
commit

feedback
set timestamp
set barrier
commit

wait barrier
commit

The second content update can cause the feedback request from the first to
send a discarded event if the timestamp is in the past.

Be less clever and just put waits in both our content updates.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Fixes: c26ab1aee1 ("vulkan/wsi/wayland: Pace frames with commit-timing-v1")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32121>
This commit is contained in:
Derek Foreman 2024-11-13 13:20:45 -06:00 committed by Marge Bot
parent ed2bb692f7
commit b9c8afae33

View File

@ -2498,6 +2498,7 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain,
if (mode_fifo && chain->fifo) {
wp_fifo_v1_set_barrier(chain->fifo);
wp_fifo_v1_wait_barrier(chain->fifo);
/* If our surface is occluded and we're using vkWaitForPresentKHR,
* we can end up waiting forever. The FIFO condition and the time
@ -2512,10 +2513,26 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain,
* receives presented feedback and the FIFO one blocks further
* updates until the next refresh.
*/
if (timestamped)
if (timestamped) {
wl_surface_commit(wsi_wl_surface->surface);
wp_fifo_v1_wait_barrier(chain->fifo);
/* Once we're in a steady state, we'd only need one of these
* barrier waits. However, the first time we use a timestamp
* we need both of our content updates to wait. The first
* needs to wait to avoid potentially provoking a feedback
* discarded event for the previous untimed content update,
* the second to prevent provoking a discard event for the
* timed update we've just made.
*
* Before the transition, we would only have a single content
* update per call, which would contain a barrier wait. After
* that, we would only need a barrier wait in the empty content
* update.
*
* Instead of statefully tracking the transition across calls to
* this function, just put a barrier wait in every content update.
*/
wp_fifo_v1_wait_barrier(chain->fifo);
}
}
wl_surface_commit(wsi_wl_surface->surface);
wl_display_flush(wsi_wl_surface->display->wl_display);