From 3d39461d7adb9bdbc7a6bfcb225c0b3620383895 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Tue, 21 Jul 2020 11:45:30 -0400 Subject: [PATCH] Add option to disable main loop sleep --- .../newview/app_settings/settings_alchemy.xml | 11 +++++++++ indra/newview/llappviewer.cpp | 24 +++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/indra/newview/app_settings/settings_alchemy.xml b/indra/newview/app_settings/settings_alchemy.xml index 75b8c728176..e94a7295262 100644 --- a/indra/newview/app_settings/settings_alchemy.xml +++ b/indra/newview/app_settings/settings_alchemy.xml @@ -288,6 +288,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>AlchemyMainLoopSleep</key> + <map> + <key>Comment</key> + <string>Sleep main loop after 90-ish fps threshold to reduce needless gpu strain</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>AlchemyMapShowAgentCount</key> <map> <key>Comment</key> diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 5760b3a7014..c4b1c9d1060 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1492,20 +1492,24 @@ bool LLAppViewer::doFrame() display(); - static U64 last_call = 0; - if (!gTeleportDisplay || gGLManager.mIsIntel) // SL-10625...throttle early, throttle often with Intel + static const LLCachedControl<bool> sleep_main_loop(gSavedSettings, "AlchemyMainLoopSleep", true); + if (sleep_main_loop) { - // Frame/draw throttling - U64 elapsed_time = LLTimer::getTotalTime() - last_call; - if (elapsed_time < mMinMicroSecPerFrame) + static U64 last_call = 0; + if (!gTeleportDisplay || gGLManager.mIsIntel) // SL-10625...throttle early, throttle often with Intel { - LL_RECORD_BLOCK_TIME(FTM_SLEEP); - // llclamp for when time function gets funky - U64 sleep_time = llclamp(mMinMicroSecPerFrame - elapsed_time, (U64)1, (U64)1e6); - micro_sleep(sleep_time, 0); + // Frame/draw throttling + U64 elapsed_time = LLTimer::getTotalTime() - last_call; + if (elapsed_time < mMinMicroSecPerFrame) + { + LL_RECORD_BLOCK_TIME(FTM_SLEEP); + // llclamp for when time function gets funky + U64 sleep_time = llclamp(mMinMicroSecPerFrame - elapsed_time, (U64)1, (U64)1e6); + micro_sleep(sleep_time, 0); + } } + last_call = LLTimer::getTotalTime(); } - last_call = LLTimer::getTotalTime(); pingMainloopTimeout("Main:Snapshot"); LLFloaterSnapshot::update(); // take snapshots -- GitLab