diff options
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r-- | indra/newview/llappviewer.cpp | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 37340a42b6..f72eb48f81 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,24 @@ bool LLAppViewer::frame() { pingMainloopTimeout("Main:Display"); gGLActive = TRUE; + + static U64 last_call = 0; + if (!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 +1468,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 +1493,6 @@ bool LLAppViewer::frame() ms_sleep(500); } - idleTimer.reset(); S32 total_work_pending = 0; S32 total_io_pending = 0; { @@ -1537,13 +1545,6 @@ bool LLAppViewer::frame() } } - if ((LLStartUp::getStartupState() >= STATE_CLEANUP) && - (frameTimer.getElapsedTimeF64() > FRAME_STALL_THRESHOLD)) - { - gFrameStalls++; - } - frameTimer.reset(); - resumeMainloopTimeout(); pingMainloopTimeout("Main:End"); @@ -4396,23 +4397,15 @@ bool LLAppViewer::initCache() // Init the texture cache // Allocate 80% of the cache size for textures const S32 MB = 1024 * 1024; - const S64 MIN_CACHE_SIZE = 64 * MB; + const S64 MIN_CACHE_SIZE = 256 * MB; const S64 MAX_CACHE_SIZE = 9984ll * MB; const S64 MAX_VFS_SIZE = 1024 * MB; // 1 GB S64 cache_size = (S64)(gSavedSettings.getU32("CacheSize")) * MB; cache_size = llclamp(cache_size, MIN_CACHE_SIZE, MAX_CACHE_SIZE); - S64 texture_cache_size = ((cache_size * 8) / 10); - S64 vfs_size = cache_size - texture_cache_size; - - if (vfs_size > MAX_VFS_SIZE) - { - // Give the texture cache more space, since the VFS can't be bigger than 1GB. - // This happens when the user's CacheSize setting is greater than 5GB. - vfs_size = MAX_VFS_SIZE; - texture_cache_size = cache_size - MAX_VFS_SIZE; - } + S64 vfs_size = llmin((S64)((cache_size * 2) / 10), MAX_VFS_SIZE); + S64 texture_cache_size = cache_size - vfs_size; S64 extra = LLAppViewer::getTextureCache()->initCache(LL_PATH_CACHE, texture_cache_size, texture_cache_mismatch); texture_cache_size -= extra; @@ -5585,6 +5578,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; |