Skip to content

Commit

Permalink
(Vulkan) Improve fastforward frameskip option hack
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos committed Sep 17, 2024
1 parent ece70f7 commit fd75fd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2709,17 +2709,18 @@ void video_driver_build_info(video_frame_info_t *video_info)
video_info->runloop_is_paused = (runloop_st->flags & RUNLOOP_FLAG_PAUSED) ? true : false;
video_info->runloop_is_slowmotion = (runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION) ? true : false;
video_info->fastforward_frameskip = settings->bools.fastforward_frameskip;
video_info->frame_time_target = 1000000.0f / video_info->refresh_rate;

#ifdef _WIN32
#ifdef HAVE_VULKAN
/* Vulkan in Windows does mailbox emulation
* in fullscreen with vsync, effectively
* discarding frames that can't be shown,
* therefore do not do it twice. */
* already discarding frames, therefore compensate
* frameskip target to make it smoother and faster. */
if ( video_info->fullscreen
&& settings->bools.video_vsync
&& string_is_equal(video_driver_get_ident(), "vulkan"))
video_info->fastforward_frameskip = false;
video_info->frame_time_target /= 2.0f;
#endif
#endif

Expand Down Expand Up @@ -3409,9 +3410,9 @@ void video_driver_frame(const void *data, unsigned width,
static retro_time_t last_time;
static retro_time_t curr_time;
static retro_time_t fps_time;
static retro_time_t frame_time_accumulator;
static float last_fps, frame_time;
static uint64_t last_used_memory, last_total_memory;
static uint16_t frame_time_accumulator;
/* Mark the start of nonblock state for
* ignoring initial previous frame time */
static int8_t nonblock_active;
Expand Down Expand Up @@ -3494,9 +3495,9 @@ void video_driver_frame(const void *data, unsigned width,
&& video_info.fastforward_frameskip)
#endif
{
retro_time_t frame_time_accumulator_prev = frame_time_accumulator;
retro_time_t frame_time_delta = new_time - last_time;
retro_time_t frame_time_target = 1000000.0f / video_info.refresh_rate;
uint16_t frame_time_accumulator_prev = frame_time_accumulator;
uint16_t frame_time_delta = new_time - last_time;
uint16_t frame_time_target = video_info.frame_time_target;

/* Ignore initial previous frame time
* to prevent rubber band startup */
Expand Down
2 changes: 2 additions & 0 deletions gfx/video_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ typedef struct video_frame_info
uint32_t video_st_flags;
uint16_t menu_st_flags;

uint16_t frame_time_target;

char stat_text[1024];

bool widgets_active;
Expand Down

0 comments on commit fd75fd0

Please sign in to comment.