From 393a06911269b69ed83f1b29bd5e252c07ba59bf Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Mon, 6 Jun 2016 02:44:15 +0200 Subject: vo_opengl: expose performance timers as properties This is plumbed through a new VOCTRL, VOCTRL_PERFORMANCE_DATA, and exposed as properties render-time-last, render-time-avg etc. All of these numbers are in microseconds, which gives a good precision range when just outputting them via show-text. (Lua scripts can obviously still do their own formatting etc.) Signed-off-by: wm4 --- video/out/opengl/video.c | 18 ++++++++++++++++++ video/out/opengl/video.h | 1 + video/out/vo.h | 12 ++++++++++++ video/out/vo_opengl.c | 3 +++ 4 files changed, 34 insertions(+) (limited to 'video') diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index fe7c0abaa9..ea24f6e9a1 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -2908,6 +2908,24 @@ void gl_video_resize(struct gl_video *p, int vp_w, int vp_h, mpgl_osd_resize(p->osd, p->osd_rect, p->image_params.stereo_out); } +static struct voctrl_performance_entry gl_video_perfentry(struct gl_timer *t) +{ + return (struct voctrl_performance_entry) { + .last = gl_timer_last_us(t), + .avg = gl_timer_avg_us(t), + .peak = gl_timer_peak_us(t), + }; +} + +struct voctrl_performance_data gl_video_perfdata(struct gl_video *p) +{ + return (struct voctrl_performance_data) { + .upload = gl_video_perfentry(p->upload_timer), + .render = gl_video_perfentry(p->render_timer), + .present = gl_video_perfentry(p->present_timer), + }; +} + static bool unmap_image(struct gl_video *p, struct mp_image *mpi) { GL *gl = p->gl; diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h index 29a5ea9643..9e44cf8b06 100644 --- a/video/out/opengl/video.h +++ b/video/out/opengl/video.h @@ -169,6 +169,7 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, int fbo); void gl_video_resize(struct gl_video *p, int vp_w, int vp_h, struct mp_rect *src, struct mp_rect *dst, struct mp_osd_res *osd); +struct voctrl_performance_data gl_video_perfdata(struct gl_video *p); struct mp_csp_equalizer; struct mp_csp_equalizer *gl_video_eq_ptr(struct gl_video *p); void gl_video_eq_update(struct gl_video *p); diff --git a/video/out/vo.h b/video/out/vo.h index 000283cd36..9c29d5f2cc 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -77,6 +77,8 @@ enum mp_voctrl { VOCTRL_UPDATE_WINDOW_TITLE, // char* VOCTRL_UPDATE_PLAYBACK_STATE, // struct voctrl_playback_state* + VOCTRL_PERFORMANCE_DATA, // struct voctrl_performance_data* + VOCTRL_SET_CURSOR_VISIBILITY, // bool* VOCTRL_KILL_SCREENSAVER, @@ -137,6 +139,16 @@ struct voctrl_playback_state { int percent_pos; }; +// VOCTRL_PERFORMANCE_DATA +struct voctrl_performance_entry { + // Times are in microseconds + uint64_t last, avg, peak; +}; + +struct voctrl_performance_data { + struct voctrl_performance_entry upload, render, present; +}; + enum { // VO does handle mp_image_params.rotate in 90 degree steps VO_CAP_ROTATE90 = 1 << 0, diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 4a84e8b3ba..426236e436 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -329,6 +329,9 @@ static int control(struct vo *vo, uint32_t request, void *data) vo_wakeup(vo); } return true; + case VOCTRL_PERFORMANCE_DATA: + *(struct voctrl_performance_data *)data = gl_video_perfdata(p->renderer); + return true; } int events = 0; -- cgit v1.2.3