RenderingManager: FPS software limiter even with VSYNC

V-sync on multiple windows is not always performing well. So limiting to 61 FPS works with both VSYNC at 60FPS or without VSYNC. This means the settings for VSYNC is useless (removed from Settings panel).
This commit is contained in:
Bruno Herbelin
2022-05-18 23:46:27 +02:00
parent cc69baf0dd
commit cb0abd51db
2 changed files with 21 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
/*
/*
* This file is part of vimix - video live mixer
*
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@gmail.com>
@@ -311,6 +311,13 @@ void Rendering::pushBackDrawCallback(RenderingCallback function)
void Rendering::draw()
{
// Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
glfwPollEvents();
// change windows fullscreen mode if requested
main_.toggleFullscreen_();
output_.toggleFullscreen_();
@@ -338,28 +345,21 @@ void Rendering::draw()
request_screenshot_ = false;
}
// software framerate limiter < 61 FPS
{
static GTimer *timer = g_timer_new ();
double elapsed = g_timer_elapsed (timer, NULL) * 1000000.0;
if ( (elapsed < 16390.0) && (elapsed > 0.0) )
g_usleep( 16390 - (gulong)elapsed );
g_timer_start(timer);
}
// swap GL buffers
glfwSwapBuffers(main_.window());
// draw output window (and swap buffer output)
output_.draw( Mixer::manager().session()->frame() );
// software framerate limiter 60FPS if not v-sync
if ( Settings::application.render.vsync < 1 ) {
static GTimer *timer = g_timer_new ();
double elapsed = g_timer_elapsed (timer, NULL) * 1000000.0;
if ( (elapsed < 16000.0) && (elapsed > 0.0) )
g_usleep( 16000 - (gulong)elapsed );
g_timer_start(timer);
}
// Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
glfwPollEvents();
}
void Rendering::terminate()
@@ -983,13 +983,13 @@ void RenderingWindow::draw(FrameBuffer *fb)
glBindTexture(GL_TEXTURE_2D, 0);
}
// restore attribs
Rendering::manager().popAttrib();
// swap buffer
glfwSwapBuffers(window_);
}
// restore attribs
Rendering::manager().popAttrib();
// give back context ownership
glfwMakeContextCurrent(master_);
}

View File

@@ -7281,9 +7281,9 @@ void Navigator::RenderMainPannelSettings()
static bool multi = (Settings::application.render.multisampling > 0);
static bool gpu = Settings::application.render.gpu_decoding;
bool change = false;
change |= ImGuiToolkit::ButtonSwitch( "Vertical synchronization", &vsync);
change |= ImGuiToolkit::ButtonSwitch( "Blit framebuffer", &blit);
#ifndef NDEBUG
change |= ImGuiToolkit::ButtonSwitch( "Vertical synchronization", &vsync);
change |= ImGuiToolkit::ButtonSwitch( "Antialiasing framebuffer", &multi);
#endif
// hardware support deserves more explanation