Auto swap interval correction
This commit is contained in:
parent
015e515e9e
commit
ba8b97041e
36
retroarch.c
36
retroarch.c
|
@ -1381,11 +1381,8 @@ static void driver_adjust_system_rates(
|
||||||
video_driver_state_t *video_st,
|
video_driver_state_t *video_st,
|
||||||
settings_t *settings)
|
settings_t *settings)
|
||||||
{
|
{
|
||||||
struct retro_system_av_info *av_info = &video_st->av_info;
|
double input_sample_rate = video_st->av_info.timing.sample_rate;
|
||||||
const struct retro_system_timing *info =
|
double input_fps = video_st->av_info.timing.fps;
|
||||||
(const struct retro_system_timing*)&av_info->timing;
|
|
||||||
double input_sample_rate = info->sample_rate;
|
|
||||||
double input_fps = info->fps;
|
|
||||||
float video_refresh_rate = settings->floats.video_refresh_rate;
|
float video_refresh_rate = settings->floats.video_refresh_rate;
|
||||||
float audio_max_timing_skew = settings->floats.audio_max_timing_skew;
|
float audio_max_timing_skew = settings->floats.audio_max_timing_skew;
|
||||||
unsigned video_swap_interval = settings->uints.video_swap_interval;
|
unsigned video_swap_interval = settings->uints.video_swap_interval;
|
||||||
|
@ -1396,17 +1393,8 @@ static void driver_adjust_system_rates(
|
||||||
|
|
||||||
/* Update video swap interval if automatic
|
/* Update video swap interval if automatic
|
||||||
* switching is enabled */
|
* switching is enabled */
|
||||||
runloop_set_video_swap_interval(
|
runloop_set_video_swap_interval(settings);
|
||||||
vrr_runloop_enable,
|
video_swap_interval = runloop_get_video_swap_interval(video_swap_interval);
|
||||||
(video_st->flags & VIDEO_FLAG_CRT_SWITCHING_ACTIVE) ? true : false,
|
|
||||||
video_swap_interval,
|
|
||||||
black_frame_insertion,
|
|
||||||
shader_subframes,
|
|
||||||
audio_max_timing_skew,
|
|
||||||
video_refresh_rate,
|
|
||||||
input_fps);
|
|
||||||
video_swap_interval = runloop_get_video_swap_interval(
|
|
||||||
video_swap_interval);
|
|
||||||
|
|
||||||
if (input_sample_rate > 0.0)
|
if (input_sample_rate > 0.0)
|
||||||
{
|
{
|
||||||
|
@ -1559,6 +1547,9 @@ void drivers_init(
|
||||||
menu_st->flags |= MENU_ST_FLAG_DATA_OWN;
|
menu_st->flags |= MENU_ST_FLAG_DATA_OWN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Content av_info based automatic swap interval must be set early. */
|
||||||
|
runloop_set_video_swap_interval(settings);
|
||||||
|
|
||||||
/* Initialize video driver */
|
/* Initialize video driver */
|
||||||
if (flags & DRIVER_VIDEO_MASK)
|
if (flags & DRIVER_VIDEO_MASK)
|
||||||
{
|
{
|
||||||
|
@ -1583,16 +1574,15 @@ void drivers_init(
|
||||||
runloop_st->frame_time_last = 0;
|
runloop_st->frame_time_last = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Regular display refresh rate startup autoswitch based on content av_info */
|
/* Regular display refresh rate startup autoswitch based on content av_info. */
|
||||||
if ( flags & (DRIVER_VIDEO_MASK | DRIVER_AUDIO_MASK)
|
if ( flags & (DRIVER_VIDEO_MASK | DRIVER_AUDIO_MASK)
|
||||||
&& !(runloop_st->flags & RUNLOOP_FLAG_IS_INITED))
|
&& !(runloop_st->flags & RUNLOOP_FLAG_IS_INITED))
|
||||||
{
|
{
|
||||||
struct retro_system_av_info *av_info = &video_st->av_info;
|
float refresh_rate = video_st->av_info.timing.fps;
|
||||||
float refresh_rate = av_info->timing.fps;
|
unsigned autoswitch_refresh_rate = settings->uints.video_autoswitch_refresh_rate;
|
||||||
unsigned autoswitch_refresh_rate = settings->uints.video_autoswitch_refresh_rate;
|
bool exclusive_fullscreen = settings->bools.video_fullscreen && !settings->bools.video_windowed_fullscreen;
|
||||||
bool exclusive_fullscreen = settings->bools.video_fullscreen && !settings->bools.video_windowed_fullscreen;
|
bool windowed_fullscreen = settings->bools.video_fullscreen && settings->bools.video_windowed_fullscreen;
|
||||||
bool windowed_fullscreen = settings->bools.video_fullscreen && settings->bools.video_windowed_fullscreen;
|
bool all_fullscreen = settings->bools.video_fullscreen || settings->bools.video_windowed_fullscreen;
|
||||||
bool all_fullscreen = settings->bools.video_fullscreen || settings->bools.video_windowed_fullscreen;
|
|
||||||
|
|
||||||
/* Making a switch from PC standard 60 Hz to NTSC 59.94 is excluded by the last condition. */
|
/* Making a switch from PC standard 60 Hz to NTSC 59.94 is excluded by the last condition. */
|
||||||
if ( (refresh_rate > 0.0f)
|
if ( (refresh_rate > 0.0f)
|
||||||
|
|
46
runloop.c
46
runloop.c
|
@ -4390,29 +4390,28 @@ float runloop_get_fastforward_ratio(
|
||||||
}
|
}
|
||||||
|
|
||||||
void runloop_set_video_swap_interval(
|
void runloop_set_video_swap_interval(
|
||||||
bool vrr_runloop_enable,
|
settings_t *settings)
|
||||||
bool crt_switching_active,
|
|
||||||
unsigned swap_interval_config,
|
|
||||||
unsigned black_frame_insertion,
|
|
||||||
unsigned shader_subframes,
|
|
||||||
float audio_max_timing_skew,
|
|
||||||
float video_refresh_rate,
|
|
||||||
double input_fps)
|
|
||||||
{
|
{
|
||||||
runloop_state_t *runloop_st = &runloop_state;
|
runloop_state_t *runloop_st = &runloop_state;
|
||||||
float core_hz = input_fps;
|
video_driver_state_t *video_st = video_state_get_ptr();
|
||||||
float timing_hz = crt_switching_active ?
|
float video_refresh_rate = settings->floats.video_refresh_rate;
|
||||||
input_fps : video_refresh_rate;
|
float audio_max_timing_skew = settings->floats.audio_max_timing_skew;
|
||||||
float swap_ratio;
|
float input_fps = video_st->av_info.timing.fps;
|
||||||
unsigned swap_integer;
|
float timing_fps = (video_st->flags & VIDEO_FLAG_CRT_SWITCHING_ACTIVE)
|
||||||
float timing_skew;
|
? input_fps : video_refresh_rate;
|
||||||
|
float swap_ratio = 1;
|
||||||
|
float timing_skew = 0;
|
||||||
|
unsigned swap_interval_config = settings->uints.video_swap_interval;
|
||||||
|
unsigned black_frame_insertion = settings->uints.video_black_frame_insertion;
|
||||||
|
unsigned shader_subframes = settings->uints.video_shader_subframes;
|
||||||
|
unsigned swap_integer = 1;
|
||||||
|
bool vrr_runloop_enable = settings->bools.vrr_runloop_enable;
|
||||||
|
|
||||||
/* If automatic swap interval selection is
|
/* If automatic swap interval selection is
|
||||||
* disabled, just record user-set value */
|
* disabled, just record user-set value */
|
||||||
if (swap_interval_config != 0)
|
if (swap_interval_config != 0)
|
||||||
{
|
{
|
||||||
runloop_st->video_swap_interval_auto =
|
runloop_st->video_swap_interval_auto = swap_interval_config;
|
||||||
swap_interval_config;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4425,11 +4424,12 @@ void runloop_set_video_swap_interval(
|
||||||
* > If BFI is active set swap interval to 1
|
* > If BFI is active set swap interval to 1
|
||||||
* > If Shader Subframes active, set swap interval to 1 */
|
* > If Shader Subframes active, set swap interval to 1 */
|
||||||
if ( (vrr_runloop_enable)
|
if ( (vrr_runloop_enable)
|
||||||
|| (core_hz > timing_hz)
|
|
||||||
|| (core_hz <= 0.0f)
|
|
||||||
|| (timing_hz <= 0.0f)
|
|
||||||
|| (black_frame_insertion)
|
|| (black_frame_insertion)
|
||||||
|| (shader_subframes > 1))
|
|| (shader_subframes > 1)
|
||||||
|
|| (input_fps > timing_fps)
|
||||||
|
|| (input_fps <= 0.0f)
|
||||||
|
|| (timing_fps <= 0.0f)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
runloop_st->video_swap_interval_auto = 1;
|
runloop_st->video_swap_interval_auto = 1;
|
||||||
return;
|
return;
|
||||||
|
@ -4437,7 +4437,7 @@ void runloop_set_video_swap_interval(
|
||||||
|
|
||||||
/* Check whether display refresh rate is an integer
|
/* Check whether display refresh rate is an integer
|
||||||
* multiple of core fps (within timing skew tolerance) */
|
* multiple of core fps (within timing skew tolerance) */
|
||||||
swap_ratio = timing_hz / core_hz;
|
swap_ratio = timing_fps / input_fps;
|
||||||
swap_integer = (unsigned)(swap_ratio + 0.5f);
|
swap_integer = (unsigned)(swap_ratio + 0.5f);
|
||||||
|
|
||||||
/* > Sanity check: swap interval must be in the
|
/* > Sanity check: swap interval must be in the
|
||||||
|
@ -4449,7 +4449,7 @@ void runloop_set_video_swap_interval(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
timing_skew = fabs(1.0f - core_hz / (timing_hz / (float)swap_integer));
|
timing_skew = fabs(1.0f - input_fps / (timing_fps / (float)swap_integer));
|
||||||
|
|
||||||
runloop_st->video_swap_interval_auto =
|
runloop_st->video_swap_interval_auto =
|
||||||
(timing_skew <= audio_max_timing_skew) ?
|
(timing_skew <= audio_max_timing_skew) ?
|
||||||
|
|
10
runloop.h
10
runloop.h
|
@ -394,14 +394,8 @@ float runloop_get_fastforward_ratio(
|
||||||
struct retro_fastforwarding_override *fastmotion_override);
|
struct retro_fastforwarding_override *fastmotion_override);
|
||||||
|
|
||||||
void runloop_set_video_swap_interval(
|
void runloop_set_video_swap_interval(
|
||||||
bool vrr_runloop_enable,
|
settings_t *settings);
|
||||||
bool crt_switching_active,
|
|
||||||
unsigned swap_interval_config,
|
|
||||||
unsigned black_frame_insertion,
|
|
||||||
unsigned shader_subframes,
|
|
||||||
float audio_max_timing_skew,
|
|
||||||
float video_refresh_rate,
|
|
||||||
double input_fps);
|
|
||||||
unsigned runloop_get_video_swap_interval(
|
unsigned runloop_get_video_swap_interval(
|
||||||
unsigned swap_interval_config);
|
unsigned swap_interval_config);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue