summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-07-05 20:37:39 +0800
committerErik Kundiman <erik@megapahit.org>2024-07-05 20:37:39 +0800
commitbe75d0eba7ff0a29573139aee593debba81cc65d (patch)
tree2545f54e724b38702be6876e3b0ee4948bf64d25 /indra/newview/llappviewer.cpp
parent6814c077701786f9d69e9f5c0f78ed496a3122cf (diff)
parent6369047dcb74323b248de59bc8187db0d315548a (diff)
Merge branch 'main' into webrtc-voice
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r--indra/newview/llappviewer.cpp37
1 files changed, 12 insertions, 25 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ab87ff6d2c..1b1a47aa0d 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -393,7 +393,6 @@ static std::string gLaunchFileOnQuit;
// Used on Win32 for other apps to identify our window (eg, win_setup)
const char* const VIEWER_WINDOW_CLASSNAME = "Second Life";
-U64 fpsLimitSleepUntil = 0; // fps limiter : time until to render the frame again
//----------------------------------------------------------------------------
@@ -1373,21 +1372,11 @@ bool LLAppViewer::frame()
bool LLAppViewer::doFrame()
{
+ static LLCachedControl<U32> fpsLimitMaxFps(gSavedSettings, "MaxFPS", 0);
- // FPS Limit
-
- U64 fpsLimitNow = LLTrace::BlockTimer::getCPUClockCount64();
- U64 fpsLimitFrameStartTime = fpsLimitNow;
- if(fpsLimitSleepUntil > 0)
- {
- if(fpsLimitSleepUntil > fpsLimitNow) return 0;
- }
- else
- {
- fpsLimitSleepUntil = 0;
- }
-
-
+ U64 fpsLimitSleepFor = 0;
+ U64 fpsLimitFrameStartTime = 0;
+ if(fpsLimitMaxFps > 0) fpsLimitFrameStartTime = LLTrace::BlockTimer::getCPUClockCount64();
LL_RECORD_BLOCK_TIME(FTM_FRAME);
{
@@ -1559,24 +1548,17 @@ bool LLAppViewer::doFrame()
}
}
- // fps limiter
-
- fpsLimitNow = LLTrace::BlockTimer::getCPUClockCount64();
- U64 fpsLimitFrameTime = fpsLimitNow - fpsLimitFrameStartTime;
- static LLCachedControl<U32> fpsLimitMaxFps(gSavedSettings, "MaxFPS", 0);
-
if(fpsLimitMaxFps > 0)
{
+ U64 fpsLimitFrameTime = LLTrace::BlockTimer::getCPUClockCount64() - fpsLimitFrameStartTime;
U64 desired_time_ns = (U32)(1000000.f / fpsLimitMaxFps);
- if(fpsLimitFrameTime < desired_time_ns)
+ if((fpsLimitFrameTime+1000) < desired_time_ns)
{
- U64 fpsLimitSleepUntil_for = desired_time_ns - fpsLimitFrameTime;
- fpsLimitSleepUntil = LLTrace::BlockTimer::getCPUClockCount64() + fpsLimitSleepUntil_for;
+ fpsLimitSleepFor = (desired_time_ns - fpsLimitFrameTime - 1000) * 1.0;
}
}
-
{
LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df pauseMainloopTimeout" )
pingMainloopTimeout("Main:Sleep");
@@ -1589,6 +1571,11 @@ bool LLAppViewer::doFrame()
//LL_RECORD_BLOCK_TIME(SLEEP2);
LL_PROFILE_ZONE_WARN( "Sleep2" )
+ if(fpsLimitSleepFor)
+ {
+ usleep(fpsLimitSleepFor);
+ }
+
// yield some time to the os based on command line option
static LLCachedControl<S32> yield_time(gSavedSettings, "YieldTime", -1);
if(yield_time >= 0)