From ff39749feb776c6ca4e30bddcac8a75ebfeaa39a Mon Sep 17 00:00:00 2001 From: Dagen Brock Date: Sun, 26 Aug 2018 13:59:39 -0500 Subject: [PATCH] fix sdl frame rendering vsync method to simply present the buffer once per frame --- src/sdl2_driver.c | 25 +++++++++++++++---------- src/video.c | 12 ++++-------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/sdl2_driver.c b/src/sdl2_driver.c index c9558cb..8db6530 100644 --- a/src/sdl2_driver.c +++ b/src/sdl2_driver.c @@ -416,17 +416,9 @@ void sdl_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int src pitch = BORDER_WIDTH+72; } SDL_UpdateTexture(texture, &dstrect, src_ptr, pitch*4 ); - SDL_RenderClear(renderer); - SDL_RenderCopy(renderer, texture, NULL, NULL); - if (g_scanline_simulator) { - SDL_RenderCopy(renderer, overlay_texture, NULL, NULL); - } - SDL_RenderPresent(renderer); - if (g_screenshot_requested) { - x_take_screenshot(); - g_screenshot_requested = 0; - } + // We now call the render step seperately in sdl_present_buffer once per frame + // SDL picks up the buffer and waits for VBLANK to send it } @@ -806,6 +798,19 @@ void debuginfo_renderer(SDL_Renderer *r) { } } +void sdl_present_buffer() { + SDL_RenderClear(renderer); + SDL_RenderCopy(renderer, texture, NULL, NULL); + if (g_scanline_simulator) { + SDL_RenderCopy(renderer, overlay_texture, NULL, NULL); + } + + SDL_RenderPresent(renderer); + if (g_screenshot_requested) { + x_take_screenshot(); + g_screenshot_requested = 0; + } +} // BELOW ARE FUNCTIONS THAT ARE EITHER UNIMPLEMENTED, OR AR NOT RELEVANT TO // THIS DRIVER. diff --git a/src/video.c b/src/video.c index 7e0c376..72b96f0 100644 --- a/src/video.c +++ b/src/video.c @@ -640,7 +640,10 @@ void video_update() { video_update_through_line(0); } - +#if defined(HAVE_SDL) + extern void sdl_present_buffer(); + sdl_present_buffer(); +#endif // OG Notify host that video has been uodated #if defined(ACTIVEGSPLUGIN) && defined(MAC) { @@ -3474,13 +3477,6 @@ void video_update_color_array(int col_num, int a2_color) { return; } -#if 0 - if(g_screen_depth != 8) { - /* redraw whole superhires for now */ - g_full_refresh_needed = -1; - } -#endif - video_update_color_raw(col_num, a2_color); }