gl: Make vsync setting dynamic

This commit is contained in:
kd-11 2026-03-18 22:37:14 +03:00 committed by kd-11
parent 7a7e25f901
commit cb501e32ca
3 changed files with 31 additions and 15 deletions

View File

@ -138,21 +138,7 @@ void GLGSRender::on_init_thread()
gl::init();
gl::set_command_context(gl_state);
// Enable adaptive vsync if vsync is requested
int swap_interval = 0;
switch (g_cfg.video.vsync)
{
default:
case vsync_mode::off:
break;
case vsync_mode::adaptive:
swap_interval = -1;
break;
case vsync_mode::full:
swap_interval = 1;
break;
}
gl::set_swapinterval(swap_interval);
update_swap_interval();
if (g_cfg.video.debug_output)
gl::enable_debugging();
@ -593,6 +579,33 @@ void GLGSRender::on_exit()
gl::set_primary_context_thread(false);
}
void GLGSRender::update_swap_interval()
{
const vsync_mode current_mode = g_cfg.video.vsync;
if (current_mode == m_vsync_mode)
{
return;
}
// Enable adaptive vsync if vsync is requested
int swap_interval = 0;
switch (current_mode)
{
default:
case vsync_mode::off:
break;
case vsync_mode::adaptive:
swap_interval = -1;
break;
case vsync_mode::full:
swap_interval = 1;
break;
}
gl::set_swapinterval(swap_interval);
m_vsync_mode = current_mode;
}
void GLGSRender::clear_surface(u32 arg)
{
if (skip_current_frame) return;

View File

@ -186,6 +186,8 @@ private:
gl::texture* get_present_source(gl::present_surface_info* info, const rsx::avconf& avconfig);
void update_swap_interval();
public:
void set_viewport();
void set_scissor(bool clip_viewport);

View File

@ -252,6 +252,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
if (info.emu_flip)
{
evaluate_cpu_usage_reduction_limits();
update_swap_interval();
}
// Get window state