summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2017-06-27 22:51:39 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2017-06-27 22:51:39 +0300
commitd80981de767e2ae34eb7dde9ad367fa360890215 (patch)
treeeebb5373c832e3334c25c8b79e3ffa62b2804513
parent8a75b5eb18b77c30baead8d8ac42b1d63f903efe (diff)
MAINT-7554 Frame throttling
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/llappviewer.cpp61
-rw-r--r--indra/newview/llappviewer.h5
-rw-r--r--indra/newview/llviewerstats.cpp3
4 files changed, 53 insertions, 27 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c544205df0..5b501514c7 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -812,6 +812,17 @@
<key>Value</key>
<integer>0</integer>
</map>
+ <key>FramePerSecondLimit</key>
+ <map>
+ <key>Comment</key>
+ <string>Test</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>U32</string>
+ <key>Value</key>
+ <integer>120</integer>
+ </map>
<key>BackgroundYieldTime</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 37340a42b6..b4c433893d 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -315,8 +315,6 @@ F32SecondsImplicit gFrameIntervalSeconds = 0.f;
F32 gFPSClamped = 10.f; // Pretend we start at target rate.
F32 gFrameDTClamped = 0.f; // Time between adjacent checks to network for packets
U64MicrosecondsImplicit gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds
-U32 gFrameStalls = 0;
-const F64 FRAME_STALL_THRESHOLD = 1.0;
LLTimer gRenderStartTime;
LLFrameTimer gForegroundTime;
@@ -705,7 +703,8 @@ LLAppViewer::LLAppViewer()
mFastTimerLogThread(NULL),
mUpdater(new LLUpdaterService()),
mSettingsLocationList(NULL),
- mIsFirstRun(false)
+ mIsFirstRun(false),
+ mMinMicroSecPerFrame(0.f)
{
if(NULL != sInstance)
{
@@ -1249,6 +1248,9 @@ bool LLAppViewer::init()
joystick->setNeedsReset(true);
/*----------------------------------------------------------------------*/
+ gSavedSettings.getControl("FramePerSecondLimit")->getSignal()->connect(boost::bind(&LLAppViewer::onChangeFrameLimit, this, _2));
+ onChangeFrameLimit(gSavedSettings.getLLSD("FramePerSecondLimit"));
+
return true;
}
@@ -1328,9 +1330,6 @@ bool LLAppViewer::frame()
LLEventPump& mainloop(LLEventPumps::instance().obtain("mainloop"));
LLSD newFrame;
- LLTimer frameTimer,idleTimer;
- LLTimer debugTime;
-
//LLPrivateMemoryPoolTester::getInstance()->run(false) ;
//LLPrivateMemoryPoolTester::getInstance()->run(true) ;
//LLPrivateMemoryPoolTester::destroy() ;
@@ -1371,14 +1370,6 @@ bool LLAppViewer::frame()
gViewerWindow->getWindow()->gatherInput();
}
-#if 1 && !LL_RELEASE_FOR_DOWNLOAD
- // once per second debug info
- if (debugTime.getElapsedTimeF32() > 1.f)
- {
- debugTime.reset();
- }
-
-#endif
//memory leaking simulation
LLFloaterMemLeak* mem_leak_instance =
LLFloaterReg::findTypedInstance<LLFloaterMemLeak>("mem_leaking");
@@ -1432,7 +1423,25 @@ bool LLAppViewer::frame()
{
pingMainloopTimeout("Main:Display");
gGLActive = TRUE;
+
+ static U64 last_call = 0;
+ if (LLStartUp::getStartupState() == STATE_STARTED
+ && !gTeleportDisplay)
+ {
+ // 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();
+
display();
+
pingMainloopTimeout("Main:Snapshot");
LLFloaterSnapshot::update(); // take snapshots
LLFloaterOutfitSnapshot::update();
@@ -1460,7 +1469,8 @@ bool LLAppViewer::frame()
|| !gFocusMgr.getAppHasFocus())
{
// Sleep if we're not rendering, or the window is minimized.
- S32 milliseconds_to_sleep = llclamp(gSavedSettings.getS32("BackgroundYieldTime"), 0, 1000);
+ static LLCachedControl<S32> s_bacground_yeild_time(gSavedSettings, "BackgroundYieldTime", 40);
+ S32 milliseconds_to_sleep = llclamp((S32)s_bacground_yeild_time, 0, 1000);
// don't sleep when BackgroundYieldTime set to 0, since this will still yield to other threads
// of equal priority on Windows
if (milliseconds_to_sleep > 0)
@@ -1484,7 +1494,6 @@ bool LLAppViewer::frame()
ms_sleep(500);
}
- idleTimer.reset();
S32 total_work_pending = 0;
S32 total_io_pending = 0;
{
@@ -1537,13 +1546,6 @@ bool LLAppViewer::frame()
}
}
- if ((LLStartUp::getStartupState() >= STATE_CLEANUP) &&
- (frameTimer.getElapsedTimeF64() > FRAME_STALL_THRESHOLD))
- {
- gFrameStalls++;
- }
- frameTimer.reset();
-
resumeMainloopTimeout();
pingMainloopTimeout("Main:End");
@@ -5585,6 +5587,19 @@ void LLAppViewer::disconnectViewer()
LLUrlEntryParcel::setDisconnected(gDisconnected);
}
+bool LLAppViewer::onChangeFrameLimit(LLSD const & evt)
+{
+ if (evt.asInteger() > 0)
+ {
+ mMinMicroSecPerFrame = 1000000 / evt.asInteger();
+ }
+ else
+ {
+ mMinMicroSecPerFrame = 0;
+ }
+ return false;
+}
+
void LLAppViewer::forceErrorLLError()
{
LL_ERRS() << "This is a deliberate llerror" << LL_ENDL;
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 7bb3c32c51..9656deb4e1 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -255,6 +255,8 @@ private:
void sendLogoutRequest();
void disconnectViewer();
+ bool onChangeFrameLimit(LLSD const & evt);
+
// *FIX: the app viewer class should be some sort of singleton, no?
// Perhaps its child class is the singleton and this should be an abstract base.
static LLAppViewer* sInstance;
@@ -316,6 +318,8 @@ private:
LLAppCoreHttp mAppCoreHttp;
bool mIsFirstRun;
+ U64 mMinMicroSecPerFrame; // frame throttling
+
//---------------------------------------------
//*NOTE: Mani - legacy updater stuff
// Still useable?
@@ -371,7 +375,6 @@ extern F32SecondsImplicit gFrameTimeSeconds; // Loses msec precision after ~4
extern F32SecondsImplicit gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds
extern F32 gFPSClamped; // Frames per second, smoothed, weighted toward last frame
extern F32 gFrameDTClamped;
-extern U32 gFrameStalls;
extern LLTimer gRenderStartTime;
extern LLFrameTimer gForegroundTime;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index f52c82dab7..dd44697dcd 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -585,9 +585,6 @@ void send_stats()
misc["string_1"] = llformat("%d", window_size);
misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gTextureTimer.getElapsedTimeF32(), gFrameTimeSeconds.value());
-// misc["int_1"] = LLSD::Integer(gSavedSettings.getU32("RenderQualityPerformance")); // Steve: 1.21
-// misc["int_2"] = LLSD::Integer(gFrameStalls); // Steve: 1.21
-
F32 unbaked_time = LLVOAvatar::sUnbakedTime * 1000.f / gFrameTimeSeconds;
misc["int_1"] = LLSD::Integer(unbaked_time); // Steve: 1.22
F32 grey_time = LLVOAvatar::sGreyTime * 1000.f / gFrameTimeSeconds;