From 9e8947e4d51ddafb40887b8a8ebfb1873615f9b6 Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Fri, 2 Jun 2023 10:25:07 +0100 Subject: add render timer API Based on five calls: wlr_render_timer_create - creates a timer which can be reused across frames on the same renderer wlr_renderer_begin_buffer_pass - now takes a timer so that backends can record when the rendering starts and finishes wlr_render_timer_get_time - should be called as late as possible so that queries can make their way back from the GPU wlr_render_timer_destroy - self-explanatory The timer is exposed as an opaque `struct wlr_render_timer` so that backends can store whatever they want in there. --- include/wlr/render/wlr_renderer.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'include/wlr/render/wlr_renderer.h') diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h index 33668067..a150930c 100644 --- a/include/wlr/render/wlr_renderer.h +++ b/include/wlr/render/wlr_renderer.h @@ -161,14 +161,23 @@ void wlr_renderer_destroy(struct wlr_renderer *renderer); */ struct wlr_render_pass; +/** + * An object that can be queried after a render to get the duration of the render. + */ +struct wlr_render_timer; + +struct wlr_buffer_pass_options { + struct wlr_render_timer *timer; +}; + /** * Begin a new render pass with the supplied destination buffer. * * Callers must call wlr_render_pass_submit() once they are done with the * render pass. */ -struct wlr_render_pass *wlr_renderer_begin_buffer_pass( - struct wlr_renderer *renderer, struct wlr_buffer *buffer); +struct wlr_render_pass *wlr_renderer_begin_buffer_pass(struct wlr_renderer *renderer, + struct wlr_buffer *buffer, struct wlr_buffer_pass_options *options); /** * Submit the render pass. @@ -235,4 +244,21 @@ struct wlr_render_rect_options { void wlr_render_pass_add_rect(struct wlr_render_pass *render_pass, const struct wlr_render_rect_options *options); +/** + * Allocate and initialise a new render timer. + */ +struct wlr_render_timer *wlr_render_timer_create(struct wlr_renderer *renderer); + +/** + * Get the render duration in nanoseconds from the timer. + * + * Returns -1 if the duration is unavailable. + */ +int wlr_render_timer_get_duration_ns(struct wlr_render_timer *timer); + +/** + * Destroy the render timer. + */ +void wlr_render_timer_destroy(struct wlr_render_timer *timer); + #endif -- cgit v1.2.3