From 580cf1c07e6ad3d16a1c82c475b8f69eb0800167 Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 19 Sep 2012 00:44:50 +0200 Subject: [PATCH] Report delta times for vblank misses. For debugging purposes, report time from PageFlip is queued, till it actually happens. --- gfx/context/drm_egl_ctx.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index d84a4027a5..fe55df9f5f 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -108,15 +109,14 @@ static unsigned last_page_flip; static uint64_t first_usec; static uint64_t last_usec; +static uint64_t flip_request_usec; + static unsigned missed_vblanks; static unsigned hit_vblanks; static void page_flip_handler(int fd, unsigned frame, unsigned sec, unsigned usec, void *data) { (void)fd; - (void)frame; - (void)sec; - (void)usec; uint64_t current_usec = (uint64_t)sec * 1000000 + usec; if (!first_page_flip) @@ -135,15 +135,16 @@ static void page_flip_handler(int fd, unsigned frame, unsigned sec, unsigned use RARCH_LOG("[KMS/EGL]: Missed %u VBlank(s) (Frame: %u).\n", missed, frame - first_page_flip); missed_vblanks += missed; + + unsigned flip_time = current_usec - flip_request_usec; + RARCH_LOG("\tDelta request => flip: %.5f ms.\n", flip_time / 1000.0); } } last_page_flip = frame; last_usec = current_usec; - - bool *waiting = (bool*)data; - *waiting = false; + *(bool*)data = false; } static bool waiting_for_flip; @@ -196,6 +197,10 @@ static void queue_flip(void) return; } + struct timeval tv; + gettimeofday(&tv, NULL); + flip_request_usec = (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec; + waiting_for_flip = true; }