mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
When modechanging on X11, try to match configured refresh rate.
This commit is contained in:
parent
b1270496a3
commit
45205cc5d7
@ -34,6 +34,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <sys/time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
@ -599,19 +600,11 @@ static bool gfx_ctx_set_video_mode(void *data,
|
||||
if (width != g_connector->modes[i].hdisplay || height != g_connector->modes[i].vdisplay)
|
||||
continue;
|
||||
|
||||
if (!g_drm_mode)
|
||||
float diff = fabsf(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];
|
||||
minimum_fps_diff = g_drm_mode->vrefresh - g_settings.video.refresh_rate;
|
||||
}
|
||||
else
|
||||
{
|
||||
float diff = g_connector->modes[i].vrefresh - g_settings.video.refresh_rate;
|
||||
if (diff < minimum_fps_diff)
|
||||
{
|
||||
g_drm_mode = &g_connector->modes[i];
|
||||
minimum_fps_diff = diff;
|
||||
}
|
||||
minimum_fps_diff = diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <math.h>
|
||||
#include "../image/image.h"
|
||||
#include "../../general.h"
|
||||
#include "../../input/input_common.h"
|
||||
@ -146,13 +147,21 @@ static bool get_video_mode(Display *dpy, unsigned width, unsigned height, XF86Vi
|
||||
*desktop_mode = *modes[0];
|
||||
|
||||
bool ret = false;
|
||||
float minimum_fps_diff = 0.0f;
|
||||
|
||||
for (i = 0; i < num_modes; i++)
|
||||
{
|
||||
if (modes[i]->hdisplay == width && modes[i]->vdisplay == height)
|
||||
const XF86VidModeModeInfo *m = modes[i];
|
||||
if (m->hdisplay == width && m->vdisplay == height)
|
||||
{
|
||||
*mode = *modes[i];
|
||||
float refresh = 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;
|
||||
minimum_fps_diff = diff;
|
||||
}
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user