Fix inconsistencies with the FPS scheduler (#241)

The current Fps manager will sometime skip the intended delay and start
the next frame immediately, I'm not 100% sure why it happens, but I
rewrote most of it to stay consistent and improved the overall precision
by compensating for OS wake delay after sleep and finishing with a busy
wait
I also changed the behavior of mlx_set_fps_goal to allow zero/negative
values and treat them as uncapped (like most graphics libraries)
This commit is contained in:
Daemo
2026-08-08 15:45:56 +02:00
committed by GitHub
parent c9df651a14
commit 63fe3088bf
4 changed files with 43 additions and 34 deletions
+2 -3
View File
@@ -8,7 +8,7 @@
namespace mlx
{
Application::Application() : p_mem_manager(std::make_unique<MemManager>()), p_sdl_manager(std::make_unique<SDLManager>()), m_fps(), m_in()
Application::Application() : p_mem_manager(std::make_unique<MemManager>()), p_sdl_manager(std::make_unique<SDLManager>()), m_fps(), m_in()
{
MLX_PROFILE_FUNCTION();
std::srand(std::time(nullptr));
@@ -33,8 +33,7 @@ namespace mlx
while(m_in.IsRunning())
{
if(!m_fps.Update())
continue;
m_fps.WaitUntilNextFrame();
m_in.FetchInputs();