present_mode: proper vsync implementation

pull/1365/head
flightlessmango 5 days ago
parent 2a2cc4ada2
commit ed6cf225f1

@ -131,8 +131,19 @@ EXPORT_C_(int) glXMakeCurrent(void* dpy, void* drawable, void* ctx) {
return ret; return ret;
} }
#ifndef GLX_SWAP_INTERVAL_EXT
#define GLX_SWAP_INTERVAL_EXT 0x20F1
#endif
static void do_imgui_swap(void *dpy, void *drawable) static void do_imgui_swap(void *dpy, void *drawable)
{ {
static auto last_time = std::chrono::steady_clock::now();
auto current_time = std::chrono::steady_clock::now();
std::chrono::duration<double> elapsed_seconds = current_time - last_time;
if (HUDElements.vsync == 10 || elapsed_seconds.count() > 5.0)
glx.QueryDrawable(dpy, drawable, GLX_SWAP_INTERVAL_EXT, &HUDElements.vsync);
GLint vp[4]; GLint vp[4];
if (!is_blacklisted()) { if (!is_blacklisted()) {
imgui_create(glx.GetCurrentContext(), gl_wsi::GL_WSI_GLX); imgui_create(glx.GetCurrentContext(), gl_wsi::GL_WSI_GLX);

@ -52,6 +52,7 @@ class HudElements{
uint32_t vendorID; uint32_t vendorID;
int hdr_status = 0; int hdr_status = 0;
int refresh = 0; int refresh = 0;
unsigned int vsync = 10;
std::unique_ptr<WineSync> winesync_ptr = nullptr; std::unique_ptr<WineSync> winesync_ptr = nullptr;
std::unique_ptr<Net> net = nullptr; std::unique_ptr<Net> net = nullptr;
#ifdef __linux__ #ifdef __linux__
@ -158,11 +159,8 @@ class HudElements{
std::string get_present_mode(){ std::string get_present_mode(){
if (is_vulkan) if (is_vulkan)
return presentModeMap[cur_present_mode]; return presentModeMap[cur_present_mode];
// TODO: the opengl side is probably not as solid.
// But it also might not be possible to figure out if vsync
// is on or off unless we specify it.
else else
return params->gl_vsync == 0 ? "OFF" : "ON"; return vsync == 0 ? "OFF" : "ON";
} }
}; };

Loading…
Cancel
Save