mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 00:35:21 +00:00
Add performance metrics to KMS driver.
This commit is contained in:
parent
3c9e28e613
commit
f6af4fc122
@ -101,14 +101,44 @@ void gfx_ctx_check_window(bool *quit,
|
||||
*quit = g_quit;
|
||||
}
|
||||
|
||||
static void page_flip_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data)
|
||||
static unsigned first_page_flip;
|
||||
static unsigned last_page_flip;
|
||||
static uint64_t first_usec;
|
||||
static uint64_t last_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;
|
||||
|
||||
//fprintf(stderr, "Frame: %u, Time (ms). %.3f\n", frame, sec * 1000.0 + usec / 1000.0);
|
||||
|
||||
uint64_t current_usec = (uint64_t)sec * 1000000 + usec;
|
||||
if (!first_page_flip)
|
||||
{
|
||||
first_page_flip = frame;
|
||||
first_usec = current_usec;
|
||||
}
|
||||
|
||||
if (last_page_flip)
|
||||
{
|
||||
unsigned missed = frame - last_page_flip - 1;
|
||||
if (!missed)
|
||||
hit_vblanks++;
|
||||
else
|
||||
{
|
||||
RARCH_LOG("[KMS/EGL]: Missed %u VBlank(s) (Frame: %u).\n",
|
||||
missed, frame - first_page_flip);
|
||||
missed_vblanks += missed;
|
||||
}
|
||||
}
|
||||
|
||||
last_page_flip = frame;
|
||||
last_usec = current_usec;
|
||||
|
||||
|
||||
bool *waiting = (bool*)data;
|
||||
*waiting = false;
|
||||
@ -516,6 +546,16 @@ void gfx_ctx_destroy(void)
|
||||
drmClose(g_drm_fd);
|
||||
g_drm_fd = -1;
|
||||
|
||||
unsigned frames = last_page_flip - first_page_flip;
|
||||
if (frames)
|
||||
{
|
||||
uint64_t usec = last_usec - first_usec;
|
||||
RARCH_WARN("[KMS/EGL]: Estimated monitor FPS: %.5f Hz\n", 1000000.0 * frames / usec);
|
||||
}
|
||||
|
||||
RARCH_WARN("[KMS/EGL]: Performance stats: Missed VBlanks: %u, Perfect VBlanks: %u\n",
|
||||
missed_vblanks, hit_vblanks);
|
||||
|
||||
// Reinitialization fails for now ...
|
||||
//g_inited = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user