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. --- render/gles2/renderer.c | 2 +- render/pixman/renderer.c | 2 +- render/vulkan/renderer.c | 3 ++- render/wlr_renderer.c | 27 ++++++++++++++++++++++++--- 4 files changed, 28 insertions(+), 6 deletions(-) (limited to 'render') diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 414d5feb..c330d7ad 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -537,7 +537,7 @@ static void gles2_destroy(struct wlr_renderer *wlr_renderer) { } static struct wlr_render_pass *gles2_begin_buffer_pass(struct wlr_renderer *wlr_renderer, - struct wlr_buffer *wlr_buffer) { + struct wlr_buffer *wlr_buffer, struct wlr_buffer_pass_options *options) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); if (!wlr_egl_make_current(renderer->egl)) { return NULL; diff --git a/render/pixman/renderer.c b/render/pixman/renderer.c index 2ada4cdb..821bb9f5 100644 --- a/render/pixman/renderer.c +++ b/render/pixman/renderer.c @@ -494,7 +494,7 @@ static uint32_t pixman_get_render_buffer_caps(struct wlr_renderer *renderer) { } static struct wlr_render_pass *pixman_begin_buffer_pass(struct wlr_renderer *wlr_renderer, - struct wlr_buffer *wlr_buffer) { + struct wlr_buffer *wlr_buffer, struct wlr_buffer_pass_options *options) { struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer); struct wlr_pixman_buffer *buffer = get_buffer(renderer, wlr_buffer); diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c index 4476f55b..70ec0ce0 100644 --- a/render/vulkan/renderer.c +++ b/render/vulkan/renderer.c @@ -1916,7 +1916,8 @@ static uint32_t vulkan_get_render_buffer_caps(struct wlr_renderer *wlr_renderer) return WLR_BUFFER_CAP_DMABUF; } -static struct wlr_render_pass *vulkan_begin_buffer_pass(struct wlr_renderer *wlr_renderer, struct wlr_buffer *buffer) { +static struct wlr_render_pass *vulkan_begin_buffer_pass(struct wlr_renderer *wlr_renderer, + struct wlr_buffer *buffer, struct wlr_buffer_pass_options *options) { struct wlr_vk_renderer *renderer = vulkan_get_renderer(wlr_renderer); struct wlr_vk_render_buffer *render_buffer = get_render_buffer(renderer, buffer); diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index cfddca88..22c1f8d2 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -413,10 +413,31 @@ int wlr_renderer_get_drm_fd(struct wlr_renderer *r) { return r->impl->get_drm_fd(r); } -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) { if (!renderer->impl->begin_buffer_pass) { return begin_legacy_buffer_render_pass(renderer, buffer); } - return renderer->impl->begin_buffer_pass(renderer, buffer); + return renderer->impl->begin_buffer_pass(renderer, buffer, options); +} + +struct wlr_render_timer *wlr_render_timer_create(struct wlr_renderer *renderer) { + if (!renderer->impl->render_timer_create) { + return NULL; + } + return renderer->impl->render_timer_create(renderer); +} + +int wlr_render_timer_get_duration_ns(struct wlr_render_timer *timer) { + if (!timer->impl->get_duration_ns) { + return -1; + } + return timer->impl->get_duration_ns(timer); +} + +void wlr_render_timer_destroy(struct wlr_render_timer *timer) { + if (!timer->impl->destroy) { + return; + } + timer->impl->destroy(timer); } -- cgit v1.2.3