From c0ba626c8009b22310b3923e8170e5db2a021253 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 15 Oct 2012 21:34:29 -0600 Subject: For SH-3333: Design and implement a new object cache system on viewer side --- indra/newview/llvocache.cpp | 78 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 7 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 7db19c5c1b..17e0ef3bdb 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -29,6 +29,8 @@ #include "llerror.h" #include "llregionhandle.h" #include "llviewercontrol.h" +#include "llviewerobjectlist.h" +#include "lldrawable.h" BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { @@ -46,12 +48,13 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes) //--------------------------------------------------------------------------- LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp) - : + : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(local_id), mCRC(crc), mHitCount(0), mDupeCount(0), - mCRCChangeCount(0) + mCRCChangeCount(0), + mState(INACTIVE) { mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); @@ -59,19 +62,22 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & } LLVOCacheEntry::LLVOCacheEntry() - : + : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(0), mCRC(0), mHitCount(0), mDupeCount(0), mCRCChangeCount(0), - mBuffer(NULL) + mBuffer(NULL), + mState(INACTIVE) { mDP.assignBuffer(mBuffer, 0); } LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) - : mBuffer(NULL) + : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), + mBuffer(NULL), + mState(INACTIVE) { S32 size = -1; BOOL success; @@ -138,8 +144,57 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) LLVOCacheEntry::~LLVOCacheEntry() { mDP.freeBuffer(); + //llassert(mState == INACTIVE); } +//virtual +void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) +{ + if(!entry && mDP.getBufferSize() > 0) + { + LLUUID fullid; + mDP.reset(); + mDP.unpackUUID(fullid, "ID"); + mDP.reset(); + + LLViewerObject* obj = gObjectList.findObject(fullid); + if(obj && obj->mDrawable) + { + entry = obj->mDrawable->getEntry(); + } + } + + LLViewerOctreeEntryData::setOctreeEntry(entry); +} + +//virtual +S32 LLVOCacheEntry::getMinVisFrameRange()const +{ + const S32 MIN_RANGE = 128; //frames + + return MIN_RANGE; +} + +void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) +{ + llassert(entry != NULL); + + mChildrenList.push_back(entry); +} + +LLVOCacheEntry* LLVOCacheEntry::getNextChild() +{ + S32 size = mChildrenList.size(); + if(!size) + { + return NULL; + } + + LLVOCacheEntry* entry = mChildrenList[size - 1]; + mChildrenList.pop_back(); //remove the entry; + + return entry; +} // New CRC means the object has changed. void LLVOCacheEntry::assignCRC(U32 crc, LLDataPackerBinaryBuffer &dp) @@ -170,6 +225,16 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc) return &mDP; } +LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP() +{ + if (mDP.getBufferSize() == 0) + { + //llinfos << "Not getting cache entry, invalid!" << llendl; + return NULL; + } + + return &mDP; +} void LLVOCacheEntry::recordHit() { @@ -625,11 +690,10 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca { for (S32 i = 0; i < num_entries; i++) { - LLVOCacheEntry* entry = new LLVOCacheEntry(&apr_file); + LLPointer entry = new LLVOCacheEntry(&apr_file); if (!entry->getLocalID()) { llwarns << "Aborting cache file load for " << filename << ", cache file corruption!" << llendl; - delete entry ; success = false ; break ; } -- cgit v1.2.3 From 9bc8028ab52ef5d56fa8a3915d927b5a050d8ead Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 16 Oct 2012 11:40:02 -0600 Subject: Some minor performance tuning-up for SH-3333. --- indra/newview/llvocache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 17e0ef3bdb..236ce11c7e 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -170,7 +170,7 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) //virtual S32 LLVOCacheEntry::getMinVisFrameRange()const { - const S32 MIN_RANGE = 128; //frames + const S32 MIN_RANGE = 64; //frames return MIN_RANGE; } -- cgit v1.2.3 From 87097e546fa9e160264400f6d9d79d536abbb2fa Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 25 Oct 2012 17:00:34 -0600 Subject: more for SH-3333: avoid repeatedly creating/killing a same object from object cache due to occlusion culling. --- indra/newview/llvocache.cpp | 47 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 236ce11c7e..fbab5c60e3 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -54,7 +54,9 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mHitCount(0), mDupeCount(0), mCRCChangeCount(0), - mState(INACTIVE) + mState(INACTIVE), + mRepeatedVisCounter(0), + mVisFrameRange(64) { mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); @@ -69,7 +71,9 @@ LLVOCacheEntry::LLVOCacheEntry() mDupeCount(0), mCRCChangeCount(0), mBuffer(NULL), - mState(INACTIVE) + mState(INACTIVE), + mRepeatedVisCounter(0), + mVisFrameRange(64) { mDP.assignBuffer(mBuffer, 0); } @@ -77,7 +81,9 @@ LLVOCacheEntry::LLVOCacheEntry() LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mBuffer(NULL), - mState(INACTIVE) + mState(INACTIVE), + mRepeatedVisCounter(0), + mVisFrameRange(64) { S32 size = -1; BOOL success; @@ -167,12 +173,41 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) LLViewerOctreeEntryData::setOctreeEntry(entry); } +void LLVOCacheEntry::setState(U32 state) +{ + mState = state; + + if(mState == ACTIVE) + { + const S32 MIN_REAVTIVE_INTERVAL = 20; + U32 last_visible = getVisible(); + + setVisible(); + + if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mVisFrameRange) + { + mRepeatedVisCounter++; + } + else + { + mRepeatedVisCounter = 0; + mVisFrameRange = 64; + } + + if(mRepeatedVisCounter > 2) + { + //if repeatedly becomes visible immediately after invisible, enlarge the visible frame range + + mRepeatedVisCounter = 0; + mVisFrameRange *= 2; + } + } +} + //virtual S32 LLVOCacheEntry::getMinVisFrameRange()const { - const S32 MIN_RANGE = 64; //frames - - return MIN_RANGE; + return mVisFrameRange; } void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) -- cgit v1.2.3 From e35a220bf7dd47132174c81181d5f59fb0d54c5d Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 29 Oct 2012 17:13:15 -0600 Subject: for SH-3459: interesting store object bounding information in viewer cache --- indra/newview/llvocache.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index fbab5c60e3..f389867484 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -89,6 +89,8 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) BOOL success; mDP.assignBuffer(mBuffer, 0); + setOctreeEntry(NULL); + success = check_read(apr_file, &mLocalID, sizeof(U32)); if(success) { @@ -107,6 +109,21 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) success = check_read(apr_file, &mCRCChangeCount, sizeof(S32)); } if(success) + { + LLVector4 pos; + success = check_read(apr_file, (void*)pos.mV, sizeof(LLVector4)); + + LLVector4a pos_; + pos_.load4a(pos.mV); + setPositionGroup(pos_); + } + if(success) + { + F32 rad; + success = check_read(apr_file, &rad, sizeof(F32)); + setBinRadius(rad); + } + if(success) { success = check_read(apr_file, &size, sizeof(S32)); @@ -144,6 +161,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mDupeCount = 0; mCRCChangeCount = 0; mBuffer = NULL; + mEntry = NULL; } } @@ -289,6 +307,11 @@ void LLVOCacheEntry::dump() const BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const { + if(!mEntry) + { + return FALSE; + } + BOOL success; success = check_write(apr_file, (void*)&mLocalID, sizeof(U32)); if(success) @@ -308,6 +331,17 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const success = check_write(apr_file, (void*)&mCRCChangeCount, sizeof(S32)); } if(success) + { + const LLVector4a pos_ = getPositionGroup() ; + LLVector4 pos(pos_[0], pos_[1], pos_[2], pos_[3]); + success = check_write(apr_file, pos.mV, sizeof(LLVector4)); + } + if(success) + { + F32 rad = getBinRadius(); + success = check_write(apr_file, (void*)&rad, sizeof(F32)); + } + if(success) { S32 size = mDP.getBufferSize(); success = check_write(apr_file, (void*)&size, sizeof(S32)); -- cgit v1.2.3 From 5ae116f89b8459963ccb6ae9125d94ffaa79025e Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 31 Oct 2012 17:05:53 -0600 Subject: for SH-3471: create a simplified version of octree for object cache entries. --- indra/newview/llvocache.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index f389867484..d4938fd216 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -31,6 +31,7 @@ #include "llviewercontrol.h" #include "llviewerobjectlist.h" #include "lldrawable.h" +#include "llviewerregion.h" BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { @@ -355,6 +356,82 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const return success ; } +//------------------------------------------------------------------- +//LLVOCachePartition +//------------------------------------------------------------------- +LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) +{ + mRegionp = regionp; + mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; + mVisitedTime = 0; + + new LLviewerOctreeGroup(mOctree); +} + +void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) +{ + llassert(entry->hasVOCacheEntry()); + + mOctree->insert(entry); +} + +void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) +{ + entry->getVOCacheEntry()->setGroup(NULL); + + llassert(!entry->getGroup()); +} + +class LLVOCacheOctreeCull : public LLViewerOctreeCull +{ +public: + LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp) : LLViewerOctreeCull(camera), mRegionp(regionp) {} + + virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + { + S32 res = AABBInFrustumNoFarClipGroupBounds(group); + if (res != 0) + { + res = llmin(res, AABBSphereIntersectGroupExtents(group)); + } + return res; + } + + virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + { + S32 res = AABBInFrustumNoFarClipObjectBounds(group); + if (res != 0) + { + res = llmin(res, AABBSphereIntersectObjectExtents(group)); + } + return res; + } + + virtual void processGroup(LLviewerOctreeGroup* base_group) + { + mRegionp->addVisibleGroup(base_group); + } + +private: + LLViewerRegion* mRegionp; +}; + +S32 LLVOCachePartition::cull(LLCamera &camera) +{ + if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame()) + { + return 0; //already visited. + } + mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame(); + + ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); + + LLVOCacheOctreeCull culler(&camera, mRegionp); + culler.traverse(mOctree); + + return 0; +} + //------------------------------------------------------------------- //LLVOCache //------------------------------------------------------------------- -- cgit v1.2.3 From 8e6341b9194b1fb27d92d8f5e6739390ac882941 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 1 Nov 2012 17:05:26 -0600 Subject: more for SH-3459: interesting store object bounding information in viewer cache --- indra/newview/llvocache.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index d4938fd216..db6aa9cd00 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -110,6 +110,17 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) success = check_read(apr_file, &mCRCChangeCount, sizeof(S32)); } if(success) + { + F32 ext[8]; + success = check_read(apr_file, (void*)ext, sizeof(F32) * 8); + + LLVector4a exts[2]; + exts[0].load4a(ext); + exts[1].load4a(&ext[4]); + + setSpatialExtents(exts[0], exts[1]); + } + if(success) { LLVector4 pos; success = check_read(apr_file, (void*)pos.mV, sizeof(LLVector4)); @@ -332,6 +343,17 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const success = check_write(apr_file, (void*)&mCRCChangeCount, sizeof(S32)); } if(success) + { + const LLVector4a* exts = getSpatialExtents() ; + LLVector4 ext(exts[0][0], exts[0][1], exts[0][2], exts[0][3]); + success = check_write(apr_file, ext.mV, sizeof(LLVector4)); + if(success) + { + ext.set(exts[1][0], exts[1][1], exts[1][2], exts[1][3]); + success = check_write(apr_file, ext.mV, sizeof(LLVector4)); + } + } + if(success) { const LLVector4a pos_ = getPositionGroup() ; LLVector4 pos(pos_[0], pos_[1], pos_[2], pos_[3]); -- cgit v1.2.3 From c2859e4663c405950b6f433270ae558852330c76 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 8 Nov 2012 21:36:47 -0700 Subject: for SH-3472: prioritize object loading --- indra/newview/llvocache.cpp | 136 ++++++++++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 36 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index db6aa9cd00..ec8585852b 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -32,6 +32,7 @@ #include "llviewerobjectlist.h" #include "lldrawable.h" #include "llviewerregion.h" +#include "pipeline.h" BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { @@ -57,11 +58,24 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mCRCChangeCount(0), mState(INACTIVE), mRepeatedVisCounter(0), - mVisFrameRange(64) + mVisFrameRange(64), + mSceneContrib(0.f) { mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); mDP = dp; + + if(dp.getBufferSize() > 0) + { + U32 parent_id = 0; + dp.reset(); + dp.unpackU32(parent_id, "ParentID"); + dp.reset(); + if(parent_id > 0) + { + mState |= CHILD; //is a child + } + } } LLVOCacheEntry::LLVOCacheEntry() @@ -74,7 +88,8 @@ LLVOCacheEntry::LLVOCacheEntry() mBuffer(NULL), mState(INACTIVE), mRepeatedVisCounter(0), - mVisFrameRange(64) + mVisFrameRange(64), + mSceneContrib(0.f) { mDP.assignBuffer(mBuffer, 0); } @@ -84,7 +99,8 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mBuffer(NULL), mState(INACTIVE), mRepeatedVisCounter(0), - mVisFrameRange(64) + mVisFrameRange(64), + mSceneContrib(0.f) { S32 size = -1; BOOL success; @@ -110,6 +126,10 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) success = check_read(apr_file, &mCRCChangeCount, sizeof(S32)); } if(success) + { + success = check_read(apr_file, &mState, sizeof(U32)); + } + if(success) { F32 ext[8]; success = check_read(apr_file, (void*)ext, sizeof(F32) * 8); @@ -174,6 +194,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mCRCChangeCount = 0; mBuffer = NULL; mEntry = NULL; + mState = 0; } } @@ -203,11 +224,40 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) LLViewerOctreeEntryData::setOctreeEntry(entry); } +void LLVOCacheEntry::setBridgeChild() +{ + mState |= BRIDGE_CHILD; +} + +void LLVOCacheEntry::clearBridgeChild() +{ + mState &= ~BRIDGE_CHILD; +} + +void LLVOCacheEntry::copy(LLVOCacheEntry* entry) +{ + //copy LLViewerOctreeEntry + LLViewerOctreeEntry* oct_entry = entry->getEntry(); + if(!oct_entry) + { + setOctreeEntry(oct_entry); + } + + //copy children + S32 num_children = entry->getNumOfChildren(); + for(S32 i = 0; i < num_children; i++) + { + addChild(entry->getChild(i)); + } +} + void LLVOCacheEntry::setState(U32 state) { - mState = state; + mState &= 0xffff0000; //clear the low 16 bits + state &= 0x0000ffff; //clear the high 16 bits; + mState |= state; - if(mState == ACTIVE) + if(getState() == ACTIVE) { const S32 MIN_REAVTIVE_INTERVAL = 20; U32 last_visible = getVisible(); @@ -247,37 +297,6 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) mChildrenList.push_back(entry); } -LLVOCacheEntry* LLVOCacheEntry::getNextChild() -{ - S32 size = mChildrenList.size(); - if(!size) - { - return NULL; - } - - LLVOCacheEntry* entry = mChildrenList[size - 1]; - mChildrenList.pop_back(); //remove the entry; - - return entry; -} - -// New CRC means the object has changed. -void LLVOCacheEntry::assignCRC(U32 crc, LLDataPackerBinaryBuffer &dp) -{ - if ( (mCRC != crc) - ||(mDP.getBufferSize() == 0)) - { - mCRC = crc; - mHitCount = 0; - mCRCChangeCount++; - - mDP.freeBuffer(); - mBuffer = new U8[dp.getBufferSize()]; - mDP.assignBuffer(mBuffer, dp.getBufferSize()); - mDP = dp; - } -} - LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc) { if ( (mCRC != crc) @@ -343,6 +362,11 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const success = check_write(apr_file, (void*)&mCRCChangeCount, sizeof(S32)); } if(success) + { + U32 state = mState & 0xffff0000; //only store the high 16 bits. + success = check_write(apr_file, (void*)&state, sizeof(U32)); + } + if(success) { const LLVector4a* exts = getSpatialExtents() ; LLVector4 ext(exts[0][0], exts[0][1], exts[0][2], exts[0][3]); @@ -378,6 +402,46 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const return success ; } +void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update) +{ + if(!needs_update && getVisible() >= last_update) + { + return; //no need to update + } + + const LLVector4a& center = getPositionGroup(); + + LLVector4a origin; + origin.load3(camera_origin.mV); + + LLVector4a lookAt; + lookAt.setSub(center, origin); + F32 squared_dist = lookAt.dot3(lookAt).getF32(); + + F32 rad = getBinRadius(); + mSceneContrib = rad * rad / squared_dist; + + setVisible(); +} + +U32 LLVOCacheEntry::getParentID() +{ + if(!(mState & CHILD)) + { + return 0; //not a child + } + + U32 parent_id = 0; + LLDataPackerBinaryBuffer* dp = getDP(); + if(dp) + { + dp->reset(); + dp->unpackU32(parent_id, "ParentID"); + dp->reset(); + } + return parent_id; +} + //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- -- cgit v1.2.3 From 551411247b8e4701e4768f61717b644750af83a7 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 20 Nov 2012 21:37:04 -0700 Subject: fix a crash caused by object cache for SH-3333. --- indra/newview/llvocache.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ec8585852b..8ea79dbae6 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -234,20 +234,20 @@ void LLVOCacheEntry::clearBridgeChild() mState &= ~BRIDGE_CHILD; } -void LLVOCacheEntry::copy(LLVOCacheEntry* entry) +void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry) { //copy LLViewerOctreeEntry - LLViewerOctreeEntry* oct_entry = entry->getEntry(); - if(!oct_entry) + if(mEntry.notNull()) { - setOctreeEntry(oct_entry); + new_entry->setOctreeEntry(mEntry); + mEntry = NULL; } //copy children - S32 num_children = entry->getNumOfChildren(); + S32 num_children = getNumOfChildren(); for(S32 i = 0; i < num_children; i++) { - addChild(entry->getChild(i)); + new_entry->addChild(getChild(i)); } } -- cgit v1.2.3 From e1247d631f24065a31d9668915cb8bc84f3abc7f Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 18 Dec 2012 14:36:46 -0700 Subject: fix for SH-3619: some objects are missing --- indra/newview/llvocache.cpp | 49 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 8ea79dbae6..59645fdbe9 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -424,24 +424,6 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool setVisible(); } -U32 LLVOCacheEntry::getParentID() -{ - if(!(mState & CHILD)) - { - return 0; //not a child - } - - U32 parent_id = 0; - LLDataPackerBinaryBuffer* dp = getDP(); - if(dp) - { - dp->reset(); - dp->unpackU32(parent_id, "ParentID"); - dp->reset(); - } - return parent_id; -} - //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- @@ -471,24 +453,31 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) class LLVOCacheOctreeCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp) : LLViewerOctreeCull(camera), mRegionp(regionp) {} + LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift) : LLViewerOctreeCull(camera), mRegionp(regionp) + { + mLocalShift = shift; + } virtual S32 frustumCheck(const LLviewerOctreeGroup* group) { - S32 res = AABBInFrustumNoFarClipGroupBounds(group); + //S32 res = AABBInRegionFrustumGroupBounds(group); + + S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); if (res != 0) { - res = llmin(res, AABBSphereIntersectGroupExtents(group)); + res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift)); } return res; } virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) { - S32 res = AABBInFrustumNoFarClipObjectBounds(group); + //S32 res = AABBInRegionFrustumObjectBounds(group); + + S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); if (res != 0) { - res = llmin(res, AABBSphereIntersectObjectExtents(group)); + res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift)); } return res; } @@ -500,10 +489,16 @@ public: private: LLViewerRegion* mRegionp; + LLVector3 mLocalShift; //shift vector from agent space to local region space. }; S32 LLVOCachePartition::cull(LLCamera &camera) { + if(!LLViewerRegion::sVOCacheCullingEnabled) + { + return 0; + } + if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame()) { return 0; //already visited. @@ -511,8 +506,12 @@ S32 LLVOCachePartition::cull(LLCamera &camera) mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame(); ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); - - LLVOCacheOctreeCull culler(&camera, mRegionp); + + //localize the camera + LLVector3 region_agent = mRegionp->getOriginAgent(); + camera.calcRegionFrustumPlanes(region_agent); + + LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent); culler.traverse(mOctree); return 0; -- cgit v1.2.3 From 4e22f3e3ef15e24d7e9e0ad156e60d4cd1b2d5c9 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 18 Dec 2012 23:16:50 -0700 Subject: fix for SH-3624: Object deletion does not work --- indra/newview/llvocache.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 59645fdbe9..86cfbb1d74 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -64,18 +64,6 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); mDP = dp; - - if(dp.getBufferSize() > 0) - { - U32 parent_id = 0; - dp.reset(); - dp.unpackU32(parent_id, "ParentID"); - dp.reset(); - if(parent_id > 0) - { - mState |= CHILD; //is a child - } - } } LLVOCacheEntry::LLVOCacheEntry() @@ -224,16 +212,6 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) LLViewerOctreeEntryData::setOctreeEntry(entry); } -void LLVOCacheEntry::setBridgeChild() -{ - mState |= BRIDGE_CHILD; -} - -void LLVOCacheEntry::clearBridgeChild() -{ - mState &= ~BRIDGE_CHILD; -} - void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry) { //copy LLViewerOctreeEntry -- cgit v1.2.3 From bd60fdbe44d9f996686d31cf48a3f2ca664dd301 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 28 Feb 2013 22:49:05 -0700 Subject: for SH-3824: interesting: Ensure viewer can handle object updates from entire region gracefully --- indra/newview/llvocache.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 86cfbb1d74..26c3e04b92 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -198,10 +198,8 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) if(!entry && mDP.getBufferSize() > 0) { LLUUID fullid; - mDP.reset(); - mDP.unpackUUID(fullid, "ID"); - mDP.reset(); - + LLViewerObject::unpackUUID(&mDP, fullid, "ID"); + LLViewerObject* obj = gObjectList.findObject(fullid); if(obj && obj->mDrawable) { @@ -402,6 +400,28 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool setVisible(); } +void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scale) +{ + LLVector4a center, newMin, newMax; + center.load3(pos.mV); + LLVector4a size; + size.load3(scale.mV); + newMin.setSub(center, size); + newMax.setAdd(center, size); + + setPositionGroup(center); + setSpatialExtents(newMin, newMax); + setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f)); +} + +void LLVOCacheEntry::updateBoundingInfo(LLVOCacheEntry* parent) +{ + //LLVector4a old_pos = getPositionGroup(); + //parent->getPositionRegion() + (getPosition() * parent->getRotation()); + + shift(parent->getPositionGroup()); +} + //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- -- cgit v1.2.3 From 50b32cf2bdb93fad14770aa0f6b92fb3815ebdf0 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 7 Mar 2013 23:54:11 -0700 Subject: for SH-3937: interesting: implement the new cache probe logic --- indra/newview/llvocache.cpp | 81 +++++++++------------------------------------ 1 file changed, 16 insertions(+), 65 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 26c3e04b92..a9e0dd39d5 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -59,7 +59,9 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mState(INACTIVE), mRepeatedVisCounter(0), mVisFrameRange(64), - mSceneContrib(0.f) + mSceneContrib(0.f), + mTouched(TRUE), + mParentID(0) { mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); @@ -77,7 +79,9 @@ LLVOCacheEntry::LLVOCacheEntry() mState(INACTIVE), mRepeatedVisCounter(0), mVisFrameRange(64), - mSceneContrib(0.f) + mSceneContrib(0.f), + mTouched(TRUE), + mParentID(0) { mDP.assignBuffer(mBuffer, 0); } @@ -88,7 +92,9 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mState(INACTIVE), mRepeatedVisCounter(0), mVisFrameRange(64), - mSceneContrib(0.f) + mSceneContrib(0.f), + mTouched(FALSE), + mParentID(0) { S32 size = -1; BOOL success; @@ -114,36 +120,6 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) success = check_read(apr_file, &mCRCChangeCount, sizeof(S32)); } if(success) - { - success = check_read(apr_file, &mState, sizeof(U32)); - } - if(success) - { - F32 ext[8]; - success = check_read(apr_file, (void*)ext, sizeof(F32) * 8); - - LLVector4a exts[2]; - exts[0].load4a(ext); - exts[1].load4a(&ext[4]); - - setSpatialExtents(exts[0], exts[1]); - } - if(success) - { - LLVector4 pos; - success = check_read(apr_file, (void*)pos.mV, sizeof(LLVector4)); - - LLVector4a pos_; - pos_.load4a(pos.mV); - setPositionGroup(pos_); - } - if(success) - { - F32 rad; - success = check_read(apr_file, &rad, sizeof(F32)); - setBinRadius(rad); - } - if(success) { success = check_read(apr_file, &size, sizeof(S32)); @@ -229,9 +205,7 @@ void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry) void LLVOCacheEntry::setState(U32 state) { - mState &= 0xffff0000; //clear the low 16 bits - state &= 0x0000ffff; //clear the high 16 bits; - mState |= state; + mState = state; if(getState() == ACTIVE) { @@ -298,6 +272,7 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP() void LLVOCacheEntry::recordHit() { + setTouched(); mHitCount++; } @@ -338,33 +313,6 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const success = check_write(apr_file, (void*)&mCRCChangeCount, sizeof(S32)); } if(success) - { - U32 state = mState & 0xffff0000; //only store the high 16 bits. - success = check_write(apr_file, (void*)&state, sizeof(U32)); - } - if(success) - { - const LLVector4a* exts = getSpatialExtents() ; - LLVector4 ext(exts[0][0], exts[0][1], exts[0][2], exts[0][3]); - success = check_write(apr_file, ext.mV, sizeof(LLVector4)); - if(success) - { - ext.set(exts[1][0], exts[1][1], exts[1][2], exts[1][3]); - success = check_write(apr_file, ext.mV, sizeof(LLVector4)); - } - } - if(success) - { - const LLVector4a pos_ = getPositionGroup() ; - LLVector4 pos(pos_[0], pos_[1], pos_[2], pos_[3]); - success = check_write(apr_file, pos.mV, sizeof(LLVector4)); - } - if(success) - { - F32 rad = getBinRadius(); - success = check_write(apr_file, (void*)&rad, sizeof(F32)); - } - if(success) { S32 size = mDP.getBufferSize(); success = check_write(apr_file, (void*)&size, sizeof(S32)); @@ -958,7 +906,7 @@ void LLVOCache::purgeEntries(U32 size) mNumEntries = mHandleEntryMap.size() ; } -void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) +void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, BOOL full_region_cache_probe) { if(!mEnabled) { @@ -1031,7 +979,10 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); success && iter != cache_entry_map.end(); ++iter) { - success = iter->second->writeToFile(&apr_file) ; + if(!full_region_cache_probe || iter->second->isTouched()) + { + success = iter->second->writeToFile(&apr_file) ; + } } } } -- cgit v1.2.3 From 79dc4a1190a2954a7f1338596aa2d63ea3a96fff Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 11 Mar 2013 11:34:22 -0600 Subject: for SH-3976: interesting: make new object cache be able to handle shadows. --- indra/newview/llvocache.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index a9e0dd39d5..ac97f1b6ce 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -377,8 +377,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) { mRegionp = regionp; mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; - mVisitedTime = 0; - + new LLviewerOctreeGroup(mOctree); } @@ -445,12 +444,6 @@ S32 LLVOCachePartition::cull(LLCamera &camera) return 0; } - if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame()) - { - return 0; //already visited. - } - mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame(); - ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); //localize the camera -- cgit v1.2.3 From 27bb36b1e796add58f319555bf761e417f7957ef Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 11 Mar 2013 21:23:15 -0600 Subject: for SH-3979: interesting: can not edit objects with new object cache code --- indra/newview/llvocache.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ac97f1b6ce..5f112675dc 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -53,6 +53,7 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(local_id), mCRC(crc), + mUpdateFlags(-1), mHitCount(0), mDupeCount(0), mCRCChangeCount(0), @@ -72,6 +73,7 @@ LLVOCacheEntry::LLVOCacheEntry() : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(0), mCRC(0), + mUpdateFlags(-1), mHitCount(0), mDupeCount(0), mCRCChangeCount(0), @@ -89,6 +91,7 @@ LLVOCacheEntry::LLVOCacheEntry() LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mBuffer(NULL), + mUpdateFlags(-1), mState(INACTIVE), mRepeatedVisCounter(0), mVisFrameRange(64), -- cgit v1.2.3 From 933691ad133b552be3fdd26b0d9d26a09c3a7aa5 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 20 Mar 2013 16:29:48 -0600 Subject: for SH-4004: interesting: need debug option to clear viewer cache while still logged in --- indra/newview/llvocache.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 5f112675dc..a08e01784c 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -563,13 +563,19 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) } } -void LLVOCache::removeCache(ELLPath location) +void LLVOCache::removeCache(ELLPath location, bool started) { + if(started) + { + removeCache(); + return; + } + if(mReadOnly) { llwarns << "Not removing cache at " << location << ": Cache is currently in read-only mode." << llendl; return ; - } + } llinfos << "about to remove the object cache due to settings." << llendl ; @@ -592,10 +598,8 @@ void LLVOCache::removeCache() return ; } - llinfos << "about to remove the object cache due to some error." << llendl ; - std::string mask = "*"; - llinfos << "Removing cache at " << mObjectCacheDirName << llendl; + llinfos << "Removing object cache at " << mObjectCacheDirName << llendl; gDirUtilp->deleteFilesInDir(mObjectCacheDirName, mask); clearCacheInMemory() ; -- cgit v1.2.3 From 51e5997bd6f7f7d66a5843cf1d0b749b143460a8 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 29 Mar 2013 17:54:04 -0600 Subject: delay removing invalid objects from cache in case region is logged out too soon. --- indra/newview/llvocache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index a08e01784c..caa87eb1eb 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -906,7 +906,7 @@ void LLVOCache::purgeEntries(U32 size) mNumEntries = mHandleEntryMap.size() ; } -void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, BOOL full_region_cache_probe) +void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, bool removal_enabled) { if(!mEnabled) { @@ -979,7 +979,7 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); success && iter != cache_entry_map.end(); ++iter) { - if(!full_region_cache_probe || iter->second->isTouched()) + if(!removal_enabled || iter->second->isTouched()) { success = iter->second->writeToFile(&apr_file) ; } -- cgit v1.2.3 From c05fa390dc57b072da4b69b4e08743fd62bf4ce5 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 11 Apr 2013 15:25:35 -0600 Subject: add LLTrace::MemTrackable to LLVOCachePartition --- indra/newview/llvocache.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index caa87eb1eb..1dd149631a 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -34,6 +34,8 @@ #include "llviewerregion.h" #include "pipeline.h" +LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); + BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { return apr_file->read(src, n_bytes) == n_bytes ; -- cgit v1.2.3 From 4687803c8e5371cab2bdf2636397b9043edf0299 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 12 Apr 2013 16:10:21 -0600 Subject: fix the crash for SH-4004: interesting: need debug option to clear viewer cache while still logged in --- indra/newview/llvocache.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 1dd149631a..f90bddcba9 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -593,7 +593,12 @@ void LLVOCache::removeCache(ELLPath location, bool started) void LLVOCache::removeCache() { - llassert_always(mInitialized) ; + if(!mInitialized) + { + //OK to remove cache even it is not initialized. + llwarns << "Object cache is not initialized yet." << llendl; + } + if(mReadOnly) { llwarns << "Not clearing object cache: Cache is currently in read-only mode." << llendl; -- cgit v1.2.3 From 674df12bc9e81b9b4290f74a96116dbbf1e7f77c Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 17 Apr 2013 23:00:36 -0600 Subject: for SH-4105: interesting: new viewer does not handle orphaned child prims in ObjectUpdateCompressed messages --- indra/newview/llvocache.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index f90bddcba9..eba768fef4 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -367,14 +367,6 @@ void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scal setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f)); } -void LLVOCacheEntry::updateBoundingInfo(LLVOCacheEntry* parent) -{ - //LLVector4a old_pos = getPositionGroup(); - //parent->getPositionRegion() + (getPosition() * parent->getRotation()); - - shift(parent->getPositionGroup()); -} - //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- -- cgit v1.2.3 From 6b81b8629e67d82a7620e48781ded73b6e6126ea Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 5 May 2013 17:45:35 -0700 Subject: Spring cleaning: removed unused .cpp and.h files, and cleaned up header dependencies --- indra/newview/llvocache.cpp | 56 ++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index eba768fef4..b67a6bbacd 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -170,7 +170,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) LLVOCacheEntry::~LLVOCacheEntry() { mDP.freeBuffer(); - //llassert(mState == INACTIVE); + llassert(mState == INACTIVE); } //virtual @@ -191,7 +191,7 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) LLViewerOctreeEntryData::setOctreeEntry(entry); } -void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry) +void LLVOCacheEntry::moveTo(LLVOCacheEntry* new_entry) { //copy LLViewerOctreeEntry if(mEntry.notNull()) @@ -206,6 +206,7 @@ void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry) { new_entry->addChild(getChild(i)); } + mChildrenList.clear(); } void LLVOCacheEntry::setState(U32 state) @@ -465,37 +466,10 @@ const U32 INVALID_TIME = 0 ; const char* object_cache_dirname = "objectcache"; const char* header_filename = "object.cache"; -LLVOCache* LLVOCache::sInstance = NULL; - -//static -LLVOCache* LLVOCache::getInstance() -{ - if(!sInstance) - { - sInstance = new LLVOCache() ; - } - return sInstance ; -} - -//static -BOOL LLVOCache::hasInstance() -{ - return sInstance != NULL ; -} - -//static -void LLVOCache::destroyClass() -{ - if(sInstance) - { - delete sInstance ; - sInstance = NULL ; - } -} LLVOCache::LLVOCache(): - mInitialized(FALSE), - mReadOnly(TRUE), + mInitialized(false), + mReadOnly(true), mNumEntries(0), mCacheSize(1) { @@ -532,7 +506,7 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) llwarns << "Cache already initialized." << llendl; return ; } - mInitialized = TRUE ; + mInitialized = true; setDirNames(location); if (!mReadOnly) @@ -580,7 +554,7 @@ void LLVOCache::removeCache(ELLPath location, bool started) LLFile::rmdir(cache_dir); clearCacheInMemory(); - mInitialized = FALSE ; + mInitialized = false; } void LLVOCache::removeCache() @@ -607,23 +581,23 @@ void LLVOCache::removeCache() void LLVOCache::removeEntry(HeaderEntryInfo* entry) { - llassert_always(mInitialized) ; + llassert_always(mInitialized); if(mReadOnly) { - return ; + return; } if(!entry) { - return ; + return; } - header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry) ; + header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry); if(iter != mHeaderEntryQueue.end()) { - mHandleEntryMap.erase(entry->mHandle) ; - mHeaderEntryQueue.erase(iter) ; - removeFromCache(entry) ; - delete entry ; + mHandleEntryMap.erase(entry->mHandle); + mHeaderEntryQueue.erase(iter); + removeFromCache(entry); + delete entry; mNumEntries = mHandleEntryMap.size() ; } -- cgit v1.2.3 From 16616ae48d86da75b3809fa6be6c846a9d420603 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 23 May 2013 18:25:21 -0600 Subject: for SH-4145: Interesting: Implement occlusion culling for object cache --- indra/newview/llvocache.cpp | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index eba768fef4..6261540765 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -372,10 +372,11 @@ void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scal //------------------------------------------------------------------- LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) { + mLODPeriod = 16; mRegionp = regionp; mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; - new LLviewerOctreeGroup(mOctree); + new LLOcclusionCullingGroup(mOctree, this); } void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) @@ -400,11 +401,31 @@ public: mLocalShift = shift; } + virtual bool earlyFail(LLviewerOctreeGroup* base_group) + { + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; + if(group->needsUpdate()) + { + return false; //needs to issue new occlusion culling check. + } + + group->checkOcclusion(); + + if (group->getOctreeNode()->getParent() && //never occlusion cull the root node + LLPipeline::sUseOcclusion && //ignore occlusion if disabled + group->isOcclusionState(LLSpatialGroup::OCCLUDED)) + { + return true; + } + + return false; + } + virtual S32 frustumCheck(const LLviewerOctreeGroup* group) { - //S32 res = AABBInRegionFrustumGroupBounds(group); + S32 res = AABBInRegionFrustumGroupBounds(group); - S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); + //S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); if (res != 0) { res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift)); @@ -414,9 +435,9 @@ public: virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) { - //S32 res = AABBInRegionFrustumObjectBounds(group); + S32 res = AABBInRegionFrustumObjectBounds(group); - S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); + //S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); if (res != 0) { res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift)); @@ -426,7 +447,15 @@ public: virtual void processGroup(LLviewerOctreeGroup* base_group) { - mRegionp->addVisibleGroup(base_group); + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; + if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1) + { + ((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera); + group->setVisible(); + return; //wait for occlusion culling results + } + + mRegionp->addVisibleGroup(group); } private: -- cgit v1.2.3 From b5f98560c796d62e45ebd0e410254b79958c7f47 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 23 May 2013 23:21:41 -0600 Subject: add a debug setting "UseObjectCacheOcclusion" to enable/disable object cache occlusion culling --- indra/newview/llvocache.cpp | 50 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 1a6ad90a78..fdb14aa8d2 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -397,28 +397,33 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) class LLVOCacheOctreeCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift) : LLViewerOctreeCull(camera), mRegionp(regionp) + LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion) + : LLViewerOctreeCull(camera), + mRegionp(regionp) { mLocalShift = shift; + mUseObjectCacheOcclusion = (use_object_cache_occlusion && LLPipeline::sUseOcclusion); } virtual bool earlyFail(LLviewerOctreeGroup* base_group) { - LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; - if(group->needsUpdate()) + if( mUseObjectCacheOcclusion && + base_group->getOctreeNode()->getParent()) //never occlusion cull the root node { - return false; //needs to issue new occlusion culling check. - } + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; + if(group->needsUpdate()) + { + return false; //needs to issue new occlusion culling check. + } - group->checkOcclusion(); + group->checkOcclusion(); - if (group->getOctreeNode()->getParent() && //never occlusion cull the root node - LLPipeline::sUseOcclusion && //ignore occlusion if disabled - group->isOcclusionState(LLSpatialGroup::OCCLUDED)) - { - return true; + if (group->isOcclusionState(LLSpatialGroup::OCCLUDED)) + { + return true; + } } - + return false; } @@ -448,24 +453,29 @@ public: virtual void processGroup(LLviewerOctreeGroup* base_group) { - LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; - if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1) + if(mUseObjectCacheOcclusion && base_group->getOctreeNode()->getParent()) { - ((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera); - group->setVisible(); - return; //wait for occlusion culling results + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; + if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1) + { + ((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera); + group->setVisible(); + return; //wait for occlusion culling results + } } - - mRegionp->addVisibleGroup(group); + mRegionp->addVisibleGroup(base_group); } private: LLViewerRegion* mRegionp; LLVector3 mLocalShift; //shift vector from agent space to local region space. + bool mUseObjectCacheOcclusion; }; S32 LLVOCachePartition::cull(LLCamera &camera) { + static LLCachedControl use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); + if(!LLViewerRegion::sVOCacheCullingEnabled) { return 0; @@ -477,7 +487,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera) LLVector3 region_agent = mRegionp->getOriginAgent(); camera.calcRegionFrustumPlanes(region_agent); - LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent); + LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion); culler.traverse(mOctree); return 0; -- cgit v1.2.3 From 6827febd3027decb1bd8da013b6af413114239a9 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 28 May 2013 14:55:37 -0600 Subject: change the way to handle creating/destroying a same object repeatedly --- indra/newview/llvocache.cpp | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index fdb14aa8d2..bcd9dda652 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -60,8 +60,7 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mDupeCount(0), mCRCChangeCount(0), mState(INACTIVE), - mRepeatedVisCounter(0), - mVisFrameRange(64), + mMinFrameRange(64), mSceneContrib(0.f), mTouched(TRUE), mParentID(0) @@ -81,8 +80,7 @@ LLVOCacheEntry::LLVOCacheEntry() mCRCChangeCount(0), mBuffer(NULL), mState(INACTIVE), - mRepeatedVisCounter(0), - mVisFrameRange(64), + mMinFrameRange(64), mSceneContrib(0.f), mTouched(TRUE), mParentID(0) @@ -95,8 +93,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mBuffer(NULL), mUpdateFlags(-1), mState(INACTIVE), - mRepeatedVisCounter(0), - mVisFrameRange(64), + mMinFrameRange(64), mSceneContrib(0.f), mTouched(FALSE), mParentID(0) @@ -215,35 +212,26 @@ void LLVOCacheEntry::setState(U32 state) if(getState() == ACTIVE) { - const S32 MIN_REAVTIVE_INTERVAL = 20; + const S32 MIN_REAVTIVE_INTERVAL = 32; U32 last_visible = getVisible(); setVisible(); - if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mVisFrameRange) + if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mMinFrameRange) { - mRepeatedVisCounter++; + mMinFrameRange = llmin(mMinFrameRange * 2, 2048); } else { - mRepeatedVisCounter = 0; - mVisFrameRange = 64; - } - - if(mRepeatedVisCounter > 2) - { - //if repeatedly becomes visible immediately after invisible, enlarge the visible frame range - - mRepeatedVisCounter = 0; - mVisFrameRange *= 2; + mMinFrameRange = 64; //reset } } } //virtual -S32 LLVOCacheEntry::getMinVisFrameRange()const +S32 LLVOCacheEntry::getMinFrameRange()const { - return mVisFrameRange; + return mMinFrameRange; } void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) -- cgit v1.2.3 From 626d5e3b3d935e0ba616408b1736bd10f5ea9990 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 30 May 2013 16:09:36 -0600 Subject: remove a debug assertion --- indra/newview/llvocache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index bcd9dda652..5e2d2efc5e 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -167,7 +167,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) LLVOCacheEntry::~LLVOCacheEntry() { mDP.freeBuffer(); - llassert(mState == INACTIVE); + //llassert(mState == INACTIVE); } //virtual -- cgit v1.2.3 From db2abd49c3b41af612cbb6fed4c1626c37b4e14b Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 12 Jun 2013 11:30:43 -0600 Subject: fix for SH-4244: interesting: objects on adjacent region are not visible. --- indra/newview/llvocache.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 5e2d2efc5e..1f3af78e77 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -417,9 +417,11 @@ public: virtual S32 frustumCheck(const LLviewerOctreeGroup* group) { +#if 1 S32 res = AABBInRegionFrustumGroupBounds(group); - - //S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); +#else + S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); +#endif if (res != 0) { res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift)); @@ -429,9 +431,11 @@ public: virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) { +#if 1 S32 res = AABBInRegionFrustumObjectBounds(group); - - //S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); +#else + S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); +#endif if (res != 0) { res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift)); -- cgit v1.2.3 From fc88265cffe3553803314c6e895a1e3a3c988171 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 13 Jun 2013 18:47:51 -0600 Subject: fix for SH-4241: viewer crash shortly after login in LLViewerRegion::addNewObject and SH-4261: interesting: crash in LLViewerRegion::addToVOCacheTree --- indra/newview/llvocache.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 1f3af78e77..9816fb9af0 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -102,8 +102,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) BOOL success; mDP.assignBuffer(mBuffer, 0); - setOctreeEntry(NULL); - + success = check_read(apr_file, &mLocalID, sizeof(U32)); if(success) { -- cgit v1.2.3 From 1bc1d532cff1539bb5366f87b602970f1d2a8929 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 14 Jun 2013 16:20:22 -0600 Subject: fix for SH-4244: interesting: objects on adjacent region are not visible. and SH-4264: interesting: Content near edges of screen does not load --- indra/newview/llvocache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 9816fb9af0..68f21ed2b3 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -416,7 +416,7 @@ public: virtual S32 frustumCheck(const LLviewerOctreeGroup* group) { -#if 1 +#if 0 S32 res = AABBInRegionFrustumGroupBounds(group); #else S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); @@ -430,7 +430,7 @@ public: virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) { -#if 1 +#if 0 S32 res = AABBInRegionFrustumObjectBounds(group); #else S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); -- cgit v1.2.3 From 9ed2f4d3cb02d5161bd8bb77cb7befa7feedf2d9 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 17 Jun 2013 15:24:15 -0600 Subject: add a debug setting "InvisibleObjectsInMemoryTime" to adjust the time invisible objects stay in memory. --- indra/newview/llvocache.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 68f21ed2b3..93daf2e171 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -50,6 +50,14 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes) //--------------------------------------------------------------------------- // LLVOCacheEntry //--------------------------------------------------------------------------- +//return number of frames invisible objects should stay in memory +//static +U32 LLVOCacheEntry::getInvisibleObjectsLiveTime() +{ + static LLCachedControl inv_obj_time(gSavedSettings,"InvisibleObjectsInMemoryTime"); + + return inv_obj_time - 1; //make 0 to be the maximum +} LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp) : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), @@ -60,7 +68,6 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mDupeCount(0), mCRCChangeCount(0), mState(INACTIVE), - mMinFrameRange(64), mSceneContrib(0.f), mTouched(TRUE), mParentID(0) @@ -68,6 +75,7 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); mDP = dp; + mMinFrameRange = getInvisibleObjectsLiveTime(); } LLVOCacheEntry::LLVOCacheEntry() @@ -80,12 +88,12 @@ LLVOCacheEntry::LLVOCacheEntry() mCRCChangeCount(0), mBuffer(NULL), mState(INACTIVE), - mMinFrameRange(64), mSceneContrib(0.f), mTouched(TRUE), mParentID(0) { mDP.assignBuffer(mBuffer, 0); + mMinFrameRange = getInvisibleObjectsLiveTime(); } LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) @@ -93,7 +101,6 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mBuffer(NULL), mUpdateFlags(-1), mState(INACTIVE), - mMinFrameRange(64), mSceneContrib(0.f), mTouched(FALSE), mParentID(0) @@ -101,6 +108,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) S32 size = -1; BOOL success; + mMinFrameRange = getInvisibleObjectsLiveTime(); mDP.assignBuffer(mBuffer, 0); success = check_read(apr_file, &mLocalID, sizeof(U32)); @@ -218,17 +226,17 @@ void LLVOCacheEntry::setState(U32 state) if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mMinFrameRange) { - mMinFrameRange = llmin(mMinFrameRange * 2, 2048); + mMinFrameRange = llmin(mMinFrameRange * 2, getInvisibleObjectsLiveTime() * 32); } else { - mMinFrameRange = 64; //reset + mMinFrameRange = getInvisibleObjectsLiveTime(); //reset } } } //virtual -S32 LLVOCacheEntry::getMinFrameRange()const +U32 LLVOCacheEntry::getMinFrameRange()const { return mMinFrameRange; } -- cgit v1.2.3 From 92339583e6454bd6e769a6dcb0ad2eee31abfb1f Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 21 Jun 2013 13:02:20 -0600 Subject: for SH-4241: viewer crash shortly after login in LLViewerRegion::addNewObject --- indra/newview/llvocache.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 93daf2e171..216a91e1dc 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -244,6 +244,13 @@ U32 LLVOCacheEntry::getMinFrameRange()const void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) { llassert(entry != NULL); + llassert(entry->getParentID() == mLocalID); + llassert(entry->getEntry() != NULL); + + if(!entry || !entry->getEntry() || entry->getParentID() != mLocalID) + { + return; + } mChildrenList.push_back(entry); } -- cgit v1.2.3 From 916b68d1cb706b2dc469219f1976f10baadaea08 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 21 Jun 2013 14:32:26 -0600 Subject: trivial: convert to unix line endings. --- indra/newview/llvocache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 216a91e1dc..b3c7b80c29 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -244,7 +244,7 @@ U32 LLVOCacheEntry::getMinFrameRange()const void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) { llassert(entry != NULL); - llassert(entry->getParentID() == mLocalID); + llassert(entry->getParentID() == mLocalID); llassert(entry->getEntry() != NULL); if(!entry || !entry->getEntry() || entry->getParentID() != mLocalID) -- cgit v1.2.3 From d95d69cbc4063fae1d93ce2f0c4d22d3ef9c8edd Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 24 Jun 2013 11:42:32 -0600 Subject: fix for SH-4284: interesting: viewer does not render cacheable objects on far corner of region when camera moves --- indra/newview/llvocache.cpp | 51 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index b3c7b80c29..f23375adfa 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -399,9 +399,10 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) class LLVOCacheOctreeCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion) + LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) : LLViewerOctreeCull(camera), - mRegionp(regionp) + mRegionp(regionp), + mPartition(part) { mLocalShift = shift; mUseObjectCacheOcclusion = (use_object_cache_occlusion && LLPipeline::sUseOcclusion); @@ -422,6 +423,7 @@ public: if (group->isOcclusionState(LLSpatialGroup::OCCLUDED)) { + mPartition->addOccluders(group); return true; } } @@ -473,9 +475,10 @@ public: } private: - LLViewerRegion* mRegionp; - LLVector3 mLocalShift; //shift vector from agent space to local region space. - bool mUseObjectCacheOcclusion; + LLVOCachePartition* mPartition; + LLViewerRegion* mRegionp; + LLVector3 mLocalShift; //shift vector from agent space to local region space. + bool mUseObjectCacheOcclusion; }; S32 LLVOCachePartition::cull(LLCamera &camera) @@ -493,12 +496,48 @@ S32 LLVOCachePartition::cull(LLCamera &camera) LLVector3 region_agent = mRegionp->getOriginAgent(); camera.calcRegionFrustumPlanes(region_agent); - LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion); + mOccludedGroups.clear(); + + LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion, this); culler.traverse(mOctree); + if(!mOccludedGroups.empty()) + { + processOccluders(&camera); + mOccludedGroups.clear(); + } + return 0; } +void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) +{ + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp; + + const U32 MIN_WAIT_TIME = 16; //wait 16 frames to issue a new occlusion request + U32 last_issued_time = group->getLastOcclusionIssuedTime(); + if(gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME) + { + return; + } + + if(group && !group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) + { + group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + mOccludedGroups.insert(group); + } +} + +void LLVOCachePartition::processOccluders(LLCamera* camera) +{ + for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) + { + LLOcclusionCullingGroup* group = *iter; + group->doOcclusion(camera); + group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + } +} + //------------------------------------------------------------------- //LLVOCache //------------------------------------------------------------------- -- cgit v1.2.3 From c0fd2a15e49c4fc7578da4aa74c44e33cf45a3a1 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 25 Jun 2013 17:32:17 -0600 Subject: fix for SH-4284: interesting: viewer does not render cacheable objects on far corner of region when camera moves --- indra/newview/llvocache.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index f23375adfa..7eeabcba2e 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -414,9 +414,10 @@ public: base_group->getOctreeNode()->getParent()) //never occlusion cull the root node { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; - if(group->needsUpdate()) + if(group->needsUpdate())//needs to issue new occlusion culling check. { - return false; //needs to issue new occlusion culling check. + mPartition->addOccluders(group); + return true; } group->checkOcclusion(); @@ -461,16 +462,6 @@ public: virtual void processGroup(LLviewerOctreeGroup* base_group) { - if(mUseObjectCacheOcclusion && base_group->getOctreeNode()->getParent()) - { - LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; - if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1) - { - ((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera); - group->setVisible(); - return; //wait for occlusion culling results - } - } mRegionp->addVisibleGroup(base_group); } -- cgit v1.2.3 From 88fee7f87fc4a987a05002fedfcae11d6b42ba59 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 26 Jun 2013 17:08:03 -0600 Subject: more fix for SH-4284: interesting: viewer does not render cacheable objects on far corner of region when camera moves --- indra/newview/llvocache.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 7eeabcba2e..60d78890b5 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -494,7 +494,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera) if(!mOccludedGroups.empty()) { - processOccluders(&camera); + processOccluders(&camera, ®ion_agent); mOccludedGroups.clear(); } @@ -505,26 +505,26 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp; - const U32 MIN_WAIT_TIME = 16; //wait 16 frames to issue a new occlusion request + const U32 MIN_WAIT_TIME = 19; //wait 19 frames to issue a new occlusion request U32 last_issued_time = group->getLastOcclusionIssuedTime(); - if(gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME) + if(!group->needsUpdate() && gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME) { return; } - if(group && !group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) + if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) { group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); mOccludedGroups.insert(group); } } -void LLVOCachePartition::processOccluders(LLCamera* camera) +void LLVOCachePartition::processOccluders(LLCamera* camera, const LLVector3* region_agent) { for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { LLOcclusionCullingGroup* group = *iter; - group->doOcclusion(camera); + group->doOcclusion(camera, region_agent); group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); } } -- cgit v1.2.3 From e88c469de6b0e800ad9a2c11467d948ad891bdd9 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 2 Jul 2013 17:48:19 -0600 Subject: fix for SH-4264: interesting: Content near edges of screen does not load --- indra/newview/llvocache.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 60d78890b5..69c32db13e 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -253,6 +253,12 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) } mChildrenList.push_back(entry); + + //update parent bbox + if(getEntry() != NULL && isState(INACTIVE)) + { + updateParentBoundingInfo(entry); + } } LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc) @@ -367,9 +373,69 @@ void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scal setPositionGroup(center); setSpatialExtents(newMin, newMax); - setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f)); + + if(getNumOfChildren() > 0) //has children + { + updateParentBoundingInfo(); + } + else + { + setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f)); + } +} + +//make the parent bounding box to include all children +void LLVOCacheEntry::updateParentBoundingInfo() +{ + if(mChildrenList.empty()) + { + return; + } + + for(S32 i = 0; i < mChildrenList.size(); i++) + { + updateParentBoundingInfo(mChildrenList[i]); + } } +//make the parent bounding box to include this child +void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) +{ + const LLVector4a* child_exts = child->getSpatialExtents(); + LLVector4a newMin, newMax; + newMin = child_exts[0]; + newMax = child_exts[1]; + + //move to regional space. + { + const LLVector4a& parent_pos = getPositionGroup(); + newMin.add(parent_pos); + newMax.add(parent_pos); + } + + //update parent's bbox(min, max) + const LLVector4a* parent_exts = getSpatialExtents(); + update_min_max(newMin, newMax, parent_exts[0]); + update_min_max(newMin, newMax, parent_exts[1]); + for(S32 i = 0; i < 4; i++) + { + llclamp(newMin[i], 0.f, 256.f); + llclamp(newMax[i], 0.f, 256.f); + } + setSpatialExtents(newMin, newMax); + + //update parent's bbox center + LLVector4a center; + center.setAdd(newMin, newMax); + center.mul(0.5f); + setPositionGroup(center); + + //update parent's bbox size vector + LLVector4a size; + size.setSub(newMax, newMin); + size.mul(0.5f); + setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f)); +} //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- -- cgit v1.2.3 From 4cca9ba279f908f206fa5e32adccf1038f05cc7f Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 29 Jul 2013 10:15:10 -0600 Subject: fix for SH-4293: texture console takes a while to settle down on Interesting viewer. --- indra/newview/llvocache.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 69c32db13e..6e0243e985 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -219,18 +219,14 @@ void LLVOCacheEntry::setState(U32 state) if(getState() == ACTIVE) { - const S32 MIN_REAVTIVE_INTERVAL = 32; + const S32 MIN_REAVTIVE_INTERVAL = 128; U32 last_visible = getVisible(); setVisible(); - if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mMinFrameRange) + if(getVisible() - last_visible > MIN_REAVTIVE_INTERVAL + mMinFrameRange) { - mMinFrameRange = llmin(mMinFrameRange * 2, getInvisibleObjectsLiveTime() * 32); - } - else - { - mMinFrameRange = getInvisibleObjectsLiveTime(); //reset + mLastCameraUpdated = 0; //reset } } } -- cgit v1.2.3 From 15fe4b3bbaf139960f934b629c236092182ed297 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 30 Jul 2013 22:05:12 -0600 Subject: fix for SH-4297: interesting: viewer-interesting starts loading cached scene late --- indra/newview/llvocache.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 6e0243e985..d1c27edce7 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -219,15 +219,21 @@ void LLVOCacheEntry::setState(U32 state) if(getState() == ACTIVE) { - const S32 MIN_REAVTIVE_INTERVAL = 128; + const S32 MIN_INTERVAL = 64 + mMinFrameRange; U32 last_visible = getVisible(); setVisible(); - if(getVisible() - last_visible > MIN_REAVTIVE_INTERVAL + mMinFrameRange) + U32 cur_visible = getVisible(); + if(cur_visible - last_visible > MIN_INTERVAL || + cur_visible < MIN_INTERVAL) { mLastCameraUpdated = 0; //reset } + else + { + mLastCameraUpdated = LLViewerRegion::sLastCameraUpdated; + } } } -- cgit v1.2.3 From 576b9339977f50edb11a799d7a274610263f9fdc Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 5 Aug 2013 14:48:26 -0600 Subject: fix for SH-4397: Object cache occlusion culling results are not always correct --- indra/newview/llvocache.cpp | 63 ++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 21 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index d1c27edce7..9beb81bcdd 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -490,9 +490,8 @@ public: group->checkOcclusion(); - if (group->isOcclusionState(LLSpatialGroup::OCCLUDED)) + if (group->isOcclusionState(LLOcclusionCullingGroup::OCCLUDED)) { - mPartition->addOccluders(group); return true; } } @@ -530,7 +529,24 @@ public: virtual void processGroup(LLviewerOctreeGroup* base_group) { - mRegionp->addVisibleGroup(base_group); + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; + if(!group->isRecentlyVisible())//needs to issue new occlusion culling check. + { + mPartition->addOccluders(group); + group->setVisible(); + return ; //wait for occlusion culling result + } + + if(group->isOcclusionState(LLOcclusionCullingGroup::QUERY_PENDING) || + group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) + { + //keep waiting + group->setVisible(); + } + else + { + mRegionp->addVisibleGroup(base_group); + } } private: @@ -555,17 +571,9 @@ S32 LLVOCachePartition::cull(LLCamera &camera) LLVector3 region_agent = mRegionp->getOriginAgent(); camera.calcRegionFrustumPlanes(region_agent); - mOccludedGroups.clear(); - LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion, this); culler.traverse(mOctree); - if(!mOccludedGroups.empty()) - { - processOccluders(&camera, ®ion_agent); - mOccludedGroups.clear(); - } - return 0; } @@ -573,13 +581,6 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp; - const U32 MIN_WAIT_TIME = 19; //wait 19 frames to issue a new occlusion request - U32 last_issued_time = group->getLastOcclusionIssuedTime(); - if(!group->needsUpdate() && gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME) - { - return; - } - if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) { group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); @@ -587,14 +588,34 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) } } -void LLVOCachePartition::processOccluders(LLCamera* camera, const LLVector3* region_agent) +void LLVOCachePartition::processOccluders(LLCamera* camera) { + if(mOccludedGroups.empty()) + { + return; + } + + LLVector3 region_agent = mRegionp->getOriginAgent(); for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { LLOcclusionCullingGroup* group = *iter; - group->doOcclusion(camera, region_agent); - group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + group->doOcclusion(camera, ®ion_agent); + } +} + +void LLVOCachePartition::resetOccluders() +{ + if(mOccludedGroups.empty()) + { + return; } + + for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) + { + LLOcclusionCullingGroup* group = *iter; + group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + } + mOccludedGroups.clear(); } //------------------------------------------------------------------- -- cgit v1.2.3 From be8d04c358086d6650fe7a8195949ba6c11096ae Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 6 Aug 2013 18:03:23 -0600 Subject: fix for SH-4398: Interesting: viewer crash in LLVOCacheEntry::updateParentBoundingInfo --- indra/newview/llvocache.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 9beb81bcdd..1b68fee4c1 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -263,6 +263,28 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) } } +void LLVOCacheEntry::removeChild(LLVOCacheEntry* entry) +{ + for(S32 i = 0; i < mChildrenList.size(); i++) + { + if(mChildrenList[i] == entry) + { + entry->setParentID(0); + mChildrenList[i] = mChildrenList[mChildrenList.size() - 1]; + mChildrenList.pop_back(); + } + } +} + +void LLVOCacheEntry::removeAllChildren() +{ + for(S32 i = 0; i < mChildrenList.size(); i++) + { + mChildrenList[i]->setParentID(0); + } + mChildrenList.clear(); +} + LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc) { if ( (mCRC != crc) -- cgit v1.2.3 From f6a342438c59548276f0ee9f3033b47229d5d6d3 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 7 Aug 2013 11:29:31 -0600 Subject: more fix for SH-4397: Object cache occlusion culling results are not always correct --- indra/newview/llvocache.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 1b68fee4c1..11f31fcb9a 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -551,6 +551,14 @@ public: virtual void processGroup(LLviewerOctreeGroup* base_group) { + if( !mUseObjectCacheOcclusion || + !base_group->getOctreeNode()->getParent()) + { + //no occlusion check + mRegionp->addVisibleGroup(base_group); + return; + } + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; if(!group->isRecentlyVisible())//needs to issue new occlusion culling check. { -- cgit v1.2.3 From a2c7b0485576c6bb92f6d0eddc762f5e37d5caac Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 7 Aug 2013 22:53:27 -0600 Subject: more fix for SH-4397: Object cache occlusion culling results are not always correct --- indra/newview/llvocache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 11f31fcb9a..82485d7fdc 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -495,7 +495,7 @@ public: mPartition(part) { mLocalShift = shift; - mUseObjectCacheOcclusion = (use_object_cache_occlusion && LLPipeline::sUseOcclusion); + mUseObjectCacheOcclusion = use_object_cache_occlusion; } virtual bool earlyFail(LLviewerOctreeGroup* base_group) @@ -586,10 +586,10 @@ private: bool mUseObjectCacheOcclusion; }; -S32 LLVOCachePartition::cull(LLCamera &camera) +S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); - + if(!LLViewerRegion::sVOCacheCullingEnabled) { return 0; @@ -601,7 +601,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera) LLVector3 region_agent = mRegionp->getOriginAgent(); camera.calcRegionFrustumPlanes(region_agent); - LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion, this); + LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, this); culler.traverse(mOctree); return 0; -- cgit v1.2.3 From a6711a894c3c32ad24b47e36b2a52225713fd3ed Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 8 Aug 2013 16:45:55 -0600 Subject: fix for SH-4402: interesting: lower FPS with lots of objects in view --- indra/newview/llvocache.cpp | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 82485d7fdc..7dfa131ebf 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -34,6 +34,7 @@ #include "llviewerregion.h" #include "pipeline.h" +BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE; LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) @@ -467,8 +468,14 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) { mLODPeriod = 16; mRegionp = regionp; - mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; - + mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; + mDirty = FALSE; + + for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + { + mCulledTime[i] = 0; + mCullHistory[i] = -1; + } new LLOcclusionCullingGroup(mOctree, this); } @@ -477,6 +484,7 @@ void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) llassert(entry->hasVOCacheEntry()); mOctree->insert(entry); + mDirty = TRUE; } void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) @@ -595,7 +603,19 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) return 0; } + if(mCulledTime[LLViewerCamera::sCurCameraID] == LLViewerOctreeEntryData::getCurrentFrame()) + { + return 0; //already culled + } + mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); + + if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) + { + return 0; //nothing changed, skip culling + } + ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); + mCullHistory[LLViewerCamera::sCurCameraID] <<= 2; //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); @@ -604,7 +624,16 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, this); culler.traverse(mOctree); - return 0; + if(mRegionp->getNumOfVisibleGroups() > 0) + { + mCullHistory[LLViewerCamera::sCurCameraID] |= 1; + } + + if(!sNeedsOcclusionCheck) + { + sNeedsOcclusionCheck = !mOccludedGroups.empty(); + } + return 1; } void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) @@ -646,6 +675,8 @@ void LLVOCachePartition::resetOccluders() group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); } mOccludedGroups.clear(); + mDirty = FALSE; + sNeedsOcclusionCheck = FALSE; } //------------------------------------------------------------------- -- cgit v1.2.3 From e340009fc59d59e59b2e8d903a884acb76b178eb Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 9 Aug 2013 17:11:19 -0700 Subject: second phase summer cleaning replace llinfos, lldebugs, etc with new LL_INFOS(), LL_DEBUGS(), etc. --- indra/newview/llvocache.cpp | 54 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index d1c27edce7..98a924b3be 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -138,7 +138,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) // We've got a bogus size, skip reading it. // We won't bother seeking, because the rest of this file // is likely bogus, and will be tossed anyway. - llwarns << "Bogus cache entry, size " << size << ", aborting!" << llendl; + LL_WARNS() << "Bogus cache entry, size " << size << ", aborting!" << LL_ENDL; success = FALSE; } } @@ -268,7 +268,7 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc) if ( (mCRC != crc) ||(mDP.getBufferSize() == 0)) { - //llinfos << "Not getting cache entry, invalid!" << llendl; + //LL_INFOS() << "Not getting cache entry, invalid!" << LL_ENDL; return NULL; } mHitCount++; @@ -279,7 +279,7 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP() { if (mDP.getBufferSize() == 0) { - //llinfos << "Not getting cache entry, invalid!" << llendl; + //LL_INFOS() << "Not getting cache entry, invalid!" << LL_ENDL; return NULL; } @@ -295,12 +295,12 @@ void LLVOCacheEntry::recordHit() void LLVOCacheEntry::dump() const { - llinfos << "local " << mLocalID + LL_INFOS() << "local " << mLocalID << " crc " << mCRC << " hits " << mHitCount << " dupes " << mDupeCount << " change " << mCRCChangeCount - << llendl; + << LL_ENDL; } BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const @@ -640,13 +640,13 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) { if(!mEnabled) { - llwarns << "Not initializing cache: Cache is currently disabled." << llendl; + LL_WARNS() << "Not initializing cache: Cache is currently disabled." << LL_ENDL; return ; } if(mInitialized) { - llwarns << "Cache already initialized." << llendl; + LL_WARNS() << "Cache already initialized." << LL_ENDL; return ; } mInitialized = true; @@ -684,15 +684,15 @@ void LLVOCache::removeCache(ELLPath location, bool started) if(mReadOnly) { - llwarns << "Not removing cache at " << location << ": Cache is currently in read-only mode." << llendl; + LL_WARNS() << "Not removing cache at " << location << ": Cache is currently in read-only mode." << LL_ENDL; return ; } - llinfos << "about to remove the object cache due to settings." << llendl ; + LL_INFOS() << "about to remove the object cache due to settings." << LL_ENDL ; std::string mask = "*"; std::string cache_dir = gDirUtilp->getExpandedFilename(location, object_cache_dirname); - llinfos << "Removing cache at " << cache_dir << llendl; + LL_INFOS() << "Removing cache at " << cache_dir << LL_ENDL; gDirUtilp->deleteFilesInDir(cache_dir, mask); //delete all files LLFile::rmdir(cache_dir); @@ -705,17 +705,17 @@ void LLVOCache::removeCache() if(!mInitialized) { //OK to remove cache even it is not initialized. - llwarns << "Object cache is not initialized yet." << llendl; + LL_WARNS() << "Object cache is not initialized yet." << LL_ENDL; } if(mReadOnly) { - llwarns << "Not clearing object cache: Cache is currently in read-only mode." << llendl; + LL_WARNS() << "Not clearing object cache: Cache is currently in read-only mode." << LL_ENDL; return ; } std::string mask = "*"; - llinfos << "Removing object cache at " << mObjectCacheDirName << llendl; + LL_INFOS() << "Removing object cache at " << mObjectCacheDirName << LL_ENDL; gDirUtilp->deleteFilesInDir(mObjectCacheDirName, mask); clearCacheInMemory() ; @@ -787,7 +787,7 @@ void LLVOCache::removeFromCache(HeaderEntryInfo* entry) { if(mReadOnly) { - llwarns << "Not removing cache for handle " << entry->mHandle << ": Cache is currently in read-only mode." << llendl; + LL_WARNS() << "Not removing cache for handle " << entry->mHandle << ": Cache is currently in read-only mode." << LL_ENDL; return ; } @@ -802,7 +802,7 @@ void LLVOCache::readCacheHeader() { if(!mEnabled) { - llwarns << "Not reading cache header: Cache is currently disabled." << llendl; + LL_WARNS() << "Not reading cache header: Cache is currently disabled." << LL_ENDL; return; } @@ -832,7 +832,7 @@ void LLVOCache::readCacheHeader() if(!success) //failed { - llwarns << "Error reading cache header entry. (entry_index=" << mNumEntries << ")" << llendl; + LL_WARNS() << "Error reading cache header entry. (entry_index=" << mNumEntries << ")" << LL_ENDL; delete entry ; entry = NULL ; break ; @@ -860,7 +860,7 @@ void LLVOCache::readCacheHeader() //for(header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ; success && iter != mHeaderEntryQueue.end(); ++iter) //{ // getObjectCacheFilename((*iter)->mHandle, name) ; - // llinfos << name << llendl ; + // LL_INFOS() << name << LL_ENDL ; //} //----------- } @@ -885,13 +885,13 @@ void LLVOCache::writeCacheHeader() { if (!mEnabled) { - llwarns << "Not writing cache header: Cache is currently disabled." << llendl; + LL_WARNS() << "Not writing cache header: Cache is currently disabled." << LL_ENDL; return; } if(mReadOnly) { - llwarns << "Not writing cache header: Cache is currently in read-only mode." << llendl; + LL_WARNS() << "Not writing cache header: Cache is currently in read-only mode." << LL_ENDL; return; } @@ -945,7 +945,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca { if(!mEnabled) { - llwarns << "Not reading cache for handle " << handle << "): Cache is currently disabled." << llendl; + LL_WARNS() << "Not reading cache for handle " << handle << "): Cache is currently disabled." << LL_ENDL; return ; } llassert_always(mInitialized); @@ -953,7 +953,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ; if(iter == mHandleEntryMap.end()) //no cache { - llwarns << "No handle map entry for " << handle << llendl; + LL_WARNS() << "No handle map entry for " << handle << LL_ENDL; return ; } @@ -970,7 +970,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca { if(cache_id != id) { - llinfos << "Cache ID doesn't match for this region, discarding"<< llendl; + LL_INFOS() << "Cache ID doesn't match for this region, discarding"<< LL_ENDL; success = false ; } @@ -986,7 +986,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca LLPointer entry = new LLVOCacheEntry(&apr_file); if (!entry->getLocalID()) { - llwarns << "Aborting cache file load for " << filename << ", cache file corruption!" << llendl; + LL_WARNS() << "Aborting cache file load for " << filename << ", cache file corruption!" << LL_ENDL; success = false ; break ; } @@ -1026,14 +1026,14 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: { if(!mEnabled) { - llwarns << "Not writing cache for handle " << handle << "): Cache is currently disabled." << llendl; + LL_WARNS() << "Not writing cache for handle " << handle << "): Cache is currently disabled." << LL_ENDL; return ; } llassert_always(mInitialized); if(mReadOnly) { - llwarns << "Not writing cache for handle " << handle << "): Cache is currently in read-only mode." << llendl; + LL_WARNS() << "Not writing cache for handle " << handle << "): Cache is currently in read-only mode." << LL_ENDL; return ; } @@ -1068,13 +1068,13 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: //update cache header if(!updateEntry(entry)) { - llwarns << "Failed to update cache header index " << entry->mIndex << ". handle = " << handle << llendl; + LL_WARNS() << "Failed to update cache header index " << entry->mIndex << ". handle = " << handle << LL_ENDL; return ; //update failed. } if(!dirty_cache) { - llwarns << "Skipping write to cache for handle " << handle << ": cache not dirty" << llendl; + LL_WARNS() << "Skipping write to cache for handle " << handle << ": cache not dirty" << LL_ENDL; return ; //nothing changed, no need to update. } -- cgit v1.2.3 From 23214506d280b485cc74372a9dbb8d6b8c3937c5 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 14 Aug 2013 14:56:35 -0600 Subject: enable far clip plane culling on object cache view culling --- indra/newview/llvocache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 7dfa131ebf..67a0b58241 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -531,7 +531,7 @@ public: virtual S32 frustumCheck(const LLviewerOctreeGroup* group) { -#if 0 +#if 1 S32 res = AABBInRegionFrustumGroupBounds(group); #else S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); @@ -545,7 +545,7 @@ public: virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) { -#if 0 +#if 1 S32 res = AABBInRegionFrustumObjectBounds(group); #else S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); -- cgit v1.2.3 From 31bf481a7b5f079d95be6a44a45502bb957e0941 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 21 Aug 2013 10:19:44 -0600 Subject: fix some objects not rendered when login process is very long --- indra/newview/llvocache.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 838ac353d1..3bd71e2648 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -261,6 +261,12 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) if(getEntry() != NULL && isState(INACTIVE)) { updateParentBoundingInfo(entry); + if(getGroup()) + { + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup(); + group->unbound(); + ((LLVOCachePartition*)group->getSpatialPartition())->setDirty(); + } } } @@ -479,12 +485,17 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) new LLOcclusionCullingGroup(mOctree, this); } +void LLVOCachePartition::setDirty() +{ + mDirty = TRUE; +} + void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) { llassert(entry->hasVOCacheEntry()); mOctree->insert(entry); - mDirty = TRUE; + setDirty(); } void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) @@ -615,7 +626,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); - mCullHistory[LLViewerCamera::sCurCameraID] <<= 2; + mCullHistory[LLViewerCamera::sCurCameraID] <<= 1; //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); -- cgit v1.2.3 From 7b5618aeaeb4df31bd3f9436e067b26fb5be866b Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 22 Aug 2013 12:22:34 -0600 Subject: fix for SH-4400: Interesting: Side effect 1 of unloading culled objects. --- indra/newview/llvocache.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 3bd71e2648..2430fa556a 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -238,12 +238,6 @@ void LLVOCacheEntry::setState(U32 state) } } -//virtual -U32 LLVOCacheEntry::getMinFrameRange()const -{ - return mMinFrameRange; -} - void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) { llassert(entry != NULL); @@ -371,6 +365,28 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const return success ; } +bool LLVOCacheEntry::isRecentlyVisible() const +{ + bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); + + if(!vis) + { + vis = (sCurVisible - getVisible() < mMinFrameRange); + } + + if(!vis && !mParentID && mSceneContrib > 0.f) + { + //projection area: mSceneContrib + + //squared distance + const F32 SQUARED_CUT_OFF_DIST = 225.0; //15m + F32 rad = getBinRadius(); + vis = (rad * rad / mSceneContrib > SQUARED_CUT_OFF_DIST); + } + + return vis; +} + void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update) { if(!needs_update && getVisible() >= last_update) @@ -387,8 +403,11 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool lookAt.setSub(center, origin); F32 squared_dist = lookAt.dot3(lookAt).getF32(); - F32 rad = getBinRadius(); - mSceneContrib = rad * rad / squared_dist; + if(squared_dist > 0.f) + { + F32 rad = getBinRadius(); + mSceneContrib = rad * rad / squared_dist; + } setVisible(); } -- cgit v1.2.3 From 11a78da4b12b99e820c2018f1a0b70ea2a222a07 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 23 Aug 2013 12:23:21 -0600 Subject: more fix for SH-4400: Interesting: Side effect 1 of unloading culled objects. --- indra/newview/llvocache.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 2430fa556a..ebde17dcef 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -374,14 +374,13 @@ bool LLVOCacheEntry::isRecentlyVisible() const vis = (sCurVisible - getVisible() < mMinFrameRange); } - if(!vis && !mParentID && mSceneContrib > 0.f) + //combination of projected area and squared distance + if(!vis && !mParentID && mSceneContrib > 0.0311f) //projection angle > 10 (degree) { - //projection area: mSceneContrib - //squared distance - const F32 SQUARED_CUT_OFF_DIST = 225.0; //15m + const F32 SQUARED_CUT_OFF_DIST = 256.0; //16m F32 rad = getBinRadius(); - vis = (rad * rad / mSceneContrib > SQUARED_CUT_OFF_DIST); + vis = (rad * rad / mSceneContrib < SQUARED_CUT_OFF_DIST); } return vis; -- cgit v1.2.3 From 55df26a7bf9e141205484543cf02759f599bf521 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 23 Aug 2013 12:24:58 -0600 Subject: temporary fix for rendering starts late when running on pdp station --- indra/newview/llvocache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ebde17dcef..dc7b907a35 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -638,10 +638,10 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); - if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) - { - return 0; //nothing changed, skip culling - } + //if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) + //{ + // return 0; //nothing changed, skip culling + //} ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); mCullHistory[LLViewerCamera::sCurCameraID] <<= 1; -- cgit v1.2.3 From 041ab1c46c681de63c934af031c1d1a0b3f5a4da Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 26 Aug 2013 11:33:37 -0600 Subject: reversion of rendering starts late change --- indra/newview/llvocache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index dc7b907a35..ebde17dcef 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -638,10 +638,10 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); - //if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) - //{ - // return 0; //nothing changed, skip culling - //} + if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) + { + return 0; //nothing changed, skip culling + } ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); mCullHistory[LLViewerCamera::sCurCameraID] <<= 1; -- cgit v1.2.3 From edd1478cc0ba240d428fc4c35f9c97af7d2ce346 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 28 Aug 2013 17:27:28 -0600 Subject: fix for SH-4332: Cacheable object highlights from Render Metadata -> Update Type do not render --- indra/newview/llvocache.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ebde17dcef..dcd1ae391d 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -286,18 +286,6 @@ void LLVOCacheEntry::removeAllChildren() mChildrenList.clear(); } -LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc) -{ - if ( (mCRC != crc) - ||(mDP.getBufferSize() == 0)) - { - //LL_INFOS() << "Not getting cache entry, invalid!" << LL_ENDL; - return NULL; - } - mHitCount++; - return &mDP; -} - LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP() { if (mDP.getBufferSize() == 0) -- cgit v1.2.3 From 1751650dbcad4ea66b2c3779aa52960ec1640466 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 29 Aug 2013 13:14:56 -0600 Subject: add some debug settings for easier tuning up performance. --- indra/newview/llvocache.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index dcd1ae391d..1cfda038a8 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -33,7 +33,10 @@ #include "lldrawable.h" #include "llviewerregion.h" #include "pipeline.h" +#include "llagentcamera.h" +F32 LLVOCacheEntry::sBackDistanceSquared = 0.f; +F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f; BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE; LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); @@ -353,6 +356,21 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const return success ; } +//static +void LLVOCacheEntry::updateBackCullingFactors() +{ + //distance to keep objects = back_dist_factor * draw_distance + static LLCachedControl back_dist_factor(gSavedSettings,"BackDistanceFactor"); + + //squared tan(projection angle of the bbox), default is 10 (degree) + static LLCachedControl squared_back_angle(gSavedSettings,"BackProjectionAngleSquared"); + + sBackDistanceSquared = back_dist_factor * gAgentCamera.mDrawDistance; + sBackDistanceSquared *= sBackDistanceSquared; + + sBackAngleTanSquared = squared_back_angle; +} + bool LLVOCacheEntry::isRecentlyVisible() const { bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); @@ -363,12 +381,10 @@ bool LLVOCacheEntry::isRecentlyVisible() const } //combination of projected area and squared distance - if(!vis && !mParentID && mSceneContrib > 0.0311f) //projection angle > 10 (degree) + if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) { - //squared distance - const F32 SQUARED_CUT_OFF_DIST = 256.0; //16m F32 rad = getBinRadius(); - vis = (rad * rad / mSceneContrib < SQUARED_CUT_OFF_DIST); + vis = (rad * rad / mSceneContrib < sBackDistanceSquared); } return vis; -- cgit v1.2.3 From cbe397ad13665c7bc993e10d8fe1e4a876253378 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 5 Sep 2013 14:04:13 -0700 Subject: changed fast timer over to using macro another attempt to move mem stat into base class --- indra/newview/llvocache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 1cfda038a8..3c09981f7d 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -38,7 +38,7 @@ F32 LLVOCacheEntry::sBackDistanceSquared = 0.f; F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f; BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE; -LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); +//LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { -- cgit v1.2.3 From a9d22b0f585cc90ba1bb94a68cc4175b3019b062 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 9 Sep 2013 11:58:52 -0600 Subject: some fix for SH-4416: Interesting: memory footprint is larger when loading from cache while ObjectCacheViewCullingEnabled is enabled than when it's disabled. --- indra/newview/llvocache.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 1cfda038a8..35af99cd42 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -636,6 +636,11 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) return 0; } + if(LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_WATER0) + { + return 0; //no need for those cameras. + } + if(mCulledTime[LLViewerCamera::sCurCameraID] == LLViewerOctreeEntryData::getCurrentFrame()) { return 0; //already culled -- cgit v1.2.3 From 605060ea022670f4ff6f8850f79495032095b58e Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 12 Sep 2013 16:40:18 -0600 Subject: fix for SH-4477: Interesting: objects on adjacent region are not visible. #3 and SH-4457: Interesting: nearby content on adjacent region is not visible. --- indra/newview/llvocache.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index f0c9546651..c2b09246e9 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -545,10 +545,10 @@ public: base_group->getOctreeNode()->getParent()) //never occlusion cull the root node { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; - if(group->needsUpdate())//needs to issue new occlusion culling check. + if(group->needsUpdate()) { - mPartition->addOccluders(group); - return true; + //needs to issue new occlusion culling check, perform view culling check first. + return false; } group->checkOcclusion(); @@ -601,7 +601,7 @@ public: } LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; - if(!group->isRecentlyVisible())//needs to issue new occlusion culling check. + if(group->needsUpdate() || !group->isRecentlyVisible())//needs to issue new occlusion culling check. { mPartition->addOccluders(group); group->setVisible(); @@ -693,10 +693,11 @@ void LLVOCachePartition::processOccluders(LLCamera* camera) } LLVector3 region_agent = mRegionp->getOriginAgent(); + LLVector4a shift(region_agent[0], region_agent[1], region_agent[2]); for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { LLOcclusionCullingGroup* group = *iter; - group->doOcclusion(camera, ®ion_agent); + group->doOcclusion(camera, &shift); } } -- cgit v1.2.3 From 19137ac8fcdc8783b317c967a222136b42ff3ed0 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 18 Sep 2013 15:48:52 -0600 Subject: fix for SH-4500: Interesting: Some content on adjacent region not visible after teleport. --- indra/newview/llvocache.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index c2b09246e9..5932fb87c1 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -258,12 +258,6 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) if(getEntry() != NULL && isState(INACTIVE)) { updateParentBoundingInfo(entry); - if(getGroup()) - { - LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup(); - group->unbound(); - ((LLVOCachePartition*)group->getSpatialPartition())->setDirty(); - } } } @@ -636,6 +630,8 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) return 0; } + ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); + if(LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_WATER0) { return 0; //no need for those cameras. @@ -651,8 +647,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { return 0; //nothing changed, skip culling } - - ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); + mCullHistory[LLViewerCamera::sCurCameraID] <<= 1; //localize the camera -- cgit v1.2.3 From e464b855abb85e03dfec59691b7eccac27a323c4 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 19 Sep 2013 11:14:26 -0600 Subject: fix for SH-4501: Interesting: Occluded objects do not appear when Occluder object is deleted. --- indra/newview/llvocache.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 5932fb87c1..6d2a17882a 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -491,8 +491,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) mLODPeriod = 16; mRegionp = regionp; mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; - mDirty = FALSE; - + for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) { mCulledTime[i] = 0; @@ -501,17 +500,11 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) new LLOcclusionCullingGroup(mOctree, this); } -void LLVOCachePartition::setDirty() -{ - mDirty = TRUE; -} - void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) { llassert(entry->hasVOCacheEntry()); mOctree->insert(entry); - setDirty(); } void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) @@ -643,12 +636,28 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); - if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) + if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) { - return 0; //nothing changed, skip culling + static U32 hash = 0; + + U32 seed = llmax(mLODPeriod >> 1, (U32)4); + if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + { + if(!(LLViewerOctreeEntryData::getCurrentFrame() % seed)) + { + hash = (hash + 1) % seed; + } + } + if(LLViewerOctreeEntryData::getCurrentFrame() % seed != hash) + { + return 0; //nothing changed, reduce frequency of culling + } } - mCullHistory[LLViewerCamera::sCurCameraID] <<= 1; + if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + { + mCullHistory[LLViewerCamera::sCurCameraID] <<= 1; + } //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); @@ -709,7 +718,6 @@ void LLVOCachePartition::resetOccluders() group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); } mOccludedGroups.clear(); - mDirty = FALSE; sNeedsOcclusionCheck = FALSE; } -- cgit v1.2.3 From ba4f64ed7ad64deeed5f7109f33c796bae0c4423 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 20 Sep 2013 11:40:30 -0600 Subject: fix for SH-4430: Interesting: Light objects behind you are not loaded at login. --- indra/newview/llvocache.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 6d2a17882a..e3a3f0510b 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -490,7 +490,8 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) { mLODPeriod = 16; mRegionp = regionp; - mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; + mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; + mBackSlectionEnabled = -1; for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) { @@ -517,7 +518,8 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) class LLVOCacheOctreeCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) + LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, + const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) : LLViewerOctreeCull(camera), mRegionp(regionp), mPartition(part) @@ -583,7 +585,10 @@ public: !base_group->getOctreeNode()->getParent()) { //no occlusion check - mRegionp->addVisibleGroup(base_group); + if(mRegionp->addVisibleGroup(base_group)) + { + base_group->setVisible(); + } return; } @@ -603,7 +608,10 @@ public: } else { - mRegionp->addVisibleGroup(base_group); + if(mRegionp->addVisibleGroup(base_group)) + { + base_group->setVisible(); + } } } @@ -614,6 +622,81 @@ private: bool mUseObjectCacheOcclusion; }; +//select objects behind camera +class LLVOCacheOctreeBackCull : public LLViewerOctreeCull +{ +public: + LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp) + : LLViewerOctreeCull(camera), mRegionp(regionp) + { + mLocalShift = shift; + mSphereRadius = 20.f; //20m + } + + virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + { + const LLVector4a* exts = group->getExtents(); + return backSphereCheck(exts[0], exts[1]); + } + + virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + { + const LLVector4a* exts = group->getObjectExtents(); + return backSphereCheck(exts[0], exts[1]); + } + + virtual void processGroup(LLviewerOctreeGroup* base_group) + { + mRegionp->addVisibleGroup(base_group); + return; + } + +private: + //a sphere around the camera origin, including objects behind camera. + S32 backSphereCheck(const LLVector4a& min, const LLVector4a& max) + { + return AABBSphereIntersect(min, max, mCamera->getOrigin() - mLocalShift, mSphereRadius); + } + +private: + F32 mSphereRadius; + LLViewerRegion* mRegionp; + LLVector3 mLocalShift; //shift vector from agent space to local region space. +}; + +void LLVOCachePartition::selectBackObjects(LLCamera &camera) +{ + if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) + { + return; + } + + if(mBackSlectionEnabled < 0) + { + mBackSlectionEnabled = LLVOCacheEntry::getInvisibleObjectsLiveTime() - 1; + mBackSlectionEnabled = llmax(mBackSlectionEnabled, (S32)1); + } + + if(!mBackSlectionEnabled) + { + return; + } + + //localize the camera + LLVector3 region_agent = mRegionp->getOriginAgent(); + + LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp); + culler.traverse(mOctree); + + mBackSlectionEnabled--; + if(!mRegionp->getNumOfVisibleGroups()) + { + mBackSlectionEnabled = 0; + } + + return; +} + S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); @@ -650,10 +733,15 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } if(LLViewerOctreeEntryData::getCurrentFrame() % seed != hash) { + selectBackObjects(camera);//process back objects selection return 0; //nothing changed, reduce frequency of culling } } - + else + { + mBackSlectionEnabled = -1; //reset it. + } + if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) { mCullHistory[LLViewerCamera::sCurCameraID] <<= 1; -- cgit v1.2.3 From 3eb226275b6c66ddf5b4aa4d40f9e8c855fb4a0f Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 20 Sep 2013 11:46:51 -0600 Subject: more fix for SH-4501: Interesting: Occluded objects do not appear when Occluder object is deleted. --- indra/newview/llvocache.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index e3a3f0510b..dfc9ee57d8 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -492,6 +492,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) mRegionp = regionp; mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; mBackSlectionEnabled = -1; + mIdleHash = 0; for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) { @@ -721,17 +722,15 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) { - static U32 hash = 0; - U32 seed = llmax(mLODPeriod >> 1, (U32)4); if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) { if(!(LLViewerOctreeEntryData::getCurrentFrame() % seed)) { - hash = (hash + 1) % seed; + mIdleHash = (mIdleHash + 1) % seed; } } - if(LLViewerOctreeEntryData::getCurrentFrame() % seed != hash) + if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash) { selectBackObjects(camera);//process back objects selection return 0; //nothing changed, reduce frequency of culling -- cgit v1.2.3 From 053d97db1b283ca2548dc1f64756ddfc5166158f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 25 Sep 2013 19:12:35 -0700 Subject: better memory usage for LLTrace (tighter packing of recording arrays) removed complicated and unnecessary fast timer gapless handoff logic (it should be gapless anyway) improved MemTrackable API, better separation of shadow and footprint added memory usage stats to floater_stats.xml --- indra/newview/llvocache.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index dfc9ee57d8..25dd1f4d07 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -38,7 +38,6 @@ F32 LLVOCacheEntry::sBackDistanceSquared = 0.f; F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f; BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE; -//LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { -- cgit v1.2.3 From 5cbd814d497c6772424cc555812da620370db37b Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 26 Sep 2013 17:12:02 -0600 Subject: fix for SH-4523: interesting: viewer sometimes doesn't save objectcache file on disconnect from region --- indra/newview/llvocache.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 25dd1f4d07..91a5d4f973 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -312,11 +312,6 @@ void LLVOCacheEntry::dump() const BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const { - if(!mEntry) - { - return FALSE; - } - BOOL success; success = check_write(apr_file, (void*)&mLocalID, sizeof(U32)); if(success) @@ -1191,7 +1186,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca if(success) { - for (S32 i = 0; i < num_entries; i++) + for (S32 i = 0; i < num_entries && apr_file.eof() != APR_EOF; i++) { LLPointer entry = new LLVOCacheEntry(&apr_file); if (!entry->getLocalID()) @@ -1308,6 +1303,10 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: if(!removal_enabled || iter->second->isTouched()) { success = iter->second->writeToFile(&apr_file) ; + if(!success) + { + break; + } } } } @@ -1316,7 +1315,6 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: if(!success) { removeEntry(entry) ; - } return ; -- cgit v1.2.3 From 2fad2cc7365803b63bfe2466da2558182a1c25b9 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 26 Sep 2013 22:28:21 -0600 Subject: more optimization for memory footprint. --- indra/newview/llvocache.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 91a5d4f973..7ba0c31ffc 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -37,6 +37,7 @@ F32 LLVOCacheEntry::sBackDistanceSquared = 0.f; F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f; +U32 LLVOCacheEntry::sMinFrameRange = 0; BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE; BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) @@ -53,14 +54,6 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes) //--------------------------------------------------------------------------- // LLVOCacheEntry //--------------------------------------------------------------------------- -//return number of frames invisible objects should stay in memory -//static -U32 LLVOCacheEntry::getInvisibleObjectsLiveTime() -{ - static LLCachedControl inv_obj_time(gSavedSettings,"InvisibleObjectsInMemoryTime"); - - return inv_obj_time - 1; //make 0 to be the maximum -} LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp) : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), @@ -78,7 +71,6 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); mDP = dp; - mMinFrameRange = getInvisibleObjectsLiveTime(); } LLVOCacheEntry::LLVOCacheEntry() @@ -96,7 +88,6 @@ LLVOCacheEntry::LLVOCacheEntry() mParentID(0) { mDP.assignBuffer(mBuffer, 0); - mMinFrameRange = getInvisibleObjectsLiveTime(); } LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) @@ -111,7 +102,6 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) S32 size = -1; BOOL success; - mMinFrameRange = getInvisibleObjectsLiveTime(); mDP.assignBuffer(mBuffer, 0); success = check_read(apr_file, &mLocalID, sizeof(U32)); @@ -222,7 +212,7 @@ void LLVOCacheEntry::setState(U32 state) if(getState() == ACTIVE) { - const S32 MIN_INTERVAL = 64 + mMinFrameRange; + const S32 MIN_INTERVAL = 64 + sMinFrameRange; U32 last_visible = getVisible(); setVisible(); @@ -345,7 +335,7 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const } //static -void LLVOCacheEntry::updateBackCullingFactors() +void LLVOCacheEntry::updateDebugSettings() { //distance to keep objects = back_dist_factor * draw_distance static LLCachedControl back_dist_factor(gSavedSettings,"BackDistanceFactor"); @@ -353,6 +343,11 @@ void LLVOCacheEntry::updateBackCullingFactors() //squared tan(projection angle of the bbox), default is 10 (degree) static LLCachedControl squared_back_angle(gSavedSettings,"BackProjectionAngleSquared"); + //the number of frames invisible objects stay in memory + static LLCachedControl inv_obj_time(gSavedSettings,"InvisibleObjectsInMemoryTime"); + + sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum + sBackDistanceSquared = back_dist_factor * gAgentCamera.mDrawDistance; sBackDistanceSquared *= sBackDistanceSquared; @@ -363,11 +358,6 @@ bool LLVOCacheEntry::isRecentlyVisible() const { bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); - if(!vis) - { - vis = (sCurVisible - getVisible() < mMinFrameRange); - } - //combination of projected area and squared distance if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) { @@ -668,7 +658,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera) if(mBackSlectionEnabled < 0) { - mBackSlectionEnabled = LLVOCacheEntry::getInvisibleObjectsLiveTime() - 1; + mBackSlectionEnabled = LLVOCacheEntry::sMinFrameRange - 1; mBackSlectionEnabled = llmax(mBackSlectionEnabled, (S32)1); } -- cgit v1.2.3 From 12f0f8cb72f789e21b01b45063dcc5f1f5292087 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 1 Oct 2013 13:46:43 -0700 Subject: changed over to manual naming of MemTrackable stats changed claimMem and disclaimMem behavior to not pass through argument added more mem tracking stats to floater_stats --- indra/newview/llvocache.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 7ba0c31ffc..01666778b1 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -56,7 +56,8 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes) //--------------------------------------------------------------------------- LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp) - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(local_id), mCRC(crc), mUpdateFlags(-1), @@ -74,7 +75,8 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & } LLVOCacheEntry::LLVOCacheEntry() - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(0), mCRC(0), mUpdateFlags(-1), @@ -91,7 +93,8 @@ LLVOCacheEntry::LLVOCacheEntry() } LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mBuffer(NULL), mUpdateFlags(-1), mState(INACTIVE), @@ -471,6 +474,7 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) //LLVOCachePartition //------------------------------------------------------------------- LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) +: LLTrace::MemTrackable("LLVOCachePartition") { mLODPeriod = 16; mRegionp = regionp; -- cgit v1.2.3 From da8ac532072d5f054d30e46021b429fa72c3ab66 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 2 Oct 2013 17:55:37 -0600 Subject: more for SH-4521: Interesting viewer crash in Pipeline:RenderDrawPools --- indra/newview/llvocache.cpp | 49 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 7ba0c31ffc..5a2f477f19 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -470,6 +470,31 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- +LLVOCacheGroup::~LLVOCacheGroup() +{ + if(mOcclusionState[0] & ACTIVE_OCCLUSION) + { + ((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this); + } +} + +//virtual +void LLVOCacheGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) +{ + if (child->getListenerCount() == 0) + { + new LLVOCacheGroup(child, mSpatialPartition); + } + else + { + OCT_ERRS << "LLVOCacheGroup redundancy detected." << LL_ENDL; + } + + unbound(); + + ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); +} + LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) { mLODPeriod = 16; @@ -483,7 +508,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) mCulledTime[i] = 0; mCullHistory[i] = -1; } - new LLOcclusionCullingGroup(mOctree, this); + new LLVOCacheGroup(mOctree, this); } void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) @@ -751,11 +776,11 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) { - LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp; + LLVOCacheGroup* group = (LLVOCacheGroup*)gp; if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) { - group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS); mOccludedGroups.insert(group); } } @@ -769,9 +794,9 @@ void LLVOCachePartition::processOccluders(LLCamera* camera) LLVector3 region_agent = mRegionp->getOriginAgent(); LLVector4a shift(region_agent[0], region_agent[1], region_agent[2]); - for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) + for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { - LLOcclusionCullingGroup* group = *iter; + LLVOCacheGroup* group = *iter; group->doOcclusion(camera, &shift); } } @@ -783,15 +808,23 @@ void LLVOCachePartition::resetOccluders() return; } - for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) + for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { - LLOcclusionCullingGroup* group = *iter; - group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + LLVOCacheGroup* group = *iter; + group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS); } mOccludedGroups.clear(); sNeedsOcclusionCheck = FALSE; } +void LLVOCachePartition::removeOccluder(LLVOCacheGroup* group) +{ + if(mOccludedGroups.empty()) + { + return; + } + mOccludedGroups.erase(group); +} //------------------------------------------------------------------- //LLVOCache //------------------------------------------------------------------- -- cgit v1.2.3 From 9ae025f8ee8688b25678a243ba19f1398de08060 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 3 Oct 2013 16:21:54 -0600 Subject: add a debug setting: "BackShpereCullingRadius" --- indra/newview/llvocache.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 20e69cbea9..ada412be8c 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -640,11 +640,11 @@ private: class LLVOCacheOctreeBackCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp) + LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius) : LLViewerOctreeCull(camera), mRegionp(regionp) { mLocalShift = shift; - mSphereRadius = 20.f; //20m + mSphereRadius = back_sphere_radius; } virtual S32 frustumCheck(const LLviewerOctreeGroup* group) @@ -678,7 +678,7 @@ private: LLVector3 mLocalShift; //shift vector from agent space to local region space. }; -void LLVOCachePartition::selectBackObjects(LLCamera &camera) +void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius) { if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { @@ -699,7 +699,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera) //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); - LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp); + LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius); culler.traverse(mOctree); mBackSlectionEnabled--; @@ -714,6 +714,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera) S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); + static LLCachedControl back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); if(!LLViewerRegion::sVOCacheCullingEnabled) { @@ -745,7 +746,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash) { - selectBackObjects(camera);//process back objects selection + selectBackObjects(camera, back_sphere_radius);//process back objects selection return 0; //nothing changed, reduce frequency of culling } } -- cgit v1.2.3 From b0aa408a665ce61ff374f99e421812482fe53848 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 4 Oct 2013 11:09:29 -0600 Subject: fix for SH-4544: Interesting: Shadows from platforms above the camera flicker --- indra/newview/llvocache.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ada412be8c..71d5a92df3 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -361,6 +361,12 @@ bool LLVOCacheEntry::isRecentlyVisible() const { bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); + if(!vis && getGroup()) + { + //recently visible to any camera? + vis = ((LLOcclusionCullingGroup*)getGroup())->isAnyRecentlyVisible(); + } + //combination of projected area and squared distance if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) { -- cgit v1.2.3 From c430673b95823f688c45d0fbda4198595bb41073 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 4 Oct 2013 17:54:24 -0600 Subject: more fix for SH-4521: Interesting viewer crash in Pipeline:RenderDrawPools --- indra/newview/llvocache.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 71d5a92df3..b8a6141e2c 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -481,9 +481,13 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) //------------------------------------------------------------------- LLVOCacheGroup::~LLVOCacheGroup() { - if(mOcclusionState[0] & ACTIVE_OCCLUSION) + for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) { - ((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this); + if(mOcclusionState[i] & ACTIVE_OCCLUSION) + { + ((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this); + break; + } } } @@ -726,6 +730,10 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { return 0; } + if(mRegionp->isPaused()) + { + return 0; + } ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); @@ -791,7 +799,7 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) { - group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS); + group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); mOccludedGroups.insert(group); } } @@ -808,7 +816,11 @@ void LLVOCachePartition::processOccluders(LLCamera* camera) for(std::set::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { LLVOCacheGroup* group = *iter; - group->doOcclusion(camera, &shift); + if(group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) + { + group->doOcclusion(camera, &shift); + group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + } } } -- cgit v1.2.3 From 17df8988fec3f2ba991ca9e34ff8148253a2fc04 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 7 Oct 2013 13:38:03 -0700 Subject: renamed TraceType to StatType added more MemTrackable types optimized memory usage of LLTrace some more --- indra/newview/llvocache.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ada412be8c..3f01ffa3cd 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -495,7 +495,7 @@ void LLVOCacheGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c unbound(); - ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); + ((LLViewerOctreeGroup*)child->getListener(0))->unbound(); } LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) @@ -542,7 +542,7 @@ public: mUseObjectCacheOcclusion = use_object_cache_occlusion; } - virtual bool earlyFail(LLviewerOctreeGroup* base_group) + virtual bool earlyFail(LLViewerOctreeGroup* base_group) { if( mUseObjectCacheOcclusion && base_group->getOctreeNode()->getParent()) //never occlusion cull the root node @@ -565,7 +565,7 @@ public: return false; } - virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { #if 1 S32 res = AABBInRegionFrustumGroupBounds(group); @@ -579,7 +579,7 @@ public: return res; } - virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { #if 1 S32 res = AABBInRegionFrustumObjectBounds(group); @@ -593,7 +593,7 @@ public: return res; } - virtual void processGroup(LLviewerOctreeGroup* base_group) + virtual void processGroup(LLViewerOctreeGroup* base_group) { if( !mUseObjectCacheOcclusion || !base_group->getOctreeNode()->getParent()) @@ -647,19 +647,19 @@ public: mSphereRadius = back_sphere_radius; } - virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { const LLVector4a* exts = group->getExtents(); return backSphereCheck(exts[0], exts[1]); } - virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { const LLVector4a* exts = group->getObjectExtents(); return backSphereCheck(exts[0], exts[1]); } - virtual void processGroup(LLviewerOctreeGroup* base_group) + virtual void processGroup(LLViewerOctreeGroup* base_group) { mRegionp->addVisibleGroup(base_group); return; @@ -721,7 +721,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) return 0; } - ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); + ((LLViewerOctreeGroup*)mOctree->getListener(0))->rebound(); if(LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_WATER0) { @@ -779,7 +779,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) return 1; } -void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) +void LLVOCachePartition::addOccluders(LLViewerOctreeGroup* gp) { LLVOCacheGroup* group = (LLVOCacheGroup*)gp; -- cgit v1.2.3 From c8067cfd9708fe30659b1f07f6d035508bea3033 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 9 Oct 2013 21:42:53 -0600 Subject: Enable the debug setting "NonvisibleObjectsInMemoryTime" --- indra/newview/llvocache.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 0466dea39d..f16f3507c3 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -347,7 +347,7 @@ void LLVOCacheEntry::updateDebugSettings() static LLCachedControl squared_back_angle(gSavedSettings,"BackProjectionAngleSquared"); //the number of frames invisible objects stay in memory - static LLCachedControl inv_obj_time(gSavedSettings,"InvisibleObjectsInMemoryTime"); + static LLCachedControl inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime"); sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum @@ -374,6 +374,11 @@ bool LLVOCacheEntry::isRecentlyVisible() const vis = (rad * rad / mSceneContrib < sBackDistanceSquared); } + if(!vis) + { + vis = (getVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame()); + } + return vis; } -- cgit v1.2.3 From 2b4dfefda216a0333426ac2a8f06d23ee6ef0aee Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 16 Oct 2013 20:59:13 -0600 Subject: more fix for SH-4552: Interesting: objects sometimes fail to load after teleport. --- indra/newview/llvocache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index f16f3507c3..89a49ff1ed 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -191,10 +191,10 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) LLViewerOctreeEntryData::setOctreeEntry(entry); } -void LLVOCacheEntry::moveTo(LLVOCacheEntry* new_entry) +void LLVOCacheEntry::moveTo(LLVOCacheEntry* new_entry, bool no_entry_move) { //copy LLViewerOctreeEntry - if(mEntry.notNull()) + if(mEntry.notNull() && !no_entry_move) { new_entry->setOctreeEntry(mEntry); mEntry = NULL; -- cgit v1.2.3 From c8228b65f8a4a94220c92d89d1529ed484f6e84a Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 17 Oct 2013 20:21:17 -0600 Subject: fix for SH-4569: Objects are not culled by size in the distance --- indra/newview/llvocache.cpp | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 89a49ff1ed..4d598c8845 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -548,10 +548,11 @@ class LLVOCacheOctreeCull : public LLViewerOctreeCull { public: LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, - const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) + const LLVector3& shift, bool use_object_cache_occlusion, F32 projection_area_cutoff, LLVOCachePartition* part) : LLViewerOctreeCull(camera), mRegionp(regionp), - mPartition(part) + mPartition(part), + mProjectionAreaCutOff(projection_area_cutoff) { mLocalShift = shift; mUseObjectCacheOcclusion = use_object_cache_occlusion; @@ -605,6 +606,14 @@ public: { res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift)); } + + if(res != 0) + { + //check if the objects projection large enough + const LLVector4a* exts = group->getObjectExtents(); + res = checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff); + } + return res; } @@ -648,6 +657,7 @@ private: LLVOCachePartition* mPartition; LLViewerRegion* mRegionp; LLVector3 mLocalShift; //shift vector from agent space to local region space. + F32 mProjectionAreaCutOff; bool mUseObjectCacheOcclusion; }; @@ -655,8 +665,8 @@ private: class LLVOCacheOctreeBackCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius) - : LLViewerOctreeCull(camera), mRegionp(regionp) + LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius, F32 projection_area_cutoff) + : LLViewerOctreeCull(camera), mRegionp(regionp), mProjectionAreaCutOff(projection_area_cutoff) { mLocalShift = shift; mSphereRadius = back_sphere_radius; @@ -671,7 +681,13 @@ public: virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { const LLVector4a* exts = group->getObjectExtents(); - return backSphereCheck(exts[0], exts[1]); + if(backSphereCheck(exts[0], exts[1])) + { + //check if the objects projection large enough + const LLVector4a* exts = group->getObjectExtents(); + return checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff); + } + return false; } virtual void processGroup(LLViewerOctreeGroup* base_group) @@ -691,9 +707,10 @@ private: F32 mSphereRadius; LLViewerRegion* mRegionp; LLVector3 mLocalShift; //shift vector from agent space to local region space. + F32 mProjectionAreaCutOff; }; -void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius) +void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius, F32 projection_area_cutoff) { if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { @@ -714,7 +731,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); - LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius); + LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius, projection_area_cutoff); culler.traverse(mOctree); mBackSlectionEnabled--; @@ -730,6 +747,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); static LLCachedControl back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); + static LLCachedControl projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF"); if(!LLViewerRegion::sVOCacheCullingEnabled) { @@ -753,6 +771,11 @@ 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; + if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) { U32 seed = llmax(mLODPeriod >> 1, (U32)4); @@ -765,7 +788,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash) { - selectBackObjects(camera, back_sphere_radius);//process back objects selection + selectBackObjects(camera, back_sphere_radius, projection_threshold);//process back objects selection return 0; //nothing changed, reduce frequency of culling } } @@ -783,7 +806,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) LLVector3 region_agent = mRegionp->getOriginAgent(); camera.calcRegionFrustumPlanes(region_agent); - LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, this); + LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, projection_threshold, this); culler.traverse(mOctree); if(mRegionp->getNumOfVisibleGroups() > 0) -- cgit v1.2.3 From 7bfacf8ca6c7bfdd9b11a2036a914c8f47058a61 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 18 Oct 2013 16:14:40 -0600 Subject: stop other cameras than the world camera to asscee object cache. --- indra/newview/llvocache.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 4d598c8845..3f2a39ba2b 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -524,9 +524,10 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) { - mCulledTime[i] = 0; - mCullHistory[i] = -1; + mCulledTime[i] = 0; } + mCullHistory = -1; + new LLVOCacheGroup(mOctree, this); } @@ -760,7 +761,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) ((LLViewerOctreeGroup*)mOctree->getListener(0))->rebound(); - if(LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_WATER0) + if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { return 0; //no need for those cameras. } @@ -776,7 +777,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f; projection_threshold *= projection_threshold; - if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic()) + if(!mCullHistory && LLViewerRegion::isViewerCameraStatic()) { U32 seed = llmax(mLODPeriod >> 1, (U32)4); if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) @@ -797,22 +798,12 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) mBackSlectionEnabled = -1; //reset it. } - if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) - { - mCullHistory[LLViewerCamera::sCurCameraID] <<= 1; - } - //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); camera.calcRegionFrustumPlanes(region_agent); LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, projection_threshold, this); - culler.traverse(mOctree); - - if(mRegionp->getNumOfVisibleGroups() > 0) - { - mCullHistory[LLViewerCamera::sCurCameraID] |= 1; - } + culler.traverse(mOctree); if(!sNeedsOcclusionCheck) { @@ -821,6 +812,12 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) return 1; } +void LLVOCachePartition::setCullHistory(BOOL has_new_object) +{ + mCullHistory <<= 1; + mCullHistory |= has_new_object; +} + void LLVOCachePartition::addOccluders(LLViewerOctreeGroup* gp) { LLVOCacheGroup* group = (LLVOCacheGroup*)gp; -- cgit v1.2.3 From e0ace6d8690b2f60fb9b359f4840081957a3ff25 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 22 Oct 2013 16:07:41 -0600 Subject: fix for various object missing bugs: SH-4552, SH-4564, SH-4573, SH-4568 --- indra/newview/llvocache.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 3f2a39ba2b..72270eec46 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -250,6 +250,7 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) if(getEntry() != NULL && isState(INACTIVE)) { updateParentBoundingInfo(entry); + resetVisible(); } } @@ -441,6 +442,7 @@ void LLVOCacheEntry::updateParentBoundingInfo() { updateParentBoundingInfo(mChildrenList[i]); } + resetVisible(); } //make the parent bounding box to include this child -- cgit v1.2.3 From 787ff3937d697526284e8d0a812a7353ad916dea Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 30 Oct 2013 11:37:53 -0600 Subject: fix for SH-4584: Interesting: objectprojectionAreaCutOFF hides large objects on adjacent regions. --- indra/newview/llvocache.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 72270eec46..b1c7423b49 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -383,20 +383,15 @@ bool LLVOCacheEntry::isRecentlyVisible() const return vis; } -void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update) +void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update) { if(!needs_update && getVisible() >= last_update) { return; //no need to update } - const LLVector4a& center = getPositionGroup(); - - LLVector4a origin; - origin.load3(camera_origin.mV); - LLVector4a lookAt; - lookAt.setSub(center, origin); + lookAt.setSub(getPositionGroup(), camera_origin); F32 squared_dist = lookAt.dot3(lookAt).getF32(); if(squared_dist > 0.f) -- cgit v1.2.3 From 960765e8c7d49a48e66f2e55e980c60645d9ca37 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 30 Oct 2013 23:17:40 -0600 Subject: more fix to reduce number of rendered triangles per frame. --- indra/newview/llvocache.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index b1c7423b49..70b65f14be 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -358,26 +358,34 @@ void LLVOCacheEntry::updateDebugSettings() sBackAngleTanSquared = squared_back_angle; } -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; -- cgit v1.2.3 From ccb921b287b14129918c07072f57078c69ca7e65 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 31 Oct 2013 15:10:10 -0600 Subject: more fix for performance regression. --- indra/newview/llvocache.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 70b65f14be..be7ff00c05 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -840,6 +840,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]); @@ -864,7 +868,7 @@ void LLVOCachePartition::resetOccluders() for(std::set::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; -- cgit v1.2.3 From 463a8930c8bddd8740478f6400561a48220ee584 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 6 Nov 2013 09:42:06 -0700 Subject: re-organize the code of processing the debug setting "ObjectProjectionAreaCutOff" --- indra/newview/llvocache.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index be7ff00c05..d0061fc777 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -358,6 +358,19 @@ void LLVOCacheEntry::updateDebugSettings() sBackAngleTanSquared = squared_back_angle; } +//static +F32 LLVOCacheEntry::getSquaredObjectScreenAreaThreshold() +{ + static LLCachedControl projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOff"); + + //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::isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold) { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup(); @@ -752,8 +765,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); - static LLCachedControl back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); - static LLCachedControl projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF"); + static LLCachedControl back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); if(!LLViewerRegion::sVOCacheCullingEnabled) { @@ -778,10 +790,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); -- cgit v1.2.3 From 2cb781705e56e31e11c4c37891b2ac86326aa411 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 6 Nov 2013 10:18:06 -0700 Subject: remove some unused debug settings. --- indra/newview/llvocache.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index d0061fc777..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,21 +339,10 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const //static void LLVOCacheEntry::updateDebugSettings() { - //distance to keep objects = back_dist_factor * draw_distance - static LLCachedControl back_dist_factor(gSavedSettings,"BackDistanceFactor"); - - //squared tan(projection angle of the bbox), default is 10 (degree) - static LLCachedControl squared_back_angle(gSavedSettings,"BackProjectionAngleSquared"); - //the number of frames invisible objects stay in memory static LLCachedControl inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime"); sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum - - sBackDistanceSquared = back_dist_factor * gAgentCamera.mDrawDistance; - sBackDistanceSquared *= sBackDistanceSquared; - - sBackAngleTanSquared = squared_back_angle; } //static -- cgit v1.2.3 From d71cafa4bcecb311bce626a15dd185e4750994ea Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 6 Nov 2013 20:05:28 -0800 Subject: final settings tweaks renamed BackShpereCullingRadius to BackSphereCullingRadius --- indra/newview/llvocache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 2ff2d0f341..f2c048cd34 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -752,7 +752,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); - static LLCachedControl back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); + static LLCachedControl back_sphere_radius(gSavedSettings,"BackSphereCullingRadius"); if(!LLViewerRegion::sVOCacheCullingEnabled) { -- cgit v1.2.3 From 83c2098fb99c4a4d33dfa5f4a71ab64ca39b547f Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 11 Nov 2013 14:50:32 -0700 Subject: fix for SH-4607: Create new object cache tuning parameters --- indra/newview/llvocache.cpp | 84 +++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 22 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index f2c048cd34..3bacf5c319 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -35,7 +35,12 @@ #include "pipeline.h" #include "llagentcamera.h" +//static variables U32 LLVOCacheEntry::sMinFrameRange = 0; +F32 LLVOCacheEntry::sNearRadiusSquared = 1.0f; +F32 LLVOCacheEntry::sRearFarRadius = 1.0f; +F32 LLVOCacheEntry::sFrontPixelThreshold = 1.0f; +F32 LLVOCacheEntry::sRearPixelThreshold = 1.0f; BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE; BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) @@ -341,18 +346,46 @@ void LLVOCacheEntry::updateDebugSettings() { //the number of frames invisible objects stay in memory static LLCachedControl inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime"); - sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum + + //min radius: all objects within this radius remain loaded in memory + static LLCachedControl min_radius(gSavedSettings,"SceneLoadMinRadius"); + sNearRadiusSquared = llmin((F32)min_radius, gAgentCamera.mDrawDistance); //can not exceed the draw distance + sNearRadiusSquared *= sNearRadiusSquared; + sNearRadiusSquared = llmax(sNearRadiusSquared, 1.f); //minimum value is 1.0m + + //objects within the view frustum whose visible area is greater than this threshold will be loaded + static LLCachedControl front_pixel_threshold(gSavedSettings,"SceneLoadFrontPixelThreshold"); + sFrontPixelThreshold = front_pixel_threshold; + + //objects out of the view frustum whose visible area is greater than this threshold will remain loaded + static LLCachedControl rear_pixel_threshold(gSavedSettings,"SceneLoadRearPixelThreshold"); + sRearPixelThreshold = rear_pixel_threshold; + sRearPixelThreshold = llmax(sRearPixelThreshold, sFrontPixelThreshold); //can not be smaller than sFrontPixelThreshold. + + // a percentage of draw distance beyond which all objects outside of view frustum will be unloaded, regardless of pixel threshold + static LLCachedControl rear_max_radius_frac(gSavedSettings,"SceneLoadRearMaxRadiusFraction"); + sRearFarRadius = llmax(rear_max_radius_frac * gAgentCamera.mDrawDistance / 100.f, 1.0f); //minimum value is 1.0m + sRearFarRadius = llmax(sRearFarRadius, (F32)min_radius); //can not be less than "SceneLoadMinRadius". + sRearFarRadius = llmin(sRearFarRadius, gAgentCamera.mDrawDistance); //can not be more than the draw distance. } //static -F32 LLVOCacheEntry::getSquaredObjectScreenAreaThreshold() +F32 LLVOCacheEntry::getSquaredPixelThreshold(bool is_front) { - static LLCachedControl projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOff"); + F32 threshold; + if(is_front) + { + threshold = sFrontPixelThreshold; + } + else + { + threshold = sRearPixelThreshold; + } //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; + F32 projection_threshold = pixel_meter_ratio > 0.f ? threshold / pixel_meter_ratio : 0.f; projection_threshold *= projection_threshold; return projection_threshold; @@ -402,7 +435,13 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool lookAt.setSub(getPositionGroup(), camera_origin); F32 squared_dist = lookAt.dot3(lookAt).getF32(); - if(squared_dist > 0.f) + if(squared_dist < sNearRadiusSquared) + { + //nearby objects, set a large number + const F32 LARGE_SCENE_CONTRIBUTION = 1000.f; //a large number to force to load the object. + mSceneContrib = LARGE_SCENE_CONTRIBUTION; + } + else { F32 rad = getBinRadius(); mSceneContrib = rad * rad / squared_dist; @@ -554,14 +593,15 @@ class LLVOCacheOctreeCull : public LLViewerOctreeCull { public: LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, - const LLVector3& shift, bool use_object_cache_occlusion, F32 projection_area_cutoff, LLVOCachePartition* part) + const LLVector3& shift, bool use_object_cache_occlusion, F32 pixel_threshold, LLVOCachePartition* part) : LLViewerOctreeCull(camera), mRegionp(regionp), mPartition(part), - mProjectionAreaCutOff(projection_area_cutoff) + mPixelThreshold(pixel_threshold) { mLocalShift = shift; mUseObjectCacheOcclusion = use_object_cache_occlusion; + mSquaredNearRadius = LLVOCacheEntry::sNearRadiusSquared; } virtual bool earlyFail(LLViewerOctreeGroup* base_group) @@ -617,7 +657,7 @@ public: { //check if the objects projection large enough const LLVector4a* exts = group->getObjectExtents(); - res = checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff); + res = checkProjectionArea(exts[0], exts[1], mLocalShift, mPixelThreshold, mSquaredNearRadius); } return res; @@ -663,7 +703,8 @@ private: LLVOCachePartition* mPartition; LLViewerRegion* mRegionp; LLVector3 mLocalShift; //shift vector from agent space to local region space. - F32 mProjectionAreaCutOff; + F32 mPixelThreshold; + F32 mSquaredNearRadius; bool mUseObjectCacheOcclusion; }; @@ -671,11 +712,11 @@ private: class LLVOCacheOctreeBackCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius, F32 projection_area_cutoff) - : LLViewerOctreeCull(camera), mRegionp(regionp), mProjectionAreaCutOff(projection_area_cutoff) + LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 pixel_threshold) + : LLViewerOctreeCull(camera), mRegionp(regionp), mPixelThreshold(pixel_threshold) { mLocalShift = shift; - mSphereRadius = back_sphere_radius; + mSphereRadius = LLVOCacheEntry::sRearFarRadius; } virtual S32 frustumCheck(const LLViewerOctreeGroup* group) @@ -691,7 +732,7 @@ public: { //check if the objects projection large enough const LLVector4a* exts = group->getObjectExtents(); - return checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff); + return checkProjectionArea(exts[0], exts[1], mLocalShift, mPixelThreshold, mSphereRadius * mSphereRadius); } return false; } @@ -713,10 +754,10 @@ private: F32 mSphereRadius; LLViewerRegion* mRegionp; LLVector3 mLocalShift; //shift vector from agent space to local region space. - F32 mProjectionAreaCutOff; + F32 mPixelThreshold; }; -void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius, F32 projection_area_cutoff) +void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 pixel_threshold) { if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { @@ -737,7 +778,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); - LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius, projection_area_cutoff); + LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, pixel_threshold); culler.traverse(mOctree); mBackSlectionEnabled--; @@ -752,7 +793,6 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); - static LLCachedControl back_sphere_radius(gSavedSettings,"BackSphereCullingRadius"); if(!LLViewerRegion::sVOCacheCullingEnabled) { @@ -776,9 +816,6 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); - //object projected area threshold - F32 projection_threshold = LLVOCacheEntry::getSquaredObjectScreenAreaThreshold(); - if(!mCullHistory && LLViewerRegion::isViewerCameraStatic()) { U32 seed = llmax(mLODPeriod >> 1, (U32)4); @@ -791,7 +828,8 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash) { - selectBackObjects(camera, back_sphere_radius, projection_threshold);//process back objects selection + mFrontCull = FALSE; + selectBackObjects(camera, LLVOCacheEntry::getSquaredPixelThreshold(mFrontCull));//process back objects selection return 0; //nothing changed, reduce frequency of culling } } @@ -804,7 +842,9 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) LLVector3 region_agent = mRegionp->getOriginAgent(); camera.calcRegionFrustumPlanes(region_agent); - LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, projection_threshold, this); + mFrontCull = TRUE; + LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, + LLVOCacheEntry::getSquaredPixelThreshold(mFrontCull), this); culler.traverse(mOctree); if(!sNeedsOcclusionCheck) -- cgit v1.2.3 From 58ee2a30ce5fb83186392693c7b014aa667e02cf Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 13 Nov 2013 09:40:48 -0700 Subject: more fix for SH-4607: Create new object cache tuning parameters --- indra/newview/llvocache.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 3bacf5c319..789321e523 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -391,7 +391,7 @@ F32 LLVOCacheEntry::getSquaredPixelThreshold(bool is_front) return projection_threshold; } -bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold) +bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 dist_threshold) { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup(); if(!group) @@ -412,19 +412,17 @@ bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 squared_d if(!vis && !mParentID) { 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); + dist_threshold += getBinRadius(); + + vis = (lookAt.dot3(lookAt).getF32() < dist_threshold * dist_threshold); } return vis; } -void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update) +void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update, F32 dist_threshold) { if(!needs_update && getVisible() >= last_update) { @@ -444,7 +442,17 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool else { F32 rad = getBinRadius(); - mSceneContrib = rad * rad / squared_dist; + dist_threshold += rad; + dist_threshold *= dist_threshold; + + if(squared_dist < dist_threshold) + { + mSceneContrib = rad * rad / squared_dist; + } + else + { + mSceneContrib = 0.f; //out of draw distance, not to load + } } setVisible(); -- cgit v1.2.3 From 58b153cf878370643bd61914538a80e6512c7e5c Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 13 Nov 2013 09:51:01 -0700 Subject: fix for SH-4608: Interesting: minimap shows objects loading/uinloading behind your camera when camera is rotated --- indra/newview/llvocache.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 789321e523..92a8f7b18e 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -70,7 +70,8 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mState(INACTIVE), mSceneContrib(0.f), mTouched(TRUE), - mParentID(0) + mParentID(0), + mBSphereRadius(-1.0f) { mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); @@ -90,7 +91,8 @@ LLVOCacheEntry::LLVOCacheEntry() mState(INACTIVE), mSceneContrib(0.f), mTouched(TRUE), - mParentID(0) + mParentID(0), + mBSphereRadius(-1.0f) { mDP.assignBuffer(mBuffer, 0); } @@ -103,7 +105,8 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mState(INACTIVE), mSceneContrib(0.f), mTouched(FALSE), - mParentID(0) + mParentID(0), + mBSphereRadius(-1.0f) { S32 size = -1; BOOL success; @@ -391,7 +394,7 @@ F32 LLVOCacheEntry::getSquaredPixelThreshold(bool is_front) return projection_threshold; } -bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 dist_threshold) +bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, const LLVector4a& local_camera_origin, F32 dist_threshold) { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup(); if(!group) @@ -413,8 +416,16 @@ bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 dist_thre { LLVector4a lookAt; - lookAt.setSub(getPositionGroup(), camera_origin); - dist_threshold += getBinRadius(); + if(mBSphereRadius > 0.f) + { + lookAt.setSub(mBSphereCenter, local_camera_origin); + dist_threshold += mBSphereRadius; + } + else + { + lookAt.setSub(getPositionGroup(), camera_origin); + dist_threshold += getBinRadius(); + } vis = (lookAt.dot3(lookAt).getF32() < dist_threshold * dist_threshold); } @@ -458,6 +469,12 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool setVisible(); } +void LLVOCacheEntry::saveBoundingSphere() +{ + mBSphereCenter = getPositionGroup(); + mBSphereRadius = getBinRadius(); +} + void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scale) { LLVector4a center, newMin, newMax; -- cgit v1.2.3 From 6a0a5c18e33be6889f12a9954861c446acb9113b Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 13 Nov 2013 22:38:19 -0700 Subject: more fix for SH-4607: Create new object cache tuning parameters fix remote objects not showing up. --- indra/newview/llvocache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 92a8f7b18e..8c28d9e440 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -865,7 +865,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); - camera.calcRegionFrustumPlanes(region_agent); + camera.calcRegionFrustumPlanes(region_agent, gAgentCamera.mDrawDistance); mFrontCull = TRUE; LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, -- cgit v1.2.3 From 67ffa86817498028685e8cfb1bdc05d7ab204010 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 14 Nov 2013 11:10:19 -0700 Subject: change the calculation method for object cache view culling. --- indra/newview/llvocache.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 8c28d9e440..31722507ce 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -654,29 +654,30 @@ public: virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { -#if 1 +#if 0 S32 res = AABBInRegionFrustumGroupBounds(group); #else S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); -#endif if (res != 0) { res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift)); } +#endif + return res; } virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { -#if 1 +#if 0 S32 res = AABBInRegionFrustumObjectBounds(group); #else S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); -#endif if (res != 0) { res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift)); } +#endif if(res != 0) { -- cgit v1.2.3 From 7c7c043e38de95cc96554ebc6913973f43eed980 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 14 Nov 2013 18:07:40 -0700 Subject: fix for SH-4609: Interesting: Occluded objects are loaded at login --- indra/newview/llvocache.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 31722507ce..65da1e854d 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -412,7 +412,7 @@ bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, const LLVecto } //within the back sphere - if(!vis && !mParentID) + if(!vis && !mParentID && !group->isOcclusionState(LLOcclusionCullingGroup::OCCLUDED)) { LLVector4a lookAt; @@ -738,12 +738,28 @@ private: class LLVOCacheOctreeBackCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 pixel_threshold) - : LLViewerOctreeCull(camera), mRegionp(regionp), mPixelThreshold(pixel_threshold) + LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 pixel_threshold, bool use_occlusion) + : LLViewerOctreeCull(camera), mRegionp(regionp), mPixelThreshold(pixel_threshold), mUseObjectCacheOcclusion(use_occlusion) { mLocalShift = shift; mSphereRadius = LLVOCacheEntry::sRearFarRadius; } + + virtual bool earlyFail(LLViewerOctreeGroup* base_group) + { + if( mUseObjectCacheOcclusion && + base_group->getOctreeNode()->getParent()) //never occlusion cull the root node + { + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group; + + if (group->getOcclusionState() > 0) //occlusion state is not clear. + { + return true; + } + } + + return false; + } virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { @@ -781,9 +797,10 @@ private: LLViewerRegion* mRegionp; LLVector3 mLocalShift; //shift vector from agent space to local region space. F32 mPixelThreshold; + bool mUseObjectCacheOcclusion; }; -void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 pixel_threshold) +void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 pixel_threshold, bool use_occlusion) { if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { @@ -804,7 +821,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 pixel_threshold //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); - LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, pixel_threshold); + LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, pixel_threshold, use_occlusion); culler.traverse(mOctree); mBackSlectionEnabled--; @@ -855,7 +872,10 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash) { mFrontCull = FALSE; - selectBackObjects(camera, LLVOCacheEntry::getSquaredPixelThreshold(mFrontCull));//process back objects selection + + //process back objects selection + selectBackObjects(camera, LLVOCacheEntry::getSquaredPixelThreshold(mFrontCull), + do_occlusion && use_object_cache_occlusion); return 0; //nothing changed, reduce frequency of culling } } -- cgit v1.2.3 From f89b5d2f7467710286a57e20400bc588cdaf98bc Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 21 Nov 2013 17:34:27 -0700 Subject: combine the visiblities of octree group and object cache entry for visiblity check --- indra/newview/llvocache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 65da1e854d..05d61fab49 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -408,7 +408,8 @@ bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, const LLVecto //not ready to remove if(!vis) { - vis = (group->getAnyVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame()); + S32 cur_vis = llmax(group->getAnyVisible(), (S32)getVisible()); + vis = (cur_vis + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame()); } //within the back sphere -- cgit v1.2.3 From 29476d29c4c78a6417c45090bdc6ea14c8251d73 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 3 Dec 2013 10:52:22 -0800 Subject: SH-4606 FIX Interesting: Small objects do not load until they are very close. increased SceneLoadMinRadius to 32 changes logic so that falloff starts at SceneLoadMinRadius added timing to pixel threshold calculation --- indra/newview/llvocache.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 05d61fab49..956f9a2667 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -37,7 +37,7 @@ //static variables U32 LLVOCacheEntry::sMinFrameRange = 0; -F32 LLVOCacheEntry::sNearRadiusSquared = 1.0f; +F32 LLVOCacheEntry::sNearRadius = 1.0f; F32 LLVOCacheEntry::sRearFarRadius = 1.0f; F32 LLVOCacheEntry::sFrontPixelThreshold = 1.0f; F32 LLVOCacheEntry::sRearPixelThreshold = 1.0f; @@ -353,9 +353,8 @@ void LLVOCacheEntry::updateDebugSettings() //min radius: all objects within this radius remain loaded in memory static LLCachedControl min_radius(gSavedSettings,"SceneLoadMinRadius"); - sNearRadiusSquared = llmin((F32)min_radius, gAgentCamera.mDrawDistance); //can not exceed the draw distance - sNearRadiusSquared *= sNearRadiusSquared; - sNearRadiusSquared = llmax(sNearRadiusSquared, 1.f); //minimum value is 1.0m + sNearRadius = llmin((F32)min_radius, gAgentCamera.mDrawDistance); //can not exceed the draw distance + sNearRadius = llmax(sNearRadius, 1.f); //minimum value is 1.0m //objects within the view frustum whose visible area is greater than this threshold will be loaded static LLCachedControl front_pixel_threshold(gSavedSettings,"SceneLoadFrontPixelThreshold"); @@ -434,8 +433,11 @@ bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, const LLVecto return vis; } +static LLTrace::BlockTimerStatHandle sSceneContributionCalc("Calculate scene contribution", "Calculates relative importance of object to scene, to control object load from cache"); + void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update, F32 dist_threshold) { + LL_RECORD_BLOCK_TIME(sSceneContributionCalc); if(!needs_update && getVisible() >= last_update) { return; //no need to update @@ -443,9 +445,9 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool LLVector4a lookAt; lookAt.setSub(getPositionGroup(), camera_origin); - F32 squared_dist = lookAt.dot3(lookAt).getF32(); + F32 distance = lookAt.getLength3().getF32(); - if(squared_dist < sNearRadiusSquared) + if(distance <= sNearRadius) { //nearby objects, set a large number const F32 LARGE_SCENE_CONTRIBUTION = 1000.f; //a large number to force to load the object. @@ -453,13 +455,14 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool } else { + distance -= sNearRadius; + F32 rad = getBinRadius(); dist_threshold += rad; - dist_threshold *= dist_threshold; - if(squared_dist < dist_threshold) + if(distance < dist_threshold) { - mSceneContrib = rad * rad / squared_dist; + mSceneContrib = (rad * rad) / (distance * distance); } else { @@ -627,7 +630,7 @@ public: { mLocalShift = shift; mUseObjectCacheOcclusion = use_object_cache_occlusion; - mSquaredNearRadius = LLVOCacheEntry::sNearRadiusSquared; + mNearRadius = LLVOCacheEntry::sNearRadius; } virtual bool earlyFail(LLViewerOctreeGroup* base_group) @@ -684,7 +687,7 @@ public: { //check if the objects projection large enough const LLVector4a* exts = group->getObjectExtents(); - res = checkProjectionArea(exts[0], exts[1], mLocalShift, mPixelThreshold, mSquaredNearRadius); + res = checkProjectionArea(exts[0], exts[1], mLocalShift, mPixelThreshold, mNearRadius); } return res; @@ -731,7 +734,7 @@ private: LLViewerRegion* mRegionp; LLVector3 mLocalShift; //shift vector from agent space to local region space. F32 mPixelThreshold; - F32 mSquaredNearRadius; + F32 mNearRadius; bool mUseObjectCacheOcclusion; }; @@ -775,7 +778,7 @@ public: { //check if the objects projection large enough const LLVector4a* exts = group->getObjectExtents(); - return checkProjectionArea(exts[0], exts[1], mLocalShift, mPixelThreshold, mSphereRadius * mSphereRadius); + return checkProjectionArea(exts[0], exts[1], mLocalShift, mPixelThreshold, mSphereRadius); } return false; } -- cgit v1.2.3 From 3cb64c5038b7cde8bd44ec3a029d477e415085ee Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 3 Dec 2013 15:52:36 -0800 Subject: SH-4606 FIX Interesting: Small objects do not load until they are very close. changed culling to use inverse distance to calculate solid angle, not distance squared --- indra/newview/llvocache.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 956f9a2667..515cc003c0 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -433,11 +433,8 @@ bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, const LLVecto return vis; } -static LLTrace::BlockTimerStatHandle sSceneContributionCalc("Calculate scene contribution", "Calculates relative importance of object to scene, to control object load from cache"); - -void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update, F32 dist_threshold) +void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update, F32 max_dist) { - LL_RECORD_BLOCK_TIME(sSceneContributionCalc); if(!needs_update && getVisible() >= last_update) { return; //no need to update @@ -446,8 +443,9 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool LLVector4a lookAt; lookAt.setSub(getPositionGroup(), camera_origin); F32 distance = lookAt.getLength3().getF32(); + distance -= sNearRadius; - if(distance <= sNearRadius) + if(distance <= 0.f) { //nearby objects, set a large number const F32 LARGE_SCENE_CONTRIBUTION = 1000.f; //a large number to force to load the object. @@ -455,14 +453,12 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool } else { - distance -= sNearRadius; - F32 rad = getBinRadius(); - dist_threshold += rad; + max_dist += rad; - if(distance < dist_threshold) + if(distance + sNearRadius < max_dist) { - mSceneContrib = (rad * rad) / (distance * distance); + mSceneContrib = (rad * rad) / distance; } else { -- cgit v1.2.3 From 10ae6a779e6726da24acb0ae60bb8f430daf9bdb Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 6 Jan 2014 12:28:36 -0700 Subject: fix for SH-4656: crash at LLVOCacheEntry::updateParentBoundingInfo() line 510 --- indra/newview/llvocache.cpp | 87 +++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 39 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 515cc003c0..aa3594638a 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -69,7 +69,7 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mCRCChangeCount(0), mState(INACTIVE), mSceneContrib(0.f), - mTouched(TRUE), + mValid(TRUE), mParentID(0), mBSphereRadius(-1.0f) { @@ -90,7 +90,7 @@ LLVOCacheEntry::LLVOCacheEntry() mBuffer(NULL), mState(INACTIVE), mSceneContrib(0.f), - mTouched(TRUE), + mValid(TRUE), mParentID(0), mBSphereRadius(-1.0f) { @@ -104,7 +104,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mUpdateFlags(-1), mState(INACTIVE), mSceneContrib(0.f), - mTouched(FALSE), + mValid(FALSE), mParentID(0), mBSphereRadius(-1.0f) { @@ -169,14 +169,29 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mCRCChangeCount = 0; mBuffer = NULL; mEntry = NULL; - mState = 0; + mState = INACTIVE; } } LLVOCacheEntry::~LLVOCacheEntry() { mDP.freeBuffer(); - //llassert(mState == INACTIVE); +} + +void LLVOCacheEntry::updateEntry(U32 crc, LLDataPackerBinaryBuffer &dp) +{ + if(mCRC != crc) + { + mCRC = crc; + mCRCChangeCount++; + } + + mDP.freeBuffer(); + + llassert_always(dp.getBufferSize() > 0); + mBuffer = new U8[dp.getBufferSize()]; + mDP.assignBuffer(mBuffer, dp.getBufferSize()); + mDP = dp; } //virtual @@ -197,27 +212,19 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) LLViewerOctreeEntryData::setOctreeEntry(entry); } -void LLVOCacheEntry::moveTo(LLVOCacheEntry* new_entry, bool no_entry_move) +void LLVOCacheEntry::setState(U32 state) { - //copy LLViewerOctreeEntry - if(mEntry.notNull() && !no_entry_move) - { - new_entry->setOctreeEntry(mEntry); - mEntry = NULL; - } - - //copy children - S32 num_children = getNumOfChildren(); - for(S32 i = 0; i < num_children; i++) + if(state > LOW_BITS) //special states { - new_entry->addChild(getChild(i)); + mState |= (HIGH_BITS & state); + return; } - mChildrenList.clear(); -} -void LLVOCacheEntry::setState(U32 state) -{ - mState = state; + // + //otherwise LOW_BITS states + // + clearState(LOW_BITS); + mState |= (LOW_BITS & state); if(getState() == ACTIVE) { @@ -249,8 +256,8 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) { return; } - - mChildrenList.push_back(entry); + + mChildrenList.insert(entry); //update parent bbox if(getEntry() != NULL && isState(INACTIVE)) @@ -262,24 +269,27 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) void LLVOCacheEntry::removeChild(LLVOCacheEntry* entry) { - for(S32 i = 0; i < mChildrenList.size(); i++) + entry->setParentID(0); + + vocache_entry_set_t::iterator iter = mChildrenList.find(entry); + if(iter != mChildrenList.end()) { - if(mChildrenList[i] == entry) - { - entry->setParentID(0); - mChildrenList[i] = mChildrenList[mChildrenList.size() - 1]; - mChildrenList.pop_back(); - } + mChildrenList.erase(iter); } } -void LLVOCacheEntry::removeAllChildren() +//remove the first child, and return it. +LLVOCacheEntry* LLVOCacheEntry::getChild() { - for(S32 i = 0; i < mChildrenList.size(); i++) + LLVOCacheEntry* child = NULL; + vocache_entry_set_t::iterator iter = mChildrenList.begin(); + if(iter != mChildrenList.end()) { - mChildrenList[i]->setParentID(0); + child = *iter; + mChildrenList.erase(iter); } - mChildrenList.clear(); + + return child; } LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP() @@ -295,7 +305,6 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP() void LLVOCacheEntry::recordHit() { - setTouched(); mHitCount++; } @@ -505,9 +514,9 @@ void LLVOCacheEntry::updateParentBoundingInfo() return; } - for(S32 i = 0; i < mChildrenList.size(); i++) + for(vocache_entry_set_t::iterator iter = mChildrenList.begin(); iter != mChildrenList.end(); ++iter) { - updateParentBoundingInfo(mChildrenList[i]); + updateParentBoundingInfo(*iter); } resetVisible(); } @@ -1463,7 +1472,7 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); success && iter != cache_entry_map.end(); ++iter) { - if(!removal_enabled || iter->second->isTouched()) + if(!removal_enabled || iter->second->isValid()) { success = iter->second->writeToFile(&apr_file) ; if(!success) -- cgit v1.2.3 From 87f852ee67c75ac415ce716157bdd9ba94c60441 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 9 Jan 2014 21:17:49 -0700 Subject: fix for SH-4659:crash at LLOcclusionCullingGroup::doOcclusion line 1150 --- indra/newview/llvocache.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index aa3594638a..8af6d74ad7 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -609,11 +609,18 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) new LLVOCacheGroup(mOctree, this); } -void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) +bool LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) { llassert(entry->hasVOCacheEntry()); + if(!llfinite(entry->getBinRadius()) || !entry->getPositionGroup().isFinite3()) + { + return false; //data corrupted + } + mOctree->insert(entry); + + return true; } void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) -- cgit v1.2.3 From b49170b732e6e4b2cf11b40c12b3d75a8709cf5c Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 31 Jan 2014 18:24:55 -0700 Subject: fix some flaws for memory corruption --- indra/newview/llvocache.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 8af6d74ad7..0ff38ebdc8 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -194,6 +194,31 @@ void LLVOCacheEntry::updateEntry(U32 crc, LLDataPackerBinaryBuffer &dp) mDP = dp; } +void LLVOCacheEntry::setParentID(U32 id) +{ + if(mParentID != id) + { + removeAllChildren(); + mParentID = id; + } +} + +void LLVOCacheEntry::removeAllChildren() +{ + if(mChildrenList.empty()) + { + return; + } + + for(vocache_entry_set_t::iterator iter = mChildrenList.begin(); iter != mChildrenList.end(); ++iter) + { + *iter->setParentID(0); + } + mChildrenList.clear(); + + return; +} + //virtual void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) { -- cgit v1.2.3 From 2ab11c8e34f2349500aef76cd8372ca889020728 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 31 Jan 2014 18:51:50 -0700 Subject: fix some compiling errors --- indra/newview/llvocache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 0ff38ebdc8..6cf6028ae0 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -212,7 +212,7 @@ void LLVOCacheEntry::removeAllChildren() for(vocache_entry_set_t::iterator iter = mChildrenList.begin(); iter != mChildrenList.end(); ++iter) { - *iter->setParentID(0); + (*iter)->setParentID(0); } mChildrenList.clear(); -- cgit v1.2.3 From cd9871197c55395f6943c2911e9a7991540adfa4 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 5 Feb 2014 15:54:40 -0700 Subject: fix a memory crash caused by accessing deleted pointers. --- indra/newview/llvocache.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 6cf6028ae0..26f6987916 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -589,14 +589,14 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) //------------------------------------------------------------------- LLVOCacheGroup::~LLVOCacheGroup() { - for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) - { - if(mOcclusionState[i] & ACTIVE_OCCLUSION) - { - ((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this); - break; - } - } + //for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + //{ + // if(mOcclusionState[i] & ACTIVE_OCCLUSION) + // { + // ((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this); + // break; + // } + //} } //virtual @@ -979,7 +979,11 @@ void LLVOCachePartition::processOccluders(LLCamera* camera) group->doOcclusion(camera, &shift); group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); } - } + } + + //safe to clear mOccludedGroups here because only the world camera accesses it. + mOccludedGroups.clear(); + sNeedsOcclusionCheck = FALSE; } void LLVOCachePartition::resetOccluders() -- cgit v1.2.3 From b5389618f3744464760bbe1a54b49750d211a1ac Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 6 Feb 2014 10:15:00 -0700 Subject: more fix for a memory crash caused by accessing deleted pointers. --- indra/newview/llvocache.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 26f6987916..2176ec9c9c 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -589,14 +589,10 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) //------------------------------------------------------------------- LLVOCacheGroup::~LLVOCacheGroup() { - //for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) - //{ - // if(mOcclusionState[i] & ACTIVE_OCCLUSION) - // { - // ((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this); - // break; - // } - //} + if(mOcclusionState[LLViewerCamera::CAMERA_WORLD] & ACTIVE_OCCLUSION) + { + ((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this); + } } //virtual -- cgit v1.2.3 From f5a63ed31e499903f3d6ff5009d20f980b4fe860 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 12 Feb 2014 18:14:48 -0700 Subject: reduce peak memory usage to fix SH-4574: Interesting: viewer crash in LLJoint::setScale --- indra/newview/llvocache.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 2176ec9c9c..0f29e9cfa2 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -34,6 +34,7 @@ #include "llviewerregion.h" #include "pipeline.h" #include "llagentcamera.h" +#include "llmemory.h" //static variables U32 LLVOCacheEntry::sMinFrameRange = 0; @@ -381,6 +382,13 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const //static void LLVOCacheEntry::updateDebugSettings() { + static LLFrameTimer timer; + if(timer.getElapsedTimeF32() < 1.0f) //update frequency once per second. + { + return; + } + timer.reset(); + //the number of frames invisible objects stay in memory static LLCachedControl inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime"); sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum @@ -404,6 +412,23 @@ void LLVOCacheEntry::updateDebugSettings() sRearFarRadius = llmax(rear_max_radius_frac * gAgentCamera.mDrawDistance / 100.f, 1.0f); //minimum value is 1.0m sRearFarRadius = llmax(sRearFarRadius, (F32)min_radius); //can not be less than "SceneLoadMinRadius". sRearFarRadius = llmin(sRearFarRadius, gAgentCamera.mDrawDistance); //can not be more than the draw distance. + + //make the above parameters adaptive to memory usage + //starts to put restrictions from 750MB, apply tightest restrictions when hits 1GB + const U32 low_bound = 750 * 1024; //KB + const U32 high_bound = 1024 * 1024; //KB + + LLMemory::updateMemoryInfo() ; + U32 allocated_mem = LLMemory::getAllocatedMemKB().value(); + if(allocated_mem < low_bound) + { + return; + } + F32 adjust_factor = llmax(0.f, (F32)(high_bound - allocated_mem) / (high_bound - low_bound)); + + sRearFarRadius = llmin(adjust_factor * sRearFarRadius, 96.f); //[0.f, 96.f] + sMinFrameRange = (U32)llclamp(adjust_factor * sMinFrameRange, 10.f, 64.f); //[10, 64] + sNearRadius = llmax(adjust_factor * sNearRadius, 1.0f); } //static -- cgit v1.2.3 From 6661628d5c68855ddffc54a3f2578f93ada84de1 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 12 Feb 2014 20:50:32 -0700 Subject: add two debug settings: "SceneLoadLowMemoryBound" and "SceneLoadHighMemoryBound" --- indra/newview/llvocache.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 0f29e9cfa2..fd1d57a9d0 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -414,17 +414,18 @@ void LLVOCacheEntry::updateDebugSettings() sRearFarRadius = llmin(sRearFarRadius, gAgentCamera.mDrawDistance); //can not be more than the draw distance. //make the above parameters adaptive to memory usage - //starts to put restrictions from 750MB, apply tightest restrictions when hits 1GB - const U32 low_bound = 750 * 1024; //KB - const U32 high_bound = 1024 * 1024; //KB - + //starts to put restrictions from low_mem_bound_MB, apply tightest restrictions when hits high_mem_bound_MB + static LLCachedControl low_mem_bound_MB(gSavedSettings,"SceneLoadLowMemoryBound"); + static LLCachedControl high_mem_bound_MB(gSavedSettings,"SceneLoadHighMemoryBound"); + LLMemory::updateMemoryInfo() ; U32 allocated_mem = LLMemory::getAllocatedMemKB().value(); - if(allocated_mem < low_bound) + allocated_mem /= 1024; //convert to MB. + if(allocated_mem < low_mem_bound_MB) { return; } - F32 adjust_factor = llmax(0.f, (F32)(high_bound - allocated_mem) / (high_bound - low_bound)); + F32 adjust_factor = llmax(0.f, (F32)(high_mem_bound_MB - allocated_mem) / (high_mem_bound_MB - low_mem_bound_MB)); sRearFarRadius = llmin(adjust_factor * sRearFarRadius, 96.f); //[0.f, 96.f] sMinFrameRange = (U32)llclamp(adjust_factor * sMinFrameRange, 10.f, 64.f); //[10, 64] -- cgit v1.2.3