From caa956d120b34e4c0deadb9e61af509a88debd09 Mon Sep 17 00:00:00 2001 From: neonloop Date: Fri, 25 Mar 2022 21:34:32 +0000 Subject: Skips main loop fb flip when screen is skipped If core hasn't updated screen, no need to flip. Can save vsync delay, makes ff faster --- plat_sdl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plat_sdl.c b/plat_sdl.c index 5d996b3..0beb924 100644 --- a/plat_sdl.c +++ b/plat_sdl.c @@ -29,6 +29,8 @@ static char msg[HUD_LEN]; static unsigned msg_priority = 0; static unsigned msg_expire = 0; +static bool frame_dirty = false; + static void video_expire_msg(void) { msg[0] = '\0'; @@ -209,6 +211,7 @@ void plat_video_set_msg(const char *new_msg, unsigned priority, unsigned msec) void plat_video_process(const void *data, unsigned width, unsigned height, size_t pitch) { static int had_msg = 0; + frame_dirty = true; SDL_LockSurface(screen); if (had_msg) { @@ -230,7 +233,10 @@ void plat_video_process(const void *data, unsigned width, unsigned height, size_ void plat_video_flip(void) { - fb_flip(); + if (frame_dirty) + fb_flip(); + + frame_dirty = false; } void plat_video_close(void) -- cgit v1.2.3