diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-07-09 21:05:54 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-07-09 21:05:54 +0800 |
commit | 36585539dcf15af82335b9c106f41696823dc4b1 (patch) | |
tree | e599ecd76e9f31c05efb2febebf22d0377ec7ced /indra/newview/llappviewer.cpp | |
parent | d44065eb6d90af47401e9d0b76ad560edbb4927b (diff) | |
parent | ecdbdc8ea6fbd9a918584be1191e012af4b38af3 (diff) |
Merge branch 'main' into webrtc-voice
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r-- | indra/newview/llappviewer.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 1b1a47aa0d..91b06945cc 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -256,6 +256,8 @@ using namespace LL; #include "llcoproceduremanager.h" #include "llviewereventrecorder.h" +#include <chrono> + // *FIX: These extern globals should be cleaned up. // The globals either represent state/config/resource-storage of either // this app, or another 'component' of the viewer. App globals should be @@ -1374,9 +1376,10 @@ bool LLAppViewer::doFrame() { static LLCachedControl<U32> fpsLimitMaxFps(gSavedSettings, "MaxFPS", 0); + using TimePoint = std::chrono::steady_clock::time_point; + U64 fpsLimitSleepFor = 0; - U64 fpsLimitFrameStartTime = 0; - if(fpsLimitMaxFps > 0) fpsLimitFrameStartTime = LLTrace::BlockTimer::getCPUClockCount64(); + TimePoint fpsLimitFrameStartTime = std::chrono::steady_clock::now(); LL_RECORD_BLOCK_TIME(FTM_FRAME); { @@ -1550,12 +1553,13 @@ bool LLAppViewer::doFrame() if(fpsLimitMaxFps > 0) { - U64 fpsLimitFrameTime = LLTrace::BlockTimer::getCPUClockCount64() - fpsLimitFrameStartTime; - U64 desired_time_ns = (U32)(1000000.f / fpsLimitMaxFps); + auto elapsed = std::chrono::steady_clock::now() - fpsLimitFrameStartTime; - if((fpsLimitFrameTime+1000) < desired_time_ns) + long long fpsLimitFrameTime = std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count(); + U64 desired_time_us = (U32)(1000000.f / fpsLimitMaxFps); + if((fpsLimitFrameTime+1000) < desired_time_us) { - fpsLimitSleepFor = (desired_time_ns - fpsLimitFrameTime - 1000) * 1.0; + fpsLimitSleepFor = (desired_time_us - fpsLimitFrameTime - 1000) * 1.0; } } |