mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 04:10:09 +01:00
wsi/wayland: refactor wayland dispatch
Add a thin wrapper around the wayland dispatch code for no reason other than to add MESA_TRACE_FUNC so we can see where wayland dispatch delays are. Move this to loader so we can use it in the wayland egl code later. Signed-off-by: Derek Foreman <derek.foreman@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28634>
This commit is contained in:
parent
1062b3e813
commit
90effcceab
3 changed files with 33 additions and 14 deletions
|
|
@ -23,6 +23,8 @@
|
|||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util/perf/cpu_trace.h"
|
||||
|
||||
#include "loader_wayland_helper.h"
|
||||
|
||||
#ifndef HAVE_WL_DISPATCH_QUEUE_TIMEOUT
|
||||
|
|
@ -141,3 +143,23 @@ wl_display_create_queue_with_name(struct wl_display *display, const char *name)
|
|||
return wl_display_create_queue(display);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
loader_wayland_dispatch(struct wl_display *wl_display,
|
||||
struct wl_event_queue *queue,
|
||||
struct timespec *end_time)
|
||||
{
|
||||
struct timespec current_time;
|
||||
struct timespec remaining_timeout;
|
||||
|
||||
MESA_TRACE_FUNC();
|
||||
|
||||
if (!end_time)
|
||||
return wl_display_dispatch_queue(wl_display, queue);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||
timespec_sub_saturate(&remaining_timeout, end_time, ¤t_time);
|
||||
return wl_display_dispatch_queue_timeout(wl_display,
|
||||
queue,
|
||||
&remaining_timeout);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,4 +40,9 @@ wl_display_create_queue_with_name(struct wl_display *display,
|
|||
const char *name);
|
||||
#endif
|
||||
|
||||
int
|
||||
loader_wayland_dispatch(struct wl_display *display,
|
||||
struct wl_event_queue *queue,
|
||||
struct timespec *end_time);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1738,12 +1738,9 @@ dispatch_present_id_queue(struct wsi_swapchain *wsi_chain, struct timespec *end_
|
|||
*/
|
||||
pthread_mutex_unlock(&chain->present_ids.lock);
|
||||
|
||||
struct timespec current_time, remaining_timeout;
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||
timespec_sub_saturate(&remaining_timeout, end_time, ¤t_time);
|
||||
ret = wl_display_dispatch_queue_timeout(wl_display,
|
||||
chain->present_ids.queue,
|
||||
&remaining_timeout);
|
||||
ret = loader_wayland_dispatch(wl_display,
|
||||
chain->present_ids.queue,
|
||||
end_time);
|
||||
|
||||
pthread_mutex_lock(&chain->present_ids.lock);
|
||||
|
||||
|
|
@ -1770,7 +1767,6 @@ wsi_wl_swapchain_wait_for_present(struct wsi_swapchain *wsi_chain,
|
|||
uint64_t timeout)
|
||||
{
|
||||
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
|
||||
|
||||
struct timespec end_time;
|
||||
VkResult ret;
|
||||
int err;
|
||||
|
|
@ -1880,14 +1876,10 @@ wsi_wl_swapchain_acquire_next_image_implicit(struct wsi_swapchain *wsi_chain,
|
|||
}
|
||||
}
|
||||
|
||||
struct timespec current_time, remaining_timeout;
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||
timespec_sub_saturate(&remaining_timeout, &end_time, ¤t_time);
|
||||
|
||||
/* Try to dispatch potential events. */
|
||||
int ret = wl_display_dispatch_queue_timeout(wsi_wl_surface->display->wl_display,
|
||||
wsi_wl_surface->display->queue,
|
||||
&remaining_timeout);
|
||||
int ret = loader_wayland_dispatch(wsi_wl_surface->display->wl_display,
|
||||
wsi_wl_surface->display->queue,
|
||||
&end_time);
|
||||
if (ret == -1)
|
||||
return VK_ERROR_OUT_OF_DATE_KHR;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue