From ef19a4a09d572871a076840d6712a3c8652f4b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 1 Sep 2024 20:35:24 +0200 Subject: [PATCH] sub/osd: add log if osd rendering takes too long time Ideally it should be fast, it is on VO thread and steals precious frame time budget. Looks like this is one of the main reasons why display-resample on higher refresh rate displays is too slow. --- sub/osd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sub/osd.c b/sub/osd.c index a3da1dd3ca..6a57574a52 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -333,6 +333,8 @@ struct sub_bitmap_list *osd_render(struct osd_state *osd, struct mp_osd_res res, { mp_mutex_lock(&osd->lock); + int64_t start_time = mp_time_ns(); + struct sub_bitmap_list *list = talloc_zero(NULL, struct sub_bitmap_list); list->change_id = 1; list->w = res.w; @@ -388,6 +390,11 @@ struct sub_bitmap_list *osd_render(struct osd_state *osd, struct mp_osd_res res, if (!(draw_flags & OSD_DRAW_SUB_FILTER)) osd->want_redraw_notification = false; + double elapsed = MP_TIME_NS_TO_MS(mp_time_ns() - start_time); + bool slow = elapsed > 5; + mp_msg(osd->log, slow ? MSGL_DEBUG : MSGL_TRACE, "Spent %.3f ms in %s%s\n", + elapsed, __func__, slow ? " (slow!)" : ""); + mp_mutex_unlock(&osd->lock); return list; }