summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormobserveur <mobserveur@gmail.com>2024-07-05 20:17:25 +0200
committermobserveur <mobserveur@gmail.com>2024-07-05 20:17:25 +0200
commit8662083cf4130922732aa8fba655310664b80d8b (patch)
tree4064929b17dac5a29f5eb71cb2aa1f403930f10c
parent9fe3404f767b7613db2e11935999549b8a13f12b (diff)
Fix for the fps limiter on intel and amd cpus
This commit fixes the fps limiter for intel and amd cpus
-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 0f1b5a789b..86da40fcf5 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;
}
}