summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-07-06 08:09:31 +0800
committerErik Kundiman <erik@megapahit.org>2024-07-06 08:09:31 +0800
commit57f91acf044a3cf2c8a0175aab10fbb7b1e90a7f (patch)
tree805c3e55d83094fa2010ee66bcd2b6a204736f42 /indra/newview/llappviewer.cpp
parent29d68ecb229ecb19e6d0da4cf5fbd8e3bbdde2cf (diff)
parent8662083cf4130922732aa8fba655310664b80d8b (diff)
Merge branch 'main' into maint-b
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r--indra/newview/llappviewer.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 768d131073..975935ee6f 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
@@ -1370,9 +1372,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);
{
@@ -1546,12 +1549,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;
}
}