diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index b3ee18eebe..2aaa0a9992 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -584,6 +584,9 @@ static bool gfx_ctx_set_video_mode(void *data, attrib_ptr = NULL; } + // If we use black frame insertion, we fake a 60 Hz monitor for 120 Hz one, etc, so try to match that. + float refresh_mod = g_settings.video.black_frame_insertion ? 0.5f : 1.0f; + // Find desired video mode, and use that. // If not fullscreen, we get desired windowed size, which is not appropriate. if ((width == 0 && height == 0) || !fullscreen) @@ -600,7 +603,7 @@ static bool gfx_ctx_set_video_mode(void *data, if (width != g_connector->modes[i].hdisplay || height != g_connector->modes[i].vdisplay) continue; - float diff = fabsf(g_connector->modes[i].vrefresh - g_settings.video.refresh_rate); + float diff = fabsf(refresh_mod * g_connector->modes[i].vrefresh - g_settings.video.refresh_rate); if (!g_drm_mode || diff < minimum_fps_diff) { g_drm_mode = &g_connector->modes[i]; diff --git a/gfx/context/x11_common.c b/gfx/context/x11_common.c index 9882322713..099de2687d 100644 --- a/gfx/context/x11_common.c +++ b/gfx/context/x11_common.c @@ -152,13 +152,17 @@ static bool get_video_mode(Display *dpy, unsigned width, unsigned height, XF86Vi bool ret = false; float minimum_fps_diff = 0.0f; + // If we use black frame insertion, we fake a 60 Hz monitor for 120 Hz one, etc, so try to match that. + float refresh_mod = g_settings.video.black_frame_insertion ? 0.5f : 1.0f; + for (i = 0; i < num_modes; i++) { const XF86VidModeModeInfo *m = modes[i]; if (m->hdisplay == width && m->vdisplay == height) { - float refresh = m->dotclock * 1000.0f / (m->htotal * m->vtotal); + float refresh = refresh_mod * m->dotclock * 1000.0f / (m->htotal * m->vtotal); float diff = fabsf(refresh - g_settings.video.refresh_rate); + if (!ret || diff < minimum_fps_diff) { *mode = *m;