Use refresh rate instead of core fps for frameskip timing (#15666)
This commit is contained in:
parent
320ba73f90
commit
4d0110b278
|
@ -3409,6 +3409,10 @@ void video_driver_frame(const void *data, unsigned width,
|
||||||
|
|
||||||
video_driver_build_info(&video_info);
|
video_driver_build_info(&video_info);
|
||||||
|
|
||||||
|
/* Take target refresh rate as initial FPS value instead of 0.00 */
|
||||||
|
if (!last_fps)
|
||||||
|
last_fps = video_info.refresh_rate;
|
||||||
|
|
||||||
/* If fast forward is active and fast forward
|
/* If fast forward is active and fast forward
|
||||||
* frame skipping is enabled, drop any frames
|
* frame skipping is enabled, drop any frames
|
||||||
* that occur at a rate higher than the core-set
|
* that occur at a rate higher than the core-set
|
||||||
|
@ -3426,6 +3430,7 @@ void video_driver_frame(const void *data, unsigned width,
|
||||||
{
|
{
|
||||||
retro_time_t frame_time_accumulator_prev = frame_time_accumulator;
|
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_delta = new_time - last_time;
|
||||||
|
retro_time_t frame_time_target = 1000000.0f / video_info.refresh_rate;
|
||||||
|
|
||||||
/* Ignore initial previous frame time
|
/* Ignore initial previous frame time
|
||||||
* to prevent rubber band startup */
|
* to prevent rubber band startup */
|
||||||
|
@ -3434,28 +3439,29 @@ void video_driver_frame(const void *data, unsigned width,
|
||||||
else if (nonblock_active < 0)
|
else if (nonblock_active < 0)
|
||||||
nonblock_active = 1;
|
nonblock_active = 1;
|
||||||
|
|
||||||
/* Accumulate the elapsed time since the
|
/* Accumulate the elapsed time since the last frame */
|
||||||
* last frame */
|
|
||||||
if (nonblock_active > 0)
|
if (nonblock_active > 0)
|
||||||
frame_time_accumulator += frame_time_delta;
|
frame_time_accumulator += frame_time_delta;
|
||||||
|
|
||||||
/* Render frame if the accumulated time is
|
/* Render frame if the accumulated time is
|
||||||
* greater than or equal to the expected
|
* greater than or equal to the expected
|
||||||
* core frame time */
|
* core frame time */
|
||||||
render_frame = frame_time_accumulator >=
|
render_frame = frame_time_accumulator >= frame_time_target;
|
||||||
video_st->core_frame_time;
|
|
||||||
|
|
||||||
/* If frame is to be rendered, subtract
|
/* If frame is to be rendered, subtract
|
||||||
* expected frame time from accumulator */
|
* expected frame time from accumulator */
|
||||||
if (render_frame)
|
if (render_frame)
|
||||||
{
|
{
|
||||||
frame_time_accumulator -= video_st->core_frame_time;
|
frame_time_accumulator -= frame_time_target;
|
||||||
|
|
||||||
/* Prevent external frame limiters from
|
/* Prevent external frame limiters from
|
||||||
* pushing fast forward ratio down to 1x */
|
* pushing fast forward ratio down to 1x */
|
||||||
if (frame_time_accumulator + frame_time_accumulator_prev < video_st->core_frame_time)
|
if (frame_time_accumulator_prev - frame_time_accumulator >= frame_time_delta)
|
||||||
frame_time_accumulator -= frame_time_delta;
|
frame_time_accumulator -= frame_time_delta;
|
||||||
|
|
||||||
|
if (frame_time_accumulator < 0)
|
||||||
|
frame_time_accumulator = 0;
|
||||||
|
|
||||||
/* If fast forward is working correctly,
|
/* If fast forward is working correctly,
|
||||||
* the actual frame time will always be
|
* the actual frame time will always be
|
||||||
* less than the expected frame time.
|
* less than the expected frame time.
|
||||||
|
@ -3465,7 +3471,7 @@ void video_driver_frame(const void *data, unsigned width,
|
||||||
* will never empty and may potentially
|
* will never empty and may potentially
|
||||||
* overflow. If a 'runaway' accumulator
|
* overflow. If a 'runaway' accumulator
|
||||||
* is detected, we simply reset it */
|
* is detected, we simply reset it */
|
||||||
if (frame_time_accumulator > video_st->core_frame_time)
|
if (frame_time_accumulator > frame_time_target)
|
||||||
frame_time_accumulator = 0;
|
frame_time_accumulator = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -772,7 +772,6 @@ typedef struct
|
||||||
#endif
|
#endif
|
||||||
struct retro_system_av_info av_info; /* double alignment */
|
struct retro_system_av_info av_info; /* double alignment */
|
||||||
retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT];
|
retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT];
|
||||||
retro_time_t core_frame_time;
|
|
||||||
uint64_t frame_time_count;
|
uint64_t frame_time_count;
|
||||||
uint64_t frame_count;
|
uint64_t frame_count;
|
||||||
uint8_t *record_gpu_buffer;
|
uint8_t *record_gpu_buffer;
|
||||||
|
|
|
@ -2674,9 +2674,6 @@ bool runloop_environment_cb(unsigned cmd, void *data)
|
||||||
(*info)->timing.sample_rate);
|
(*info)->timing.sample_rate);
|
||||||
|
|
||||||
memcpy(av_info, *info, sizeof(*av_info));
|
memcpy(av_info, *info, sizeof(*av_info));
|
||||||
video_st->core_frame_time = 1000000 /
|
|
||||||
((video_st->av_info.timing.fps > 0.0) ?
|
|
||||||
video_st->av_info.timing.fps : 60.0);
|
|
||||||
|
|
||||||
command_event(CMD_EVENT_REINIT, &reinit_flags);
|
command_event(CMD_EVENT_REINIT, &reinit_flags);
|
||||||
|
|
||||||
|
@ -4587,9 +4584,6 @@ static bool runloop_event_load_core(runloop_state_t *runloop_st,
|
||||||
core_init_libretro_cbs(runloop_st, &runloop_st->retro_ctx);
|
core_init_libretro_cbs(runloop_st, &runloop_st->retro_ctx);
|
||||||
|
|
||||||
runloop_st->current_core.retro_get_system_av_info(&video_st->av_info);
|
runloop_st->current_core.retro_get_system_av_info(&video_st->av_info);
|
||||||
video_st->core_frame_time = 1000000 /
|
|
||||||
((video_st->av_info.timing.fps > 0.0) ?
|
|
||||||
video_st->av_info.timing.fps : 60.0);
|
|
||||||
|
|
||||||
RARCH_LOG("[Core]: Geometry: %ux%u, Aspect: %.3f, FPS: %.2f, Sample rate: %.2f Hz.\n",
|
RARCH_LOG("[Core]: Geometry: %ux%u, Aspect: %.3f, FPS: %.2f, Sample rate: %.2f Hz.\n",
|
||||||
video_st->av_info.geometry.base_width, video_st->av_info.geometry.base_height,
|
video_st->av_info.geometry.base_width, video_st->av_info.geometry.base_height,
|
||||||
|
|
Loading…
Reference in New Issue