diff options
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/newview/app_settings/settings.xml | 27 | ||||
-rw-r--r-- | indra/newview/llvieweroctree.h | 1 | ||||
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 113 | ||||
-rwxr-xr-x | indra/newview/llviewerregion.h | 38 | ||||
-rwxr-xr-x | indra/newview/llvocache.cpp | 69 | ||||
-rwxr-xr-x | indra/newview/llvocache.h | 7 | ||||
-rwxr-xr-x | indra/newview/llworld.cpp | 48 | ||||
-rwxr-xr-x | indra/newview/pipeline.cpp | 4 |
8 files changed, 195 insertions, 112 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index df9dd3e1b5..6c1a7ed897 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -731,18 +731,6 @@ <key>Value</key> <integer>0</integer> </map> - - <key>BackDistanceFactor</key> - <map> - <key>Comment</key> - <string>Keep invisible objects in memory which are in the distance range (the factor * draw_distance) to the camera</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>F32</string> - <key>Value</key> - <real>0.125</real> - </map> <key>BackgroundYieldTime</key> <map> <key>Comment</key> @@ -754,17 +742,6 @@ <key>Value</key> <integer>40</integer> </map> - <key>BackProjectionAngleSquared</key> - <map> - <key>Comment</key> - <string>squared tan(object bbox projection angle). that of invisible objects greater than this threshold are kept in memory</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>F32</string> - <key>Value</key> - <real>0.0311</real> - </map> <key>BackShpereCullingRadius</key> <map> <key>Comment</key> @@ -7125,7 +7102,7 @@ <real>0.75</real> </array> </map> - <key>ObjectProjectionAreaCutOFF</key> + <key>ObjectProjectionAreaCutOff</key> <map> <key>Comment</key> <string>Threshold in number of pixels of the projection area in screen of object bounding sphere. Objects smaller than this threshold are not rendered.</string> @@ -7134,7 +7111,7 @@ <key>Type</key> <string>F32</string> <key>Value</key> - <real>1.0</real> + <real>16.0</real> </map> <key>ParcelMediaAutoPlayEnable</key> <map> diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index 611f285c8e..b03047cbbe 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -217,6 +217,7 @@ public: BOOL isVisible() const; virtual BOOL isRecentlyVisible() const; S32 getVisible(LLViewerCamera::eCameraID id) const {return mVisible[id];} + S32 getAnyVisible() const {return mAnyVisible;} bool isEmpty() const { return mOctreeNode->isEmpty(); } U32 getState() {return mState; } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index cbce2674a7..56e0142dd6 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,28 +1161,24 @@ 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 - F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio(); - F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f; - projection_threshold *= projection_threshold; - + F32 projection_threshold = LLVOCacheEntry::getSquaredObjectScreenAreaThreshold(); + S32 throttle = sNewObjectCreationThrottle; BOOL has_new_obj = FALSE; LLTimer update_timer; @@ -1211,7 +1205,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 +1267,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; + + mLastUpdate = LLViewerOctreeEntryData::getCurrentFrame(); - // did_update returns TRUE if we did at least one significant update - BOOL did_update = mImpl->mLandp->idleUpdate(max_update_time); + mImpl->mLandp->idleUpdate(max_update_time); if (mParcelOverlay) { @@ -1288,32 +1301,39 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time) if(!sVOCacheCullingEnabled) { - return did_update; + return; } if(mImpl->mCacheMap.empty()) { - return did_update; + return; } if(mPaused) { mPaused = FALSE; //unpause. } + LLViewerCamera::eCameraID old_camera_id = LLViewerCamera::sCurCameraID; + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + //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(); - return did_update; + LLViewerCamera::sCurCameraID = old_camera_id; + return; } //update the throttling number for new object creation @@ -1357,18 +1377,24 @@ BOOL LLViewerRegion::isViewerCameraStatic() return sLastCameraUpdated < LLViewerOctreeEntryData::getCurrentFrame(); } -F32 LLViewerRegion::killInvisibleObjects(F32 max_time) +void LLViewerRegion::killInvisibleObjects(F32 max_time) { -#if 1 + static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); + 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; + bool unstable = sNewObjectCreationThrottle < 0; size_t max_update = unstable ? mImpl->mActiveSet.size() : 64; if(!mInvisibilityCheckHistory && isViewerCameraStatic()) @@ -1388,10 +1414,15 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time) iter = mImpl->mActiveSet.begin(); } - if(!(*iter)->isRecentlyVisible() && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated)) + if(!(*iter)->isAnyVisible(camera_origin, squared_back_threshold) && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated)) { killObject((*iter), delete_list); } + + if(max_time < update_timer.getElapsedTimeF32()) //time out + { + break; + } } if(iter == mImpl->mActiveSet.end()) @@ -1413,8 +1444,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) @@ -1430,11 +1461,15 @@ void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& iter != child_list.end(); iter++) { LLViewerObject* child = *iter; - if(child->mDrawable->isRecentlyVisible()) + if(child->mDrawable) { - //set the parent group visible if any of its children visible. - ((LLViewerOctreeEntryData*)drawablep)->setVisible(); - return; + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)child->mDrawable->getGroup(); + if(group && group->isAnyRecentlyVisible()) + { + //set the parent group visible if any of its children visible. + ((LLViewerOctreeEntryData*)drawablep)->setVisible(); + return; + } } } delete_list.push_back(drawablep); 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/llvocache.cpp b/indra/newview/llvocache.cpp index b1c7423b49..2ff2d0f341 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -35,8 +35,6 @@ #include "pipeline.h" #include "llagentcamera.h" -F32 LLVOCacheEntry::sBackDistanceSquared = 0.f; -F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f; U32 LLVOCacheEntry::sMinFrameRange = 0; BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE; @@ -341,43 +339,53 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const //static void LLVOCacheEntry::updateDebugSettings() { - //distance to keep objects = back_dist_factor * draw_distance - static LLCachedControl<F32> back_dist_factor(gSavedSettings,"BackDistanceFactor"); - - //squared tan(projection angle of the bbox), default is 10 (degree) - static LLCachedControl<F32> squared_back_angle(gSavedSettings,"BackProjectionAngleSquared"); - //the number of frames invisible objects stay in memory static LLCachedControl<U32> inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime"); sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum +} - sBackDistanceSquared = back_dist_factor * gAgentCamera.mDrawDistance; - sBackDistanceSquared *= sBackDistanceSquared; +//static +F32 LLVOCacheEntry::getSquaredObjectScreenAreaThreshold() +{ + static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOff"); - sBackAngleTanSquared = squared_back_angle; + //object projected area threshold + F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio(); + F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f; + projection_threshold *= projection_threshold; + + return projection_threshold; } -bool LLVOCacheEntry::isRecentlyVisible() const +bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold) { - bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); - - if(!vis && getGroup()) + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup(); + if(!group) { - //recently visible to any camera? - vis = ((LLOcclusionCullingGroup*)getGroup())->isAnyRecentlyVisible(); + return false; } - //combination of projected area and squared distance - if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) + //any visible + bool vis = group->isAnyRecentlyVisible(); + + //not ready to remove + if(!vis) { - F32 rad = getBinRadius(); - vis = (rad * rad / mSceneContrib < sBackDistanceSquared); + vis = (group->getAnyVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame()); } - if(!vis) + //within the back sphere + if(!vis && !mParentID) { - vis = (getVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame()); + LLVector4a lookAt; + lookAt.setSub(getPositionGroup(), camera_origin); + F32 squared_dist = lookAt.dot3(lookAt).getF32(); + F32 rad = getBinRadius(); + rad *= rad; + + //rough estimation + vis = (squared_dist - rad < squared_dist_threshold); } return vis; @@ -744,8 +752,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); - static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); - static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF"); + static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); if(!LLViewerRegion::sVOCacheCullingEnabled) { @@ -770,10 +777,8 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); //object projected area threshold - F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio(); - F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f; - projection_threshold *= projection_threshold; - + F32 projection_threshold = LLVOCacheEntry::getSquaredObjectScreenAreaThreshold(); + if(!mCullHistory && LLViewerRegion::isViewerCameraStatic()) { U32 seed = llmax(mLODPeriod >> 1, (U32)4); @@ -832,6 +837,10 @@ void LLVOCachePartition::processOccluders(LLCamera* camera) { return; } + if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) + { + return; //no need for those cameras. + } LLVector3 region_agent = mRegionp->getOriginAgent(); LLVector4a shift(region_agent[0], region_agent[1], region_agent[2]); @@ -856,7 +865,7 @@ void LLVOCachePartition::resetOccluders() for(std::set<LLVOCacheGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { LLVOCacheGroup* group = *iter; - group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS); + group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); } mOccludedGroups.clear(); sNeedsOcclusionCheck = FALSE; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index 446111620d..af97f9fdce 100755 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -85,8 +85,7 @@ public: bool hasState(U32 state) {return mState & state;} U32 getState() const {return mState;} - //virtual - bool isRecentlyVisible() const; + bool isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold); U32 getLocalID() const { return mLocalID; } U32 getCRC() const { return mCRC; } @@ -126,6 +125,7 @@ public: U32 getUpdateFlags() const {return mUpdateFlags;} static void updateDebugSettings(); + static F32 getSquaredObjectScreenAreaThreshold(); private: void updateParentBoundingInfo(const LLVOCacheEntry* child); @@ -153,9 +153,6 @@ protected: BOOL mTouched; //if set, this entry is valid, otherwise it is invalid. - static F32 sBackDistanceSquared; - static F32 sBackAngleTanSquared; - public: static U32 sMinFrameRange; }; 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); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2cf59d212b..c5148690a5 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2155,11 +2155,11 @@ void LLPipeline::updateMove() } //balance the VO Cache tree - LLVOCachePartition* vo_part = region->getVOCachePartition(); + /*LLVOCachePartition* vo_part = region->getVOCachePartition(); if(vo_part) { vo_part->mOctree->balance(); - } + }*/ } } } |