diff options
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 81 | ||||
-rwxr-xr-x | indra/newview/llviewerregion.h | 38 | ||||
-rwxr-xr-x | indra/newview/llworld.cpp | 48 |
3 files changed, 128 insertions, 39 deletions
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index f549f6740d..fe420fe551 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1047,25 +1047,23 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry) mImpl->mVisibleEntries.insert(entry); } -F32 LLViewerRegion::updateVisibleEntries(F32 max_time) +void LLViewerRegion::updateVisibleEntries(F32 max_time) { if(mDead) { - return max_time; + return; } if(mImpl->mVisibleGroups.empty() && mImpl->mVisibleEntries.empty()) { - return max_time; + return; } if(!sNewObjectCreationThrottle) { - return max_time; + return; } - LLTimer update_timer; - const F32 LARGE_SCENE_CONTRIBUTION = 100.f; //a large number to force to load the object. const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin(); const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame(); @@ -1163,21 +1161,21 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) mImpl->mLastCameraUpdate = cur_frame; } - return max_time - update_timer.getElapsedTimeF32(); + return; } -F32 LLViewerRegion::createVisibleObjects(F32 max_time) +void LLViewerRegion::createVisibleObjects(F32 max_time) { static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF"); if(mDead) { - return max_time; + return; } if(mImpl->mWaitingList.empty()) { mImpl->mVOCachePartition->setCullHistory(FALSE); - return max_time; + return; } //object projected area threshold @@ -1211,7 +1209,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time) mImpl->mVOCachePartition->setCullHistory(has_new_obj); - return max_time - update_timer.getElapsedTimeF32(); + return; } void LLViewerRegion::clearCachedVisibleObjects() @@ -1273,12 +1271,31 @@ void LLViewerRegion::clearCachedVisibleObjects() return; } -BOOL LLViewerRegion::idleUpdate(F32 max_update_time) +//perform some necessary but very light updates. +//to replace the function idleUpdate(...) in case there is no enough time. +void LLViewerRegion::lightIdleUpdate() +{ + if(!sVOCacheCullingEnabled) + { + return; + } + if(mImpl->mCacheMap.empty()) + { + return; + } + + //reset all occluders + mImpl->mVOCachePartition->resetOccluders(); +} + +void LLViewerRegion::idleUpdate(F32 max_update_time) { LLTimer update_timer; + F32 max_time; - // did_update returns TRUE if we did at least one significant update - BOOL did_update = mImpl->mLandp->idleUpdate(max_update_time); + mLastUpdate = LLViewerOctreeEntryData::getCurrentFrame(); + + mImpl->mLandp->idleUpdate(max_update_time); if (mParcelOverlay) { @@ -1288,11 +1305,11 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time) if(!sVOCacheCullingEnabled) { - return did_update; + return; } if(mImpl->mCacheMap.empty()) { - return did_update; + return; } if(mPaused) { @@ -1305,19 +1322,22 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time) //reset all occluders mImpl->mVOCachePartition->resetOccluders(); - max_update_time -= update_timer.getElapsedTimeF32(); + max_time = max_update_time - update_timer.getElapsedTimeF32(); //kill invisible objects - max_update_time = killInvisibleObjects(max_update_time); - - max_update_time = updateVisibleEntries(max_update_time); - createVisibleObjects(max_update_time); + killInvisibleObjects(max_time * 0.4f); + max_time = max_update_time - update_timer.getElapsedTimeF32(); + + updateVisibleEntries(max_time); + max_time = max_update_time - update_timer.getElapsedTimeF32(); + + createVisibleObjects(max_time); mImpl->mWaitingList.clear(); mImpl->mVisibleGroups.clear(); LLViewerCamera::sCurCameraID = old_camera_id; - return did_update; + return; } //update the throttling number for new object creation @@ -1361,20 +1381,20 @@ BOOL LLViewerRegion::isViewerCameraStatic() return sLastCameraUpdated < LLViewerOctreeEntryData::getCurrentFrame(); } -F32 LLViewerRegion::killInvisibleObjects(F32 max_time) +void LLViewerRegion::killInvisibleObjects(F32 max_time) { static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); -#if 1 if(!sVOCacheCullingEnabled) { - return max_time; + return; } if(mImpl->mActiveSet.empty()) { - return max_time; + return; } + LLTimer update_timer; LLVector4a camera_origin; camera_origin.load3(LLViewerCamera::getInstance()->getOrigin().mV); F32 squared_back_threshold = back_sphere_radius * back_sphere_radius; @@ -1402,6 +1422,11 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time) { killObject((*iter), delete_list); } + + if(max_time < update_timer.getElapsedTimeF32()) //time out + { + break; + } } if(iter == mImpl->mActiveSet.end()) @@ -1423,8 +1448,8 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time) } delete_list.clear(); } -#endif - return max_time; + + return; } void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list) diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 06a8d781a1..a6c1eb65d4 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -229,7 +229,8 @@ public: F32 getWidth() const { return mWidth; } - BOOL idleUpdate(F32 max_update_time); + void idleUpdate(F32 max_update_time); + void lightIdleUpdate(); bool addVisibleGroup(LLViewerOctreeGroup* group); void addVisibleCacheEntry(LLVOCacheEntry* entry); void addActiveCacheEntry(LLVOCacheEntry* entry); @@ -374,6 +375,9 @@ public: void addToCreatedList(U32 local_id); BOOL isPaused() const {return mPaused;} + S32 getLastUpdate() const {return mLastUpdate;} + + static BOOL isNewObjectCreationThrottleDisabled() {return sNewObjectCreationThrottle < 0;} private: void addToVOCacheTree(LLVOCacheEntry* entry); @@ -383,9 +387,9 @@ private: void replaceVisibleCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry); void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry - F32 killInvisibleObjects(F32 max_time); - F32 createVisibleObjects(F32 max_time); - F32 updateVisibleEntries(F32 max_time); //update visible entries + void killInvisibleObjects(F32 max_time); + void createVisibleObjects(F32 max_time); + void updateVisibleEntries(F32 max_time); //update visible entries void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type); void decodeBoundingInfo(LLVOCacheEntry* entry); @@ -426,9 +430,32 @@ public: static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not. static S32 sLastCameraUpdated; - LLFrameTimer & getRenderInfoRequestTimer() { return mRenderInfoRequestTimer; }; + struct CompareRegionByLastUpdate + { + bool operator()(const LLViewerRegion* const& lhs, const LLViewerRegion* const& rhs) + { + S32 lpa = lhs->getLastUpdate(); + S32 rpa = rhs->getLastUpdate(); + + //small mLastUpdate first + if(lpa < rpa) + { + return true; + } + else if(lpa > rpa) + { + return false; + } + else + { + return lhs < rhs; + } + } + }; + typedef std::set<LLViewerRegion*, CompareRegionByLastUpdate> region_priority_list_t; + private: static S32 sNewObjectCreationThrottle; LLViewerRegionImpl * mImpl; @@ -437,6 +464,7 @@ private: F32 mWidth; // Width of region on a side (meters) U64 mHandle; F32 mTimeDilation; // time dilation of physics simulation on simulator + S32 mLastUpdate; //last time called idleUpdate() // simulator name std::string mName; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 1940bdcccc..d67e4ca71d 100755 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -665,25 +665,61 @@ static LLTrace::SampleStatHandle<> sNumActiveCachedObjects("numactivecachedobjec void LLWorld::updateRegions(F32 max_update_time) { + LLTimer update_timer; + mNumOfActiveCachedObjects = 0; + if(LLViewerCamera::getInstance()->isChanged()) { LLViewerRegion::sLastCameraUpdated = LLViewerOctreeEntryData::getCurrentFrame() + 1; } LLViewerRegion::calcNewObjectCreationThrottle(); + if(LLViewerRegion::isNewObjectCreationThrottleDisabled()) + { + max_update_time = llmax(max_update_time, 1.0f); //seconds, loosen the time throttle. + } - // Perform idle time updates for the regions (and associated surfaces) + F32 max_time = llmin((F32)(max_update_time - update_timer.getElapsedTimeF32()), max_update_time * 0.25f); + //update the self avatar region + LLViewerRegion* self_regionp = gAgent.getRegion(); + if(self_regionp) + { + self_regionp->idleUpdate(max_time); + } + + //sort regions by its mLastUpdate + //smaller mLastUpdate first to make sure every region has chance to get updated. + LLViewerRegion::region_priority_list_t region_list; for (region_list_t::iterator iter = mRegionList.begin(); iter != mRegionList.end(); ++iter) { - (*iter)->idleUpdate(max_update_time); + LLViewerRegion* regionp = *iter; + if(regionp != self_regionp) + { + region_list.insert(regionp); + } + mNumOfActiveCachedObjects += regionp->getNumOfActiveCachedObjects(); } - mNumOfActiveCachedObjects = 0; - for (region_list_t::iterator iter = mRegionList.begin(); - iter != mRegionList.end(); ++iter) + // Perform idle time updates for the regions (and associated surfaces) + for (LLViewerRegion::region_priority_list_t::iterator iter = region_list.begin(); + iter != region_list.end(); ++iter) { - mNumOfActiveCachedObjects += (*iter)->getNumOfActiveCachedObjects(); + if(max_time > 0.f) + { + max_time = llmin((F32)(max_update_time - update_timer.getElapsedTimeF32()), max_update_time * 0.25f); + } + + if(max_time > 0.f) + { + (*iter)->idleUpdate(max_time); + } + else + { + //perform some necessary but very light updates. + (*iter)->lightIdleUpdate(); + } } + sample(sNumActiveCachedObjects, mNumOfActiveCachedObjects); } |