From 456c4c4d58e59f0e32435f9b0912a71a5d60fdd4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 25 Oct 2016 00:42:14 +0200 Subject: [PATCH] Remove video_driver_cached_frame_render wrapper function --- command.c | 5 ++++- gfx/drivers/gl.c | 3 ++- gfx/drivers/sdl2_gfx.c | 3 ++- gfx/drivers/vulkan.c | 4 +++- gfx/video_driver.c | 11 +---------- gfx/video_driver.h | 2 +- menu/menu_display.c | 4 +++- runloop.c | 8 ++++++-- tasks/task_screenshot.c | 8 ++++++-- 9 files changed, 28 insertions(+), 20 deletions(-) diff --git a/command.c b/command.c index 29b0b6b0f2..84e96d3ed1 100644 --- a/command.c +++ b/command.c @@ -2301,7 +2301,10 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_AUDIO_STOP, NULL); if (settings->video.black_frame_insertion) - video_driver_cached_frame_render(); + { + if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + video_driver_cached_frame(); + } } else { diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 03021eb6bb..a962adea70 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2423,7 +2423,8 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) goto error; } - video_driver_cached_frame_render(); + if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + video_driver_cached_frame(); video_frame_convert_rgba_to_bgr( (const void*)gl->readback_buffer_screenshot, diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index f1899e51c1..bc548486ad 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -630,7 +630,8 @@ static bool sdl2_gfx_read_viewport(void *data, uint8_t *buffer) performance_counter_init(&sdl2_gfx_read_viewport, "sdl2_gfx_read_viewport"); performance_counter_start(&sdl2_gfx_read_viewport); - video_driver_cached_frame_render(); + if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + video_driver_cached_frame(); surf = SDL_GetWindowSurface(vid->window); bgr24 = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_BGR24, 0); diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index c45e3acf7b..1dfcd680e4 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -2274,7 +2274,9 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer) * with conversion. */ vk->readback.pending = true; - video_driver_cached_frame_render(); + if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + video_driver_cached_frame(); + vkQueueWaitIdle(vk->context->queue); if (!staging->mapped) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index f0b047a2ae..71381d9ff2 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1112,7 +1112,7 @@ void video_driver_set_pixel_format(enum retro_pixel_format fmt) * * Renders the current video frame. **/ -static bool video_driver_cached_frame(void) +bool video_driver_cached_frame(void) { retro_ctx_frame_info_t info; void *recording = recording_driver_get_data_ptr(); @@ -1693,15 +1693,6 @@ bool video_driver_cached_frame_has_valid_framebuffer(void) return frame_cache_data == RETRO_HW_FRAME_BUFFER_VALID; } -bool video_driver_cached_frame_render(void) -{ - if (!current_video) - return false; - if (runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) - return true; /* Maybe return false here for indication of idleness? */ - return video_driver_cached_frame(); -} - bool video_driver_is_alive(void) { if (current_video) diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 0d2d8fe1d5..84afa131df 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -325,7 +325,7 @@ bool video_driver_find_driver(void); void video_driver_apply_state_changes(void); bool video_driver_read_viewport(uint8_t *buffer); bool video_driver_cached_frame_has_valid_framebuffer(void); -bool video_driver_cached_frame_render(void); +bool video_driver_cached_frame(void); bool video_driver_is_alive(void); bool video_driver_is_focused(void); bool video_driver_has_windowed(void); diff --git a/menu/menu_display.c b/menu/menu_display.c index efe43670e1..365264080b 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -308,7 +308,9 @@ bool menu_display_libretro(void) return true; } - return video_driver_cached_frame_render(); + if (runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + return true; /* Maybe return false here for indication of idleness? */ + return video_driver_cached_frame(); } void menu_display_set_width(unsigned width) diff --git a/runloop.c b/runloop.c index 2569016e85..439daf2d0d 100644 --- a/runloop.c +++ b/runloop.c @@ -996,7 +996,8 @@ static enum runloop_state runloop_check_state( if (runloop_cmd_triggered(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY)) { command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL); - video_driver_cached_frame_render(); + if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + video_driver_cached_frame(); } if (!check_is_oneshot) @@ -1077,7 +1078,10 @@ static enum runloop_state runloop_check_state( { /* Checks if slowmotion toggle/hold was being pressed and/or held. */ if (settings->video.black_frame_insertion) - video_driver_cached_frame_render(); + { + if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + video_driver_cached_frame(); + } if (state_manager_frame_is_reversed()) runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION_REWIND), 2, 30, true); diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index 3e013531c8..f12ec19c49 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -300,7 +300,8 @@ static bool take_screenshot_choice(const char *name_base) { /* Avoid taking screenshot of GUI overlays. */ video_driver_set_texture_enable(false, false); - video_driver_cached_frame_render(); + if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + video_driver_cached_frame(); #if defined(VITA) return take_screenshot_raw(name_base, NULL); #else @@ -361,7 +362,10 @@ bool take_screenshot(void) runloop_msg_queue_push(msg, 1, is_paused ? 1 : 180, true); if (is_paused) - video_driver_cached_frame_render(); + { + if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) + video_driver_cached_frame(); + } return ret; }