Account for black frame insertion in refresh rate checks.

This commit is contained in:
Themaister 2014-07-13 19:45:28 +02:00
parent ce3183696c
commit fceda4f33b
2 changed files with 9 additions and 2 deletions

View File

@ -584,6 +584,9 @@ static bool gfx_ctx_set_video_mode(void *data,
attrib_ptr = NULL; 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. // Find desired video mode, and use that.
// If not fullscreen, we get desired windowed size, which is not appropriate. // If not fullscreen, we get desired windowed size, which is not appropriate.
if ((width == 0 && height == 0) || !fullscreen) 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) if (width != g_connector->modes[i].hdisplay || height != g_connector->modes[i].vdisplay)
continue; 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) if (!g_drm_mode || diff < minimum_fps_diff)
{ {
g_drm_mode = &g_connector->modes[i]; g_drm_mode = &g_connector->modes[i];

View File

@ -152,13 +152,17 @@ static bool get_video_mode(Display *dpy, unsigned width, unsigned height, XF86Vi
bool ret = false; bool ret = false;
float minimum_fps_diff = 0.0f; 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++) for (i = 0; i < num_modes; i++)
{ {
const XF86VidModeModeInfo *m = modes[i]; const XF86VidModeModeInfo *m = modes[i];
if (m->hdisplay == width && m->vdisplay == height) 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); float diff = fabsf(refresh - g_settings.video.refresh_rate);
if (!ret || diff < minimum_fps_diff) if (!ret || diff < minimum_fps_diff)
{ {
*mode = *m; *mode = *m;