mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +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 <unistd.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <EGL/eglext.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)
|
if (width != g_connector->modes[i].hdisplay || height != g_connector->modes[i].vdisplay)
|
||||||
continue;
|
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];
|
g_drm_mode = &g_connector->modes[i];
|
||||||
minimum_fps_diff = g_drm_mode->vrefresh - g_settings.video.refresh_rate;
|
minimum_fps_diff = diff;
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
#include <math.h>
|
||||||
#include "../image/image.h"
|
#include "../image/image.h"
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include "../../input/input_common.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];
|
*desktop_mode = *modes[0];
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
float minimum_fps_diff = 0.0f;
|
||||||
|
|
||||||
for (i = 0; i < num_modes; i++)
|
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;
|
ret = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user