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/llvieweroctree.cpp | 704 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 704 insertions(+) create mode 100644 indra/newview/llvieweroctree.cpp (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp new file mode 100644 index 0000000000..05f977036c --- /dev/null +++ b/indra/newview/llvieweroctree.cpp @@ -0,0 +1,704 @@ +/** + * @file llvieweroctree.cpp + * @brief LLViewerOctreeGroup class implementation and supporting functions + * + * $LicenseInfo:firstyear=2003&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llvieweroctree.h" + +//----------------------------------------------------------------------------------- +//static variables definitions +//----------------------------------------------------------------------------------- +U32 LLViewerOctreeEntryData::sCurVisible = 0; + +//----------------------------------------------------------------------------------- +//some global functions definitions +//----------------------------------------------------------------------------------- +S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad) +{ + return AABBSphereIntersectR2(min, max, origin, rad*rad); +} + +S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &r) +{ + F32 d = 0.f; + F32 t; + + if ((min-origin).magVecSquared() < r && + (max-origin).magVecSquared() < r) + { + return 2; + } + + for (U32 i = 0; i < 3; i++) + { + if (origin.mV[i] < min.mV[i]) + { + t = min.mV[i] - origin.mV[i]; + d += t*t; + } + else if (origin.mV[i] > max.mV[i]) + { + t = origin.mV[i] - max.mV[i]; + d += t*t; + } + + if (d > r) + { + return 0; + } + } + + return 1; +} + + +S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad) +{ + return AABBSphereIntersectR2(min, max, origin, rad*rad); +} + +S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &r) +{ + F32 d = 0.f; + F32 t; + + LLVector4a origina; + origina.load3(origin.mV); + + LLVector4a v; + v.setSub(min, origina); + + if (v.dot3(v) < r) + { + v.setSub(max, origina); + if (v.dot3(v) < r) + { + return 2; + } + } + + + for (U32 i = 0; i < 3; i++) + { + if (origin.mV[i] < min[i]) + { + t = min[i] - origin.mV[i]; + d += t*t; + } + else if (origin.mV[i] > max[i]) + { + t = origin.mV[i] - max[i]; + d += t*t; + } + + if (d > r) + { + return 0; + } + } + + return 1; +} + +//----------------------------------------------------------------------------------- +//class LLViewerOctreeEntry definitions +//----------------------------------------------------------------------------------- +LLViewerOctreeEntry::LLViewerOctreeEntry() : mGroup(NULL) +{ + mPositionGroup.clear(); + mExtents[0].clear(); + mExtents[1].clear(); + mBinRadius = 0.f; + mBinIndex = -1; + + for(S32 i = 0; i < NUM_DATA_TYPE; i++) + { + mData[i] = NULL; + } +} + +LLViewerOctreeEntry::~LLViewerOctreeEntry() +{ + llassert(!mGroup); +} + +void LLViewerOctreeEntry::addData(LLViewerOctreeEntryData* data) +{ + //llassert(mData[data->getDataType()] == NULL); + llassert(data != NULL); + + mData[data->getDataType()] = data; +} + +void LLViewerOctreeEntry::removeData(LLViewerOctreeEntryData* data) +{ + //llassert(data->getDataType() != LLVOCACHEENTRY); //can not remove VOCache entry + + if(!mData[data->getDataType()]) + { + return; + } + + mData[data->getDataType()] = NULL; + + if(mGroup != NULL && !mData[LLDRAWABLE]) + { + LLviewerOctreeGroup* group = mGroup; + mGroup = NULL; + group->removeFromGroup(data); + + llassert(mBinIndex == -1); + } +} + +//called by group handleDestruction() ONLY when group is destroyed by octree. +void LLViewerOctreeEntry::nullGroup() +{ + mGroup = NULL; +} + +void LLViewerOctreeEntry::setGroup(LLviewerOctreeGroup* group) +{ + if(mGroup == group) + { + return; + } + + if(mGroup) + { + LLviewerOctreeGroup* group = mGroup; + mGroup = NULL; + group->removeFromGroup(this); + + llassert(mBinIndex == -1); + } + + mGroup = group; +} + +//----------------------------------------------------------------------------------- +//class LLViewerOctreeEntryData definitions +//----------------------------------------------------------------------------------- +LLViewerOctreeEntryData::~LLViewerOctreeEntryData() +{ + if(mEntry) + { + mEntry->removeData(this); + } +} + +LLViewerOctreeEntryData::LLViewerOctreeEntryData(LLViewerOctreeEntry::eEntryDataType_t data_type) + : mDataType(data_type), + mEntry(NULL) +{ +} + +//virtual +void LLViewerOctreeEntryData::setOctreeEntry(LLViewerOctreeEntry* entry) +{ + if(mEntry.notNull()) + { + return; + } + + if(!entry) + { + mEntry = new LLViewerOctreeEntry(); + } + else + { + mEntry = entry; + } + mEntry->addData(this); +} + +void LLViewerOctreeEntryData::setSpatialExtents(const LLVector3& min, const LLVector3& max) +{ + mEntry->mExtents[0].load3(min.mV); + mEntry->mExtents[1].load3(max.mV); +} + +void LLViewerOctreeEntryData::setSpatialExtents(const LLVector4a& min, const LLVector4a& max) +{ + mEntry->mExtents[0] = min; + mEntry->mExtents[1] = max; +} + +void LLViewerOctreeEntryData::setPositionGroup(const LLVector4a& pos) +{ + mEntry->mPositionGroup = pos; +} + +const LLVector4a* LLViewerOctreeEntryData::getSpatialExtents() const +{ + return mEntry->getSpatialExtents(); +} + +//virtual +void LLViewerOctreeEntryData::setGroup(LLviewerOctreeGroup* group) +{ + mEntry->setGroup(group); +} + +void LLViewerOctreeEntryData::shift(const LLVector4a &shift_vector) +{ + mEntry->mExtents[0].add(shift_vector); + mEntry->mExtents[1].add(shift_vector); + mEntry->mPositionGroup.add(shift_vector); +} + +LLviewerOctreeGroup* LLViewerOctreeEntryData::getGroup()const +{ + return mEntry.notNull() ? mEntry->mGroup : NULL; +} + +const LLVector4a& LLViewerOctreeEntryData::getPositionGroup() const +{ + return mEntry->getPositionGroup(); +} + +//virtual +bool LLViewerOctreeEntryData::isVisible() const +{ + if(mEntry) + { + return mEntry->mVisible == sCurVisible; + } + return false; +} + +//virtual +bool LLViewerOctreeEntryData::isRecentlyVisible() const +{ + if(!mEntry) + { + return false; + } + + if(isVisible()) + { + return true; + } + if(getGroup() && getGroup()->isRecentlyVisible()) + { + setVisible(); + return true; + } + + return (sCurVisible - mEntry->mVisible < getMinVisFrameRange()); +} + +void LLViewerOctreeEntryData::setVisible() const +{ + if(mEntry) + { + mEntry->mVisible = sCurVisible; + } +} + +//----------------------------------------------------------------------------------- +//class LLviewerOctreeGroup definitions +//----------------------------------------------------------------------------------- + +LLviewerOctreeGroup::~LLviewerOctreeGroup() +{ +} + +LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : + mOctreeNode(node), + mState(CLEAN) +{ + LLVector4a tmp; + tmp.splat(0.f); + mExtents[0] = mExtents[1] = mObjectBounds[0] = mObjectBounds[0] = mObjectBounds[1] = + mObjectExtents[0] = mObjectExtents[1] = tmp; + + mBounds[0] = node->getCenter(); + mBounds[1] = node->getSize(); + + mOctreeNode->addListener(this); +} + +bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data) +{ + return removeFromGroup(data->getEntry()); +} + +bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) +{ + llassert(entry != NULL); + llassert(!entry->getGroup()); + + unbound(); + if (mOctreeNode) + { + if (!mOctreeNode->remove(entry)) + { + OCT_ERRS << "Could not remove LLVOCacheEntry from LLVOCacheOctreeGroup" << llendl; + return false; + } + } + setState(OBJECT_DIRTY); + + return true; +} + +//virtual +void LLviewerOctreeGroup::unbound() +{ + if (isDirty()) + { + return; + } + + setState(DIRTY); + + //all the parent nodes need to rebound this child + if (mOctreeNode) + { + OctreeNode* parent = (OctreeNode*) mOctreeNode->getParent(); + while (parent != NULL) + { + LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) parent->getListener(0); + if (!group || group->isDirty()) + { + return; + } + + group->setState(DIRTY); + parent = (OctreeNode*) parent->getParent(); + } + } +} + +//virtual +void LLviewerOctreeGroup::rebound() +{ + if (!isDirty()) + { + return; + } + + if (mOctreeNode->getChildCount() == 1 && mOctreeNode->getElementCount() == 0) + { + LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); + group->rebound(); + + //copy single child's bounding box + mBounds[0] = group->mBounds[0]; + mBounds[1] = group->mBounds[1]; + mExtents[0] = group->mExtents[0]; + mExtents[1] = group->mExtents[1]; + + group->setState(SKIP_FRUSTUM_CHECK); + } + else if (mOctreeNode->isLeaf()) + { //copy object bounding box if this is a leaf + boundObjects(TRUE, mExtents[0], mExtents[1]); + mBounds[0] = mObjectBounds[0]; + mBounds[1] = mObjectBounds[1]; + } + else + { + LLVector4a& newMin = mExtents[0]; + LLVector4a& newMax = mExtents[1]; + LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); + group->clearState(SKIP_FRUSTUM_CHECK); + group->rebound(); + //initialize to first child + newMin = group->mExtents[0]; + newMax = group->mExtents[1]; + + //first, rebound children + for (U32 i = 1; i < mOctreeNode->getChildCount(); i++) + { + group = (LLviewerOctreeGroup*) mOctreeNode->getChild(i)->getListener(0); + group->clearState(SKIP_FRUSTUM_CHECK); + group->rebound(); + const LLVector4a& max = group->mExtents[1]; + const LLVector4a& min = group->mExtents[0]; + + newMax.setMax(newMax, max); + newMin.setMin(newMin, min); + } + + boundObjects(FALSE, newMin, newMax); + + mBounds[0].setAdd(newMin, newMax); + mBounds[0].mul(0.5f); + mBounds[1].setSub(newMax, newMin); + mBounds[1].mul(0.5f); + } + + clearState(DIRTY); + + return; +} + +//virtual +void LLviewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj) +{ + obj->setGroup(this); + unbound(); + setState(OBJECT_DIRTY); +} + +//virtual +void LLviewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj) +{ + obj->setGroup(NULL); + unbound(); + setState(OBJECT_DIRTY); +} + +//virtual +void LLviewerOctreeGroup::handleDestruction(const TreeNode* node) +{ + for (OctreeNode::element_iter i = mOctreeNode->getDataBegin(); i != mOctreeNode->getDataEnd(); ++i) + { + LLViewerOctreeEntry* obj = *i; + if (obj && obj->getGroup() == this) + { + obj->nullGroup(); + } + } +} + +//virtual +void LLviewerOctreeGroup::handleStateChange(const TreeNode* node) +{ + //drop bounding box upon state change + if (mOctreeNode != node) + { + mOctreeNode = (OctreeNode*) node; + } + unbound(); +} + +//virtual +void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) +{ + llerrs << "can not access here. It is an abstract class." << llendl; + + //((LLviewerOctreeGroup*)child->getListener(0))->unbound(); +} + +//virtual +void LLviewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNode* child) +{ + unbound(); +} + +LLviewerOctreeGroup* LLviewerOctreeGroup::getParent() +{ + if(!mOctreeNode) + { + return NULL; + } + + OctreeNode* parent = mOctreeNode->getOctParent(); + + if (parent) + { + return (LLviewerOctreeGroup*) parent->getListener(0); + } + + return NULL; +} + +//virtual +bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut) +{ + const OctreeNode* node = mOctreeNode; + + if (node->isEmpty()) + { //don't do anything if there are no objects + if (empty && mOctreeNode->getParent()) + { //only root is allowed to be empty + OCT_ERRS << "Empty leaf found in octree." << llendl; + } + return false; + } + + LLVector4a& newMin = mObjectExtents[0]; + LLVector4a& newMax = mObjectExtents[1]; + + if (hasState(OBJECT_DIRTY)) + { //calculate new bounding box + clearState(OBJECT_DIRTY); + + //initialize bounding box to first element + OctreeNode::const_element_iter i = node->getDataBegin(); + LLViewerOctreeEntry* entry = *i; + const LLVector4a* minMax = entry->getSpatialExtents(); + + newMin = minMax[0]; + newMax = minMax[1]; + + for (++i; i != node->getDataEnd(); ++i) + { + entry = *i; + minMax = entry->getSpatialExtents(); + + update_min_max(newMin, newMax, minMax[0]); + update_min_max(newMin, newMax, minMax[1]); + } + + mObjectBounds[0].setAdd(newMin, newMax); + mObjectBounds[0].mul(0.5f); + mObjectBounds[1].setSub(newMax, newMin); + mObjectBounds[1].mul(0.5f); + } + + if (empty) + { + minOut = newMin; + maxOut = newMax; + } + else + { + minOut.setMin(minOut, newMin); + maxOut.setMax(maxOut, newMax); + } + + return TRUE; +} + +//virtual +BOOL LLviewerOctreeGroup::isVisible() const +{ + return TRUE; +} + +//----------------------------------------------------------------------------------- +//class LLViewerOctreeCull definitions +//----------------------------------------------------------------------------------- + +//virtual +bool LLViewerOctreeCull::earlyFail(LLviewerOctreeGroup* group) +{ + return false; +} + +//virtual +void LLViewerOctreeCull::traverse(const OctreeNode* n) +{ + LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) n->getListener(0); + + if (earlyFail(group)) + { + return; + } + + if (mRes == 2 || + (mRes && group->hasState(LLviewerOctreeGroup::SKIP_FRUSTUM_CHECK))) + { //fully in, just add everything + OctreeTraveler::traverse(n); + } + else + { + mRes = frustumCheck(group); + + if (mRes) + { //at least partially in, run on down + OctreeTraveler::traverse(n); + } + + mRes = 0; + } +} + +S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); +} + +S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group) +{ + return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); +} + +S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); +} + +S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group) +{ + return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); +} + +S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]); +} + +S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); +} + +//virtual +bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOctreeGroup* group) +{ + if (branch->getElementCount() == 0) //no elements + { + return false; + } + else if (branch->getChildCount() == 0) //leaf state, already checked tightest bounding box + { + return true; + } + else if (mRes == 1 && !frustumCheckObjects(group)) //no objects in frustum + { + return false; + } + + return true; +} + +//virtual +void LLViewerOctreeCull::preprocess(LLviewerOctreeGroup* group) +{ +} + +//virtual +void LLViewerOctreeCull::processGroup(LLviewerOctreeGroup* group) +{ +} + +//virtual +void LLViewerOctreeCull::visit(const OctreeNode* branch) +{ + LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); + + preprocess(group); + + if (checkObjects(branch, group)) + { + processGroup(group); + } +} + -- 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/llvieweroctree.cpp | 48 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 05f977036c..143f2a6819 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -26,6 +26,7 @@ #include "llviewerprecompiledheaders.h" #include "llvieweroctree.h" +#include "llviewerregion.h" //----------------------------------------------------------------------------------- //static variables definitions @@ -324,6 +325,10 @@ void LLViewerOctreeEntryData::setVisible() const LLviewerOctreeGroup::~LLviewerOctreeGroup() { + if(LLViewerRegion::sCurRegionp && isVisible()) + { + LLViewerRegion::sCurRegionp->clearVisibleGroup(this); + } } LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : @@ -482,8 +487,10 @@ void LLviewerOctreeGroup::handleDestruction(const TreeNode* node) if (obj && obj->getGroup() == this) { obj->nullGroup(); + //obj->setGroup(NULL); } } + mOctreeNode = NULL; } //virtual @@ -500,8 +507,17 @@ void LLviewerOctreeGroup::handleStateChange(const TreeNode* node) //virtual void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) { - llerrs << "can not access here. It is an abstract class." << llendl; + if (child->getListenerCount() == 0) + { + new LLviewerOctreeGroup(child); + } + else + { + OCT_ERRS << "LLSpatialGroup redundancy detected." << llendl; + } + unbound(); + //((LLviewerOctreeGroup*)child->getListener(0))->unbound(); } @@ -589,7 +605,35 @@ bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4 //virtual BOOL LLviewerOctreeGroup::isVisible() const { - return TRUE; + return mVisible[LLViewerCamera::sCurCameraID] >= LLViewerOctreeEntryData::getCurrentFrame() ? TRUE : FALSE; +} + +//virtual +BOOL LLviewerOctreeGroup::isRecentlyVisible() const +{ + return FALSE; +} + +void LLviewerOctreeGroup::setVisible() +{ + mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); +} +//----------------------------------------------------------------------------------- +//class LLViewerOctreePartition definitions +//----------------------------------------------------------------------------------- +LLViewerOctreePartition::LLViewerOctreePartition() : mRegionp(NULL) +{ + LLVector4a center, size; + center.splat(0.f); + size.splat(1.f); + + mOctree = new OctreeRoot(center,size, NULL); +} + +LLViewerOctreePartition::~LLViewerOctreePartition() +{ + delete mOctree; + mOctree = NULL; } //----------------------------------------------------------------------------------- -- 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/llvieweroctree.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 143f2a6819..b6e0674a95 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -126,13 +126,14 @@ S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LL //----------------------------------------------------------------------------------- //class LLViewerOctreeEntry definitions //----------------------------------------------------------------------------------- -LLViewerOctreeEntry::LLViewerOctreeEntry() : mGroup(NULL) +LLViewerOctreeEntry::LLViewerOctreeEntry() + : mGroup(NULL), + mBinRadius(0.f), + mBinIndex(-1) { mPositionGroup.clear(); mExtents[0].clear(); - mExtents[1].clear(); - mBinRadius = 0.f; - mBinIndex = -1; + mExtents[1].clear(); for(S32 i = 0; i < NUM_DATA_TYPE; 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/llvieweroctree.cpp | 50 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index b6e0674a95..7f502a6c51 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -675,6 +675,8 @@ void LLViewerOctreeCull::traverse(const OctreeNode* n) } } +//------------------------------------------ +//agent space group culling S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) { return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); @@ -685,6 +687,14 @@ S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLviewerOctreeGrou return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); } +S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]); +} +//------------------------------------------ + +//------------------------------------------ +//agent space object set culling S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) { return mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); @@ -695,15 +705,47 @@ S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLviewerOctreeGro return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); } -S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group) { - return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]); + return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); } +//------------------------------------------ -S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group) +//------------------------------------------ +//local regional space group culling +S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) { - return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); + return mCamera->AABBInRegionFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); +} + +S32 LLViewerOctreeCull::AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInRegionFrustum(group->mBounds[0], group->mBounds[1]); +} + +S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift) +{ + return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); +} +//------------------------------------------ + +//------------------------------------------ +//local regional space object culling +S32 LLViewerOctreeCull::AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInRegionFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); +} + +S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInRegionFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); +} + +S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLviewerOctreeGroup* group, const LLVector3& shift) +{ + return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); } +//------------------------------------------ //virtual bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOctreeGroup* group) -- cgit v1.2.3 From 7cc37d949e9319a5b60641ff8453a0fed763d817 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 9 Jan 2013 22:43:10 -0700 Subject: fix the merge errors from the changeset 3eadda9666cf --- indra/newview/llvieweroctree.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 7f502a6c51..cfa24c32ed 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -347,6 +347,15 @@ LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : mOctreeNode->addListener(this); } +bool LLviewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) +{ + if(!data->getEntry()) + { + return false; + } + return std::find(getDataBegin(), getDataEnd(), data->getEntry()) != getDataEnd(); +} + bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data) { return removeFromGroup(data->getEntry()); -- cgit v1.2.3 From 2bc378c7f4f4356d444f175cc47708bb452c0d2c Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 4 Apr 2013 15:27:00 -0600 Subject: for SH-4053: interesting: visible objects are delayed to appear with new interest list --- indra/newview/llvieweroctree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index cfa24c32ed..3c7c710825 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -528,7 +528,7 @@ void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNo unbound(); - //((LLviewerOctreeGroup*)child->getListener(0))->unbound(); + ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); } //virtual -- cgit v1.2.3 From b4967dfa4f3817c890644cb9a545264b65fd747a Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 4 Apr 2013 15:48:15 -0600 Subject: add debug code for LLViewerOctree --- indra/newview/llvieweroctree.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 3c7c710825..158fc4b0a9 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -32,6 +32,7 @@ //static variables definitions //----------------------------------------------------------------------------------- U32 LLViewerOctreeEntryData::sCurVisible = 0; +BOOL LLViewerOctreeDebug::sInDebug = FALSE; //----------------------------------------------------------------------------------- //some global functions definitions @@ -798,3 +799,46 @@ void LLViewerOctreeCull::visit(const OctreeNode* branch) } } +//-------------------------------------------------------------- +//class LLViewerOctreeDebug +//virtual +void LLViewerOctreeDebug::visit(const OctreeNode* branch) +{ +#if 0 + llinfos << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << llendl; + for (U32 i = 0; i < branch->getChildCount(); i++) + { + llinfos << "Child " << i << " : " << (U32)branch->getChild(i) << llendl; + } +#endif + LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); + processGroup(group); +} + +//virtual +void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group) +{ +#if 0 + const LLVector4a* vec4 = group->getBounds(); + LLVector3 vec[2]; + vec[0].set(vec4[0].getF32ptr()); + vec[1].set(vec4[1].getF32ptr()); + llinfos << "Bounds: " << vec[0] << " : " << vec[1] << llendl; + + vec4 = group->getExtents(); + vec[0].set(vec4[0].getF32ptr()); + vec[1].set(vec4[1].getF32ptr()); + llinfos << "Extents: " << vec[0] << " : " << vec[1] << llendl; + + vec4 = group->getObjectBounds(); + vec[0].set(vec4[0].getF32ptr()); + vec[1].set(vec4[1].getF32ptr()); + llinfos << "ObjectBounds: " << vec[0] << " : " << vec[1] << llendl; + + vec4 = group->getObjectExtents(); + vec[0].set(vec4[0].getF32ptr()); + vec[1].set(vec4[1].getF32ptr()); + llinfos << "ObjectExtents: " << vec[0] << " : " << vec[1] << llendl; +#endif +} +//-------------------------------------------------------------- -- cgit v1.2.3 From 446849f23c06ab2bda5333ba31e22bd09f1083fb Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 10 Apr 2013 11:32:33 -0600 Subject: trivial: convert to unix line endings. --- indra/newview/llvieweroctree.cpp | 86 ++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 158fc4b0a9..926d791d1f 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -799,46 +799,46 @@ void LLViewerOctreeCull::visit(const OctreeNode* branch) } } -//-------------------------------------------------------------- -//class LLViewerOctreeDebug -//virtual -void LLViewerOctreeDebug::visit(const OctreeNode* branch) -{ -#if 0 - llinfos << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << llendl; - for (U32 i = 0; i < branch->getChildCount(); i++) - { - llinfos << "Child " << i << " : " << (U32)branch->getChild(i) << llendl; - } -#endif - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); - processGroup(group); -} - -//virtual -void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group) -{ -#if 0 - const LLVector4a* vec4 = group->getBounds(); - LLVector3 vec[2]; - vec[0].set(vec4[0].getF32ptr()); - vec[1].set(vec4[1].getF32ptr()); - llinfos << "Bounds: " << vec[0] << " : " << vec[1] << llendl; - - vec4 = group->getExtents(); - vec[0].set(vec4[0].getF32ptr()); - vec[1].set(vec4[1].getF32ptr()); - llinfos << "Extents: " << vec[0] << " : " << vec[1] << llendl; - - vec4 = group->getObjectBounds(); - vec[0].set(vec4[0].getF32ptr()); - vec[1].set(vec4[1].getF32ptr()); - llinfos << "ObjectBounds: " << vec[0] << " : " << vec[1] << llendl; - - vec4 = group->getObjectExtents(); - vec[0].set(vec4[0].getF32ptr()); - vec[1].set(vec4[1].getF32ptr()); - llinfos << "ObjectExtents: " << vec[0] << " : " << vec[1] << llendl; -#endif -} -//-------------------------------------------------------------- +//-------------------------------------------------------------- +//class LLViewerOctreeDebug +//virtual +void LLViewerOctreeDebug::visit(const OctreeNode* branch) +{ +#if 0 + llinfos << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << llendl; + for (U32 i = 0; i < branch->getChildCount(); i++) + { + llinfos << "Child " << i << " : " << (U32)branch->getChild(i) << llendl; + } +#endif + LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); + processGroup(group); +} + +//virtual +void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group) +{ +#if 0 + const LLVector4a* vec4 = group->getBounds(); + LLVector3 vec[2]; + vec[0].set(vec4[0].getF32ptr()); + vec[1].set(vec4[1].getF32ptr()); + llinfos << "Bounds: " << vec[0] << " : " << vec[1] << llendl; + + vec4 = group->getExtents(); + vec[0].set(vec4[0].getF32ptr()); + vec[1].set(vec4[1].getF32ptr()); + llinfos << "Extents: " << vec[0] << " : " << vec[1] << llendl; + + vec4 = group->getObjectBounds(); + vec[0].set(vec4[0].getF32ptr()); + vec[1].set(vec4[1].getF32ptr()); + llinfos << "ObjectBounds: " << vec[0] << " : " << vec[1] << llendl; + + vec4 = group->getObjectExtents(); + vec[0].set(vec4[0].getF32ptr()); + vec[1].set(vec4[1].getF32ptr()); + llinfos << "ObjectExtents: " << vec[0] << " : " << vec[1] << llendl; +#endif +} +//-------------------------------------------------------------- -- cgit v1.2.3 From 6244679b34bfb450bc83fd1ccd8c765028bb6735 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 1 May 2013 10:57:09 -0600 Subject: performance optimization: only scan 32 objects per frame looking for invisibles. --- indra/newview/llvieweroctree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 926d791d1f..2acacccbe6 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -524,7 +524,7 @@ void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNo } else { - OCT_ERRS << "LLSpatialGroup redundancy detected." << llendl; + OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << llendl; } unbound(); -- 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/llvieweroctree.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 926d791d1f..0eb1745cd5 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -331,6 +331,7 @@ LLviewerOctreeGroup::~LLviewerOctreeGroup() { LLViewerRegion::sCurRegionp->clearVisibleGroup(this); } + llassert(LLViewerRegion::sCurRegionp->hasVisibleGroup(this) == false); } LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : -- cgit v1.2.3 From 43f063fe2c814e28da69f2f5c373497a6d621460 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 9 May 2013 17:19:05 -0700 Subject: SH-4080 WIP interesting: random crash on Mac added controls for curtain delay --- indra/newview/llvieweroctree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 0eb1745cd5..0fa1f5bef3 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -331,7 +331,7 @@ LLviewerOctreeGroup::~LLviewerOctreeGroup() { LLViewerRegion::sCurRegionp->clearVisibleGroup(this); } - llassert(LLViewerRegion::sCurRegionp->hasVisibleGroup(this) == false); + llassert(!LLViewerRegion::sCurRegionp || LLViewerRegion::sCurRegionp->hasVisibleGroup(this) == false); } LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : -- cgit v1.2.3 From 7006cbe3a24a88da4182f5930bb0fe712c43ce8c Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 16 May 2013 16:58:04 -0600 Subject: fix for SH-4080: interesting: random crash on Mac --- indra/newview/llvieweroctree.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 0670b47f52..62108f0512 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -327,11 +327,7 @@ void LLViewerOctreeEntryData::setVisible() const LLviewerOctreeGroup::~LLviewerOctreeGroup() { - if(LLViewerRegion::sCurRegionp && isVisible()) - { - LLViewerRegion::sCurRegionp->clearVisibleGroup(this); - } - llassert(!LLViewerRegion::sCurRegionp || LLViewerRegion::sCurRegionp->hasVisibleGroup(this) == false); + //empty here } LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : -- 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/llvieweroctree.cpp | 620 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 619 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 926d791d1f..844075089f 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -27,6 +27,11 @@ #include "llviewerprecompiledheaders.h" #include "llvieweroctree.h" #include "llviewerregion.h" +#include "pipeline.h" +#include "llviewercontrol.h" +#include "llappviewer.h" +#include "llglslshader.h" +#include "llviewershadermgr.h" //----------------------------------------------------------------------------------- //static variables definitions @@ -37,6 +42,100 @@ BOOL LLViewerOctreeDebug::sInDebug = FALSE; //----------------------------------------------------------------------------------- //some global functions definitions //----------------------------------------------------------------------------------- +typedef enum +{ + b000 = 0x00, + b001 = 0x01, + b010 = 0x02, + b011 = 0x03, + b100 = 0x04, + b101 = 0x05, + b110 = 0x06, + b111 = 0x07, +} eLoveTheBits; + +//contact Runitai Linden for a copy of the SL object used to write this table +//basically, you give the table a bitmask of the look-at vector to a node and it +//gives you a triangle fan index array +static U16 sOcclusionIndices[] = +{ + //000 + b111, b110, b010, b011, b001, b101, b100, b110, + //001 + b011, b010, b000, b001, b101, b111, b110, b010, + //010 + b101, b100, b110, b111, b011, b001, b000, b100, + //011 + b001, b000, b100, b101, b111, b011, b010, b000, + //100 + b110, b000, b010, b011, b111, b101, b100, b000, + //101 + b010, b100, b000, b001, b011, b111, b110, b100, + //110 + b100, b010, b110, b111, b101, b001, b000, b010, + //111 + b000, b110, b100, b101, b001, b011, b010, b110, +}; + +U32 get_box_fan_indices(LLCamera* camera, const LLVector4a& center) +{ + LLVector4a origin; + origin.load3(camera->getOrigin().mV); + + S32 cypher = center.greaterThan(origin).getGatheredBits() & 0x7; + + return cypher*8; +} + +U8* get_box_fan_indices_ptr(LLCamera* camera, const LLVector4a& center) +{ + LLVector4a origin; + origin.load3(camera->getOrigin().mV); + + S32 cypher = center.greaterThan(origin).getGatheredBits() & 0x7; + + return (U8*) (sOcclusionIndices+cypher*8); +} + +//create a vertex buffer for efficiently rendering cubes +LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage) +{ + LLVertexBuffer* ret = new LLVertexBuffer(type_mask, usage); + + ret->allocateBuffer(8, 64, true); + + LLStrider pos; + LLStrider idx; + + ret->getVertexStrider(pos); + ret->getIndexStrider(idx); + + pos[0] = LLVector3(-1,-1,-1); + pos[1] = LLVector3(-1,-1, 1); + pos[2] = LLVector3(-1, 1,-1); + pos[3] = LLVector3(-1, 1, 1); + pos[4] = LLVector3( 1,-1,-1); + pos[5] = LLVector3( 1,-1, 1); + pos[6] = LLVector3( 1, 1,-1); + pos[7] = LLVector3( 1, 1, 1); + + for (U32 i = 0; i < 64; i++) + { + idx[i] = sOcclusionIndices[i]; + } + + ret->flush(); + + return ret; +} + + +#define LL_TRACK_PENDING_OCCLUSION_QUERIES 0 + +const F32 SG_OCCLUSION_FUDGE = 0.25f; +#define SG_DISCARD_TOLERANCE 0.01f + + S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad) { return AABBSphereIntersectR2(min, max, origin, rad*rad); @@ -540,6 +639,11 @@ void LLviewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const Oct LLviewerOctreeGroup* LLviewerOctreeGroup::getParent() { + if (isDead()) + { + return NULL; + } + if(!mOctreeNode) { return NULL; @@ -629,10 +733,519 @@ void LLviewerOctreeGroup::setVisible() { mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); } + +void LLviewerOctreeGroup::checkStates() +{ +#if LL_OCTREE_PARANOIA_CHECK + //LLOctreeStateCheck checker; + //checker.traverse(mOctreeNode); +#endif +} + +//------------------------------------------------------------------------------------------- +//occulsion culling functions and classes +//------------------------------------------------------------------------------------------- +std::set LLOcclusionCullingGroup::sPendingQueries; +class LLOcclusionQueryPool : public LLGLNamePool +{ +public: + LLOcclusionQueryPool() + { + mCurQuery = 1; + } + +protected: + + std::list mAvailableName; + GLuint mCurQuery; + + virtual GLuint allocateName() + { + GLuint ret = 0; + + if (!mAvailableName.empty()) + { + ret = mAvailableName.front(); + mAvailableName.pop_front(); + } + else + { + ret = mCurQuery++; + } + + return ret; + } + + virtual void releaseName(GLuint name) + { +#if LL_TRACK_PENDING_OCCLUSION_QUERIES + LLSpatialGroup::sPendingQueries.erase(name); +#endif + llassert(std::find(mAvailableName.begin(), mAvailableName.end(), name) == mAvailableName.end()); + mAvailableName.push_back(name); + } +}; + +static LLOcclusionQueryPool sQueryPool; +U32 LLOcclusionCullingGroup::getNewOcclusionQueryObjectName() +{ + return sQueryPool.allocate(); +} + +void LLOcclusionCullingGroup::releaseOcclusionQueryObjectName(GLuint name) +{ + sQueryPool.release(name); +} + +//===================================== +// Occlusion State Set/Clear +//===================================== +class LLSpatialSetOcclusionState : public OctreeTraveler +{ +public: + U32 mState; + LLSpatialSetOcclusionState(U32 state) : mState(state) { } + virtual void visit(const OctreeNode* branch) { ((LLOcclusionCullingGroup*) branch->getListener(0))->setOcclusionState(mState); } +}; + +class LLSpatialSetOcclusionStateDiff : public LLSpatialSetOcclusionState +{ +public: + LLSpatialSetOcclusionStateDiff(U32 state) : LLSpatialSetOcclusionState(state) { } + + virtual void traverse(const OctreeNode* n) + { + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*) n->getListener(0); + + if (!group->isOcclusionState(mState)) + { + OctreeTraveler::traverse(n); + } + } +}; + + +LLOcclusionCullingGroup::LLOcclusionCullingGroup(OctreeNode* node, LLViewerOctreePartition* part) : + LLviewerOctreeGroup(node), + mSpatialPartition(part) +{ + part->mLODSeed = (part->mLODSeed+1)%part->mLODPeriod; + mLODHash = part->mLODSeed; + + OctreeNode* oct_parent = node->getOctParent(); + LLOcclusionCullingGroup* parent = oct_parent ? (LLOcclusionCullingGroup*) oct_parent->getListener(0) : NULL; + + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + { + mOcclusionQuery[i] = 0; + mOcclusionIssued[i] = 0; + mOcclusionState[i] = parent ? SG_STATE_INHERIT_MASK & parent->mOcclusionState[i] : 0; + mVisible[i] = 0; + } +} + +LLOcclusionCullingGroup::~LLOcclusionCullingGroup() +{ + releaseOcclusionQueryObjectNames(); +} + +BOOL LLOcclusionCullingGroup::needsUpdate() +{ + return (LLDrawable::getCurrentFrame() % mSpatialPartition->mLODPeriod == mLODHash) ? TRUE : FALSE; +} + +//virtual +void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) +{ + if (child->getListenerCount() == 0) + { + new LLOcclusionCullingGroup(child, mSpatialPartition); + } + else + { + OCT_ERRS << "LLOcclusionCullingGroup redundancy detected." << llendl; + } + + unbound(); + + ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); +} + +void LLOcclusionCullingGroup::releaseOcclusionQueryObjectNames() +{ + if (gGLManager.mHasOcclusionQuery) + { + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; ++i) + { + if (mOcclusionQuery[i]) + { + releaseOcclusionQueryObjectName(mOcclusionQuery[i]); + mOcclusionQuery[i] = 0; + } + } + } +} + +void LLOcclusionCullingGroup::setOcclusionState(U32 state, S32 mode) +{ + if (mode > STATE_MODE_SINGLE) + { + if (mode == STATE_MODE_DIFF) + { + LLSpatialSetOcclusionStateDiff setter(state); + setter.traverse(mOctreeNode); + } + else if (mode == STATE_MODE_BRANCH) + { + LLSpatialSetOcclusionState setter(state); + setter.traverse(mOctreeNode); + } + else + { + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + { + mOcclusionState[i] |= state; + + if ((state & DISCARD_QUERY) && mOcclusionQuery[i]) + { + releaseOcclusionQueryObjectName(mOcclusionQuery[i]); + mOcclusionQuery[i] = 0; + } + } + } + } + else + { + mOcclusionState[LLViewerCamera::sCurCameraID] |= state; + if ((state & DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID]) + { + releaseOcclusionQueryObjectName(mOcclusionQuery[LLViewerCamera::sCurCameraID]); + mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0; + } + } +} + +class LLSpatialClearOcclusionState : public OctreeTraveler +{ +public: + U32 mState; + + LLSpatialClearOcclusionState(U32 state) : mState(state) { } + virtual void visit(const OctreeNode* branch) { ((LLOcclusionCullingGroup*) branch->getListener(0))->clearOcclusionState(mState); } +}; + +class LLSpatialClearOcclusionStateDiff : public LLSpatialClearOcclusionState +{ +public: + LLSpatialClearOcclusionStateDiff(U32 state) : LLSpatialClearOcclusionState(state) { } + + virtual void traverse(const OctreeNode* n) + { + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*) n->getListener(0); + + if (group->isOcclusionState(mState)) + { + OctreeTraveler::traverse(n); + } + } +}; + +void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode) +{ + if (mode > STATE_MODE_SINGLE) + { + if (mode == STATE_MODE_DIFF) + { + LLSpatialClearOcclusionStateDiff clearer(state); + clearer.traverse(mOctreeNode); + } + else if (mode == STATE_MODE_BRANCH) + { + LLSpatialClearOcclusionState clearer(state); + clearer.traverse(mOctreeNode); + } + else + { + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + { + mOcclusionState[i] &= ~state; + } + } + } + else + { + mOcclusionState[LLViewerCamera::sCurCameraID] &= ~state; + } +} + +static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait"); + +BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera) +{ + if (camera->getOrigin().isExactlyZero()) + { + return FALSE; + } + + const F32 vel = SG_OCCLUSION_FUDGE*2.f; + LLVector4a fudge; + fudge.splat(vel); + + const LLVector4a* bounds = getBounds(); + const LLVector4a& c = bounds[0]; + LLVector4a r; + r.setAdd(bounds[1], fudge); + + /*if (r.magVecSquared() > 1024.0*1024.0) + { + return TRUE; + }*/ + + LLVector4a e; + e.load3(camera->getOrigin().mV); + + LLVector4a min; + min.setSub(c,r); + LLVector4a max; + max.setAdd(c,r); + + S32 lt = e.lessThan(min).getGatheredBits() & 0x7; + if (lt) + { + return FALSE; + } + + S32 gt = e.greaterThan(max).getGatheredBits() & 0x7; + if (gt) + { + return FALSE; + } + + return TRUE; +} + +void LLOcclusionCullingGroup::checkOcclusion() +{ + if (LLPipeline::sUseOcclusion > 1) + { + LLFastTimer t(FTM_OCCLUSION_READBACK); + LLOcclusionCullingGroup* parent = (LLOcclusionCullingGroup*)getParent(); + if (parent && parent->isOcclusionState(LLOcclusionCullingGroup::OCCLUDED)) + { //if the parent has been marked as occluded, the child is implicitly occluded + clearOcclusionState(QUERY_PENDING | DISCARD_QUERY); + } + else if (isOcclusionState(QUERY_PENDING)) + { //otherwise, if a query is pending, read it back + + GLuint available = 0; + if (mOcclusionQuery[LLViewerCamera::sCurCameraID]) + { + glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available); + + static LLCachedControl wait_for_query(gSavedSettings, "RenderSynchronousOcclusion"); + + if (wait_for_query && mOcclusionIssued[LLViewerCamera::sCurCameraID] < gFrameCount) + { //query was issued last frame, wait until it's available + S32 max_loop = 1024; + LLFastTimer t(FTM_OCCLUSION_WAIT); + while (!available && max_loop-- > 0) + { + //do some usefu work while we wait + F32 max_time = llmin(gFrameIntervalSeconds.value()*10.f, 1.f); + LLAppViewer::instance()->updateTextureThreads(max_time); + + glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available); + } + } + } + else + { + available = 1; + } + + if (available) + { //result is available, read it back, otherwise wait until next frame + GLuint res = 1; + if (!isOcclusionState(DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID]) + { + glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_ARB, &res); +#if LL_TRACK_PENDING_OCCLUSION_QUERIES + sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]); +#endif + } + else if (mOcclusionQuery[LLViewerCamera::sCurCameraID]) + { //delete the query to avoid holding onto hundreds of pending queries + releaseOcclusionQueryObjectName(mOcclusionQuery[LLViewerCamera::sCurCameraID]); + mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0; + } + + if (isOcclusionState(DISCARD_QUERY)) + { + res = 2; + } + + if (res > 0) + { + assert_states_valid(this); + clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF); + assert_states_valid(this); + } + else + { + assert_states_valid(this); + + setOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF); + + assert_states_valid(this); + } + + clearOcclusionState(QUERY_PENDING | DISCARD_QUERY); + } + } + else if (mSpatialPartition->isOcclusionEnabled() && isOcclusionState(LLOcclusionCullingGroup::OCCLUDED)) + { //check occlusion has been issued for occluded node that has not had a query issued + assert_states_valid(this); + clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF); + assert_states_valid(this); + } + } +} + +static LLFastTimer::DeclareTimer FTM_PUSH_OCCLUSION_VERTS("Push Occlusion"); +static LLFastTimer::DeclareTimer FTM_SET_OCCLUSION_STATE("Occlusion State"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_ALLOCATE("Allocate"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_BUILD("Build"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_BEGIN_QUERY("Begin Query"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_END_QUERY("End Query"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_SET_BUFFER("Set Buffer"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW_WATER("Draw Water"); +static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW("Draw"); + +void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) +{ + if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1) + { + // Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension + if (earlyFail(camera)) + { + LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL); + setOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY); + assert_states_valid(this); + clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF); + assert_states_valid(this); + } + else + { + if (!isOcclusionState(QUERY_PENDING) || isOcclusionState(DISCARD_QUERY)) + { + { //no query pending, or previous query to be discarded + LLFastTimer t(FTM_RENDER_OCCLUSION); + + if (!mOcclusionQuery[LLViewerCamera::sCurCameraID]) + { + LLFastTimer t(FTM_OCCLUSION_ALLOCATE); + mOcclusionQuery[LLViewerCamera::sCurCameraID] = getNewOcclusionQueryObjectName(); + } + + // Depth clamp all water to avoid it being culled as a result of being + // behind the far clip plane, and in the case of edge water to avoid + // it being culled while still visible. + bool const use_depth_clamp = gGLManager.mHasDepthClamp && + (mSpatialPartition->mDrawableType == LLDrawPool::POOL_WATER || + mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER); + + LLGLEnable clamp(use_depth_clamp ? GL_DEPTH_CLAMP : 0); + +#if !LL_DARWIN + U32 mode = gGLManager.mHasOcclusionQuery2 ? GL_ANY_SAMPLES_PASSED : GL_SAMPLES_PASSED_ARB; +#else + U32 mode = GL_SAMPLES_PASSED_ARB; +#endif + +#if LL_TRACK_PENDING_OCCLUSION_QUERIES + sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]); +#endif + + { + LLFastTimer t(FTM_PUSH_OCCLUSION_VERTS); + + //store which frame this query was issued on + mOcclusionIssued[LLViewerCamera::sCurCameraID] = gFrameCount; + + { + LLFastTimer t(FTM_OCCLUSION_BEGIN_QUERY); + glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]); + } + + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + llassert(shader); + + shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, mBounds[0].getF32ptr()); + shader->uniform3f(LLShaderMgr::BOX_SIZE, mBounds[1][0]+SG_OCCLUSION_FUDGE, + mBounds[1][1]+SG_OCCLUSION_FUDGE, + mBounds[1][2]+SG_OCCLUSION_FUDGE); + + if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER) + { + LLFastTimer t(FTM_OCCLUSION_DRAW_WATER); + + LLGLSquashToFarClip squash(glh_get_current_projection(), 1); + if (camera->getOrigin().isExactlyZero()) + { //origin is invalid, draw entire box + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0); + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8); + } + else + { + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0])); + } + } + else + { + LLFastTimer t(FTM_OCCLUSION_DRAW); + if (camera->getOrigin().isExactlyZero()) + { //origin is invalid, draw entire box + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0); + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8); + } + else + { + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0])); + } + } + + + { + LLFastTimer t(FTM_OCCLUSION_END_QUERY); + glEndQueryARB(mode); + } + } + } + + { + LLFastTimer t(FTM_SET_OCCLUSION_STATE); + setOcclusionState(LLOcclusionCullingGroup::QUERY_PENDING); + clearOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY); + } + } + } + } +} +//------------------------------------------------------------------------------------------- +//end of occulsion culling functions and classes +//------------------------------------------------------------------------------------------- + //----------------------------------------------------------------------------------- //class LLViewerOctreePartition definitions //----------------------------------------------------------------------------------- -LLViewerOctreePartition::LLViewerOctreePartition() : mRegionp(NULL) +LLViewerOctreePartition::LLViewerOctreePartition() : + mRegionp(NULL), + mOcclusionEnabled(TRUE), + mDrawableType(0), + mLODSeed(0), + mLODPeriod(1) { LLVector4a center, size; center.splat(0.f); @@ -647,6 +1260,11 @@ LLViewerOctreePartition::~LLViewerOctreePartition() mOctree = NULL; } +BOOL LLViewerOctreePartition::isOcclusionEnabled() +{ + return mOcclusionEnabled || LLPipeline::sUseOcclusion > 2; +} + //----------------------------------------------------------------------------------- //class LLViewerOctreeCull definitions //----------------------------------------------------------------------------------- -- 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/llvieweroctree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index d9e1774c6d..d631985e82 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -409,7 +409,7 @@ bool LLViewerOctreeEntryData::isRecentlyVisible() const return true; } - return (sCurVisible - mEntry->mVisible < getMinVisFrameRange()); + return (sCurVisible - mEntry->mVisible < getMinFrameRange()); } void LLViewerOctreeEntryData::setVisible() const -- 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/llvieweroctree.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index d631985e82..576dbfd2c2 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1022,6 +1022,11 @@ BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera) return TRUE; } +U32 LLOcclusionCullingGroup::getLastOcclusionIssuedTime() +{ + return mOcclusionIssued[LLViewerCamera::sCurCameraID]; +} + void LLOcclusionCullingGroup::checkOcclusion() { if (LLPipeline::sUseOcclusion > 1) -- 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/llvieweroctree.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 576dbfd2c2..7b3186d40a 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -978,7 +978,7 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode) static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion"); static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait"); -BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera) +BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* bounds) { if (camera->getOrigin().isExactlyZero()) { @@ -989,7 +989,6 @@ BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera) LLVector4a fudge; fudge.splat(vel); - const LLVector4a* bounds = getBounds(); const LLVector4a& c = bounds[0]; LLVector4a r; r.setAdd(bounds[1], fudge); @@ -1125,12 +1124,23 @@ static LLFastTimer::DeclareTimer FTM_OCCLUSION_SET_BUFFER("Set Buffer"); static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW_WATER("Draw Water"); static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW("Draw"); -void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) +void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* region_agent) { if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1) { + //move mBounds to the agent space if necessary + LLVector4a bounds[2]; + bounds[0] = mBounds[0]; + bounds[1] = mBounds[1]; + if(region_agent != NULL) + { + LLVector4a shift((*region_agent)[0], (*region_agent)[1], (*region_agent)[2]); + bounds[0].sub(shift); + bounds[1].sub(shift); + } + // Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension - if (earlyFail(camera)) + if (earlyFail(camera, bounds)) { LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL); setOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY); @@ -1184,10 +1194,10 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; llassert(shader); - shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, mBounds[0].getF32ptr()); - shader->uniform3f(LLShaderMgr::BOX_SIZE, mBounds[1][0]+SG_OCCLUSION_FUDGE, - mBounds[1][1]+SG_OCCLUSION_FUDGE, - mBounds[1][2]+SG_OCCLUSION_FUDGE); + shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, bounds[0].getF32ptr()); + shader->uniform3f(LLShaderMgr::BOX_SIZE, bounds[1][0]+SG_OCCLUSION_FUDGE, + bounds[1][1]+SG_OCCLUSION_FUDGE, + bounds[1][2]+SG_OCCLUSION_FUDGE); if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER) { @@ -1201,7 +1211,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) } else { - gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0])); + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, bounds[0])); } } else @@ -1214,7 +1224,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera) } else { - gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0])); + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, bounds[0])); } } -- cgit v1.2.3 From 83a628a431b569555ea68588e18a49159acbfd0c Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 25 Jul 2013 16:53:01 -0600 Subject: fix for SH-4298: Interesting: Viewer crash in LLViewerOctreeCull and SH-4341: Interesting: Viewer crash in LLViewerOctreeCull --- indra/newview/llvieweroctree.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 7b3186d40a..bba3d26e09 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -464,15 +464,16 @@ bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) llassert(!entry->getGroup()); unbound(); + setState(OBJECT_DIRTY); + if (mOctreeNode) { - if (!mOctreeNode->remove(entry)) + if (!mOctreeNode->remove(entry)) //this could cause *this* pointer to be destroyed, so no more function calls after this. { OCT_ERRS << "Could not remove LLVOCacheEntry from LLVOCacheOctreeGroup" << llendl; return false; } - } - setState(OBJECT_DIRTY); + } return true; } @@ -580,9 +581,10 @@ void LLviewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEn //virtual void LLviewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj) { - obj->setGroup(NULL); unbound(); setState(OBJECT_DIRTY); + + obj->setGroup(NULL); //this could cause *this* pointer to be destroyed. So no more function calls after this. } //virtual -- 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/llvieweroctree.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index bba3d26e09..9b8a3c9269 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -853,6 +853,12 @@ BOOL LLOcclusionCullingGroup::needsUpdate() return (LLDrawable::getCurrentFrame() % mSpatialPartition->mLODPeriod == mLODHash) ? TRUE : FALSE; } +BOOL LLOcclusionCullingGroup::isRecentlyVisible() const +{ + const S32 MIN_VIS_FRAME_RANGE = 2; + return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < MIN_VIS_FRAME_RANGE ; +} + //virtual void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) { -- 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/llvieweroctree.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index bba3d26e09..443468235a 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -470,7 +470,7 @@ bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) { if (!mOctreeNode->remove(entry)) //this could cause *this* pointer to be destroyed, so no more function calls after this. { - OCT_ERRS << "Could not remove LLVOCacheEntry from LLVOCacheOctreeGroup" << llendl; + OCT_ERRS << "Could not remove LLVOCacheEntry from LLVOCacheOctreeGroup" << LL_ENDL; return false; } } @@ -622,7 +622,7 @@ void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNo } else { - OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << llendl; + OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << LL_ENDL; } unbound(); @@ -667,7 +667,7 @@ bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4 { //don't do anything if there are no objects if (empty && mOctreeNode->getParent()) { //only root is allowed to be empty - OCT_ERRS << "Empty leaf found in octree." << llendl; + OCT_ERRS << "Empty leaf found in octree." << LL_ENDL; } return false; } @@ -862,7 +862,7 @@ void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, Octr } else { - OCT_ERRS << "LLOcclusionCullingGroup redundancy detected." << llendl; + OCT_ERRS << "LLOcclusionCullingGroup redundancy detected." << LL_ENDL; } unbound(); @@ -1437,10 +1437,10 @@ void LLViewerOctreeCull::visit(const OctreeNode* branch) void LLViewerOctreeDebug::visit(const OctreeNode* branch) { #if 0 - llinfos << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << llendl; + LL_INFOS() << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << LL_ENDL; for (U32 i = 0; i < branch->getChildCount(); i++) { - llinfos << "Child " << i << " : " << (U32)branch->getChild(i) << llendl; + LL_INFOS() << "Child " << i << " : " << (U32)branch->getChild(i) << LL_ENDL; } #endif LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); @@ -1455,22 +1455,22 @@ void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group) LLVector3 vec[2]; vec[0].set(vec4[0].getF32ptr()); vec[1].set(vec4[1].getF32ptr()); - llinfos << "Bounds: " << vec[0] << " : " << vec[1] << llendl; + LL_INFOS() << "Bounds: " << vec[0] << " : " << vec[1] << LL_ENDL; vec4 = group->getExtents(); vec[0].set(vec4[0].getF32ptr()); vec[1].set(vec4[1].getF32ptr()); - llinfos << "Extents: " << vec[0] << " : " << vec[1] << llendl; + LL_INFOS() << "Extents: " << vec[0] << " : " << vec[1] << LL_ENDL; vec4 = group->getObjectBounds(); vec[0].set(vec4[0].getF32ptr()); vec[1].set(vec4[1].getF32ptr()); - llinfos << "ObjectBounds: " << vec[0] << " : " << vec[1] << llendl; + LL_INFOS() << "ObjectBounds: " << vec[0] << " : " << vec[1] << LL_ENDL; vec4 = group->getObjectExtents(); vec[0].set(vec4[0].getF32ptr()); vec[1].set(vec4[1].getF32ptr()); - llinfos << "ObjectExtents: " << vec[0] << " : " << vec[1] << llendl; + LL_INFOS() << "ObjectExtents: " << vec[0] << " : " << vec[1] << LL_ENDL; #endif } //-------------------------------------------------------------- -- 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/llvieweroctree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 637505a826..481befdb44 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -409,7 +409,7 @@ bool LLViewerOctreeEntryData::isRecentlyVisible() const return true; } - return (sCurVisible - mEntry->mVisible < getMinFrameRange()); + return false; } void LLViewerOctreeEntryData::setVisible() const -- 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/llvieweroctree.cpp | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 481befdb44..1e01c0fdef 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -983,8 +983,8 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode) } } -static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait"); +static LLTrace::TimeBlock FTM_OCCLUSION_READBACK("Readback Occlusion"); +static LLTrace::TimeBlock FTM_OCCLUSION_WAIT("Occlusion Wait"); BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* bounds) { @@ -1038,7 +1038,7 @@ void LLOcclusionCullingGroup::checkOcclusion() { if (LLPipeline::sUseOcclusion > 1) { - LLFastTimer t(FTM_OCCLUSION_READBACK); + LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_READBACK); LLOcclusionCullingGroup* parent = (LLOcclusionCullingGroup*)getParent(); if (parent && parent->isOcclusionState(LLOcclusionCullingGroup::OCCLUDED)) { //if the parent has been marked as occluded, the child is implicitly occluded @@ -1057,7 +1057,7 @@ void LLOcclusionCullingGroup::checkOcclusion() if (wait_for_query && mOcclusionIssued[LLViewerCamera::sCurCameraID] < gFrameCount) { //query was issued last frame, wait until it's available S32 max_loop = 1024; - LLFastTimer t(FTM_OCCLUSION_WAIT); + LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_WAIT); while (!available && max_loop-- > 0) { //do some usefu work while we wait @@ -1121,16 +1121,16 @@ void LLOcclusionCullingGroup::checkOcclusion() } } -static LLFastTimer::DeclareTimer FTM_PUSH_OCCLUSION_VERTS("Push Occlusion"); -static LLFastTimer::DeclareTimer FTM_SET_OCCLUSION_STATE("Occlusion State"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_ALLOCATE("Allocate"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_BUILD("Build"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_BEGIN_QUERY("Begin Query"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_END_QUERY("End Query"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_SET_BUFFER("Set Buffer"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW_WATER("Draw Water"); -static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW("Draw"); +static LLTrace::TimeBlock FTM_PUSH_OCCLUSION_VERTS("Push Occlusion"); +static LLTrace::TimeBlock FTM_SET_OCCLUSION_STATE("Occlusion State"); +static LLTrace::TimeBlock FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail"); +static LLTrace::TimeBlock FTM_OCCLUSION_ALLOCATE("Allocate"); +static LLTrace::TimeBlock FTM_OCCLUSION_BUILD("Build"); +static LLTrace::TimeBlock FTM_OCCLUSION_BEGIN_QUERY("Begin Query"); +static LLTrace::TimeBlock FTM_OCCLUSION_END_QUERY("End Query"); +static LLTrace::TimeBlock FTM_OCCLUSION_SET_BUFFER("Set Buffer"); +static LLTrace::TimeBlock FTM_OCCLUSION_DRAW_WATER("Draw Water"); +static LLTrace::TimeBlock FTM_OCCLUSION_DRAW("Draw"); void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* region_agent) { @@ -1150,7 +1150,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg // Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension if (earlyFail(camera, bounds)) { - LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL); + LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_EARLY_FAIL); setOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY); assert_states_valid(this); clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF); @@ -1161,11 +1161,11 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg if (!isOcclusionState(QUERY_PENDING) || isOcclusionState(DISCARD_QUERY)) { { //no query pending, or previous query to be discarded - LLFastTimer t(FTM_RENDER_OCCLUSION); + LL_RECORD_BLOCK_TIME(FTM_RENDER_OCCLUSION); if (!mOcclusionQuery[LLViewerCamera::sCurCameraID]) { - LLFastTimer t(FTM_OCCLUSION_ALLOCATE); + LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_ALLOCATE); mOcclusionQuery[LLViewerCamera::sCurCameraID] = getNewOcclusionQueryObjectName(); } @@ -1189,13 +1189,13 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg #endif { - LLFastTimer t(FTM_PUSH_OCCLUSION_VERTS); + LL_RECORD_BLOCK_TIME(FTM_PUSH_OCCLUSION_VERTS); //store which frame this query was issued on mOcclusionIssued[LLViewerCamera::sCurCameraID] = gFrameCount; { - LLFastTimer t(FTM_OCCLUSION_BEGIN_QUERY); + LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_BEGIN_QUERY); glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]); } @@ -1209,7 +1209,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER) { - LLFastTimer t(FTM_OCCLUSION_DRAW_WATER); + LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_DRAW_WATER); LLGLSquashToFarClip squash(glh_get_current_projection(), 1); if (camera->getOrigin().isExactlyZero()) @@ -1224,7 +1224,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg } else { - LLFastTimer t(FTM_OCCLUSION_DRAW); + LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_DRAW); if (camera->getOrigin().isExactlyZero()) { //origin is invalid, draw entire box gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0); @@ -1238,14 +1238,14 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg { - LLFastTimer t(FTM_OCCLUSION_END_QUERY); + LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_END_QUERY); glEndQueryARB(mode); } } } { - LLFastTimer t(FTM_SET_OCCLUSION_STATE); + LL_RECORD_BLOCK_TIME(FTM_SET_OCCLUSION_STATE); setOcclusionState(LLOcclusionCullingGroup::QUERY_PENDING); clearOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY); } -- cgit v1.2.3 From 3fd68662f267a3fd96d101834b3a9563bde3f61e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 7 Sep 2013 21:16:39 -0700 Subject: added memory usage and occlusion events to traces renamed "current" to "primary" when referring to accumulators --- indra/newview/llvieweroctree.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 481befdb44..b6389fac33 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -39,6 +39,11 @@ U32 LLViewerOctreeEntryData::sCurVisible = 0; BOOL LLViewerOctreeDebug::sInDebug = FALSE; +static LLTrace::CountStatHandle sOcclusionQueries("occlusion_queries", "Number of occlusion queries executed"), + sNumObjectsOccluded("occluded_objects", "Count of objects being occluded by a query"), + sNumObjectsUnoccluded("unoccluded_objects", "Count of objects being unoccluded by a query"); +static LLTrace::SampleStatHandle sOcclusionQueriesInFlight("occlusion_queries_in_flight", "Number of occlusion queries waiting for results"); + //----------------------------------------------------------------------------------- //some global functions definitions //----------------------------------------------------------------------------------- @@ -921,6 +926,10 @@ void LLOcclusionCullingGroup::setOcclusionState(U32 state, S32 mode) } else { + if (state & OCCLUDED) + { + add(sNumObjectsOccluded, 1); + } mOcclusionState[LLViewerCamera::sCurCameraID] |= state; if ((state & DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID]) { @@ -979,6 +988,10 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode) } else { + if (state & OCCLUDED) + { + add(sNumObjectsUnoccluded, 1); + } mOcclusionState[LLViewerCamera::sCurCameraID] &= ~state; } } @@ -1082,6 +1095,7 @@ void LLOcclusionCullingGroup::checkOcclusion() #if LL_TRACK_PENDING_OCCLUSION_QUERIES sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]); #endif + add(sOcclusionQueriesInFlight, -1); } else if (mOcclusionQuery[LLViewerCamera::sCurCameraID]) { //delete the query to avoid holding onto hundreds of pending queries @@ -1187,6 +1201,8 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg #if LL_TRACK_PENDING_OCCLUSION_QUERIES sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]); #endif + add(sOcclusionQueries, 1); + add(sOcclusionQueriesInFlight, 1); { LLFastTimer t(FTM_PUSH_OCCLUSION_VERTS); -- 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/llvieweroctree.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 1e01c0fdef..2457f15b50 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1132,7 +1132,7 @@ static LLTrace::TimeBlock FTM_OCCLUSION_SET_BUFFER("Set Buffer"); static LLTrace::TimeBlock FTM_OCCLUSION_DRAW_WATER("Draw Water"); static LLTrace::TimeBlock FTM_OCCLUSION_DRAW("Draw"); -void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* region_agent) +void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* shift) { if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1) { @@ -1140,11 +1140,9 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg LLVector4a bounds[2]; bounds[0] = mBounds[0]; bounds[1] = mBounds[1]; - if(region_agent != NULL) + if(shift != NULL) { - LLVector4a shift((*region_agent)[0], (*region_agent)[1], (*region_agent)[2]); - bounds[0].sub(shift); - bounds[1].sub(shift); + bounds[0].add(*shift); } // Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension -- cgit v1.2.3 From 05ec5ca3d592ed7c730026582a2573d04c6e4c16 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 19 Sep 2013 20:05:53 -0700 Subject: BUILDFIX: forgot forward declaration better overrides for memclaim and memdisclaim of sizes added occlusion stats to stats floater stats now render range instead of mean --- indra/newview/llvieweroctree.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 30658c57bf..47033afea3 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -42,7 +42,6 @@ BOOL LLViewerOctreeDebug::sInDebug = FALSE; static LLTrace::CountStatHandle sOcclusionQueries("occlusion_queries", "Number of occlusion queries executed"), sNumObjectsOccluded("occluded_objects", "Count of objects being occluded by a query"), sNumObjectsUnoccluded("unoccluded_objects", "Count of objects being unoccluded by a query"); -static LLTrace::SampleStatHandle sOcclusionQueriesInFlight("occlusion_queries_in_flight", "Number of occlusion queries waiting for results"); //----------------------------------------------------------------------------------- //some global functions definitions @@ -784,6 +783,7 @@ protected: { #if LL_TRACK_PENDING_OCCLUSION_QUERIES LLSpatialGroup::sPendingQueries.erase(name); + #endif llassert(std::find(mAvailableName.begin(), mAvailableName.end(), name) == mAvailableName.end()); mAvailableName.push_back(name); @@ -1095,7 +1095,6 @@ void LLOcclusionCullingGroup::checkOcclusion() #if LL_TRACK_PENDING_OCCLUSION_QUERIES sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]); #endif - add(sOcclusionQueriesInFlight, -1); } else if (mOcclusionQuery[LLViewerCamera::sCurCameraID]) { //delete the query to avoid holding onto hundreds of pending queries @@ -1200,7 +1199,6 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]); #endif add(sOcclusionQueries, 1); - add(sOcclusionQueriesInFlight, 1); { LL_RECORD_BLOCK_TIME(FTM_PUSH_OCCLUSION_VERTS); -- cgit v1.2.3 From 9053b9020a380f95f23051ca123127519db53e29 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 26 Sep 2013 11:03:04 -0600 Subject: fix for SH-4521: Interesting viewer crash in Pipeline:RenderDrawPools --- indra/newview/llvieweroctree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 47033afea3..e1684c19df 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -957,7 +957,7 @@ public: { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*) n->getListener(0); - if (group->isOcclusionState(mState)) + if (group && group->isOcclusionState(mState)) { OctreeTraveler::traverse(n); } -- cgit v1.2.3 From a5a1b81af28b16406687df3550730a436155589f Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 1 Oct 2013 10:56:30 -0600 Subject: fix for SH-4521: Interesting viewer crash in Pipeline:RenderDrawPools --- indra/newview/llvieweroctree.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index e1684c19df..e8eba43242 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -809,7 +809,14 @@ class LLSpatialSetOcclusionState : public OctreeTraveler public: U32 mState; LLSpatialSetOcclusionState(U32 state) : mState(state) { } - virtual void visit(const OctreeNode* branch) { ((LLOcclusionCullingGroup*) branch->getListener(0))->setOcclusionState(mState); } + virtual void visit(const OctreeNode* branch) + { + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)branch->getListener(0); + if(group) + { + group->setOcclusionState(mState); + } + } }; class LLSpatialSetOcclusionStateDiff : public LLSpatialSetOcclusionState @@ -821,7 +828,7 @@ public: { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*) n->getListener(0); - if (!group->isOcclusionState(mState)) + if (group && !group->isOcclusionState(mState)) { OctreeTraveler::traverse(n); } @@ -945,7 +952,14 @@ public: U32 mState; LLSpatialClearOcclusionState(U32 state) : mState(state) { } - virtual void visit(const OctreeNode* branch) { ((LLOcclusionCullingGroup*) branch->getListener(0))->clearOcclusionState(mState); } + virtual void visit(const OctreeNode* branch) + { + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)branch->getListener(0); + if(group) + { + group->clearOcclusionState(mState); + } + } }; class LLSpatialClearOcclusionStateDiff : public LLSpatialClearOcclusionState -- 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/llvieweroctree.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index e8eba43242..56f10aba71 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -435,6 +435,7 @@ LLviewerOctreeGroup::~LLviewerOctreeGroup() LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : mOctreeNode(node), + mAnyVisible(0), mState(CLEAN) { LLVector4a tmp; @@ -735,6 +736,7 @@ BOOL LLviewerOctreeGroup::isRecentlyVisible() const void LLviewerOctreeGroup::setVisible() { mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); + mAnyVisible = LLViewerOctreeEntryData::getCurrentFrame(); } void LLviewerOctreeGroup::checkStates() @@ -871,6 +873,12 @@ BOOL LLOcclusionCullingGroup::isRecentlyVisible() const return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < MIN_VIS_FRAME_RANGE ; } +BOOL LLOcclusionCullingGroup::isAnyRecentlyVisible() const +{ + const S32 MIN_VIS_FRAME_RANGE = 2; + return (LLDrawable::getCurrentFrame() - mAnyVisible) < MIN_VIS_FRAME_RANGE ; +} + //virtual void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) { -- 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/llvieweroctree.cpp | 120 ++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 59 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index e8eba43242..5bd0a95387 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -231,9 +231,10 @@ S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LL //class LLViewerOctreeEntry definitions //----------------------------------------------------------------------------------- LLViewerOctreeEntry::LLViewerOctreeEntry() - : mGroup(NULL), - mBinRadius(0.f), - mBinIndex(-1) +: LLTrace::MemTrackable("LLViewerOctreeEntry"), + mGroup(NULL), + mBinRadius(0.f), + mBinIndex(-1) { mPositionGroup.clear(); mExtents[0].clear(); @@ -271,7 +272,7 @@ void LLViewerOctreeEntry::removeData(LLViewerOctreeEntryData* data) if(mGroup != NULL && !mData[LLDRAWABLE]) { - LLviewerOctreeGroup* group = mGroup; + LLViewerOctreeGroup* group = mGroup; mGroup = NULL; group->removeFromGroup(data); @@ -285,7 +286,7 @@ void LLViewerOctreeEntry::nullGroup() mGroup = NULL; } -void LLViewerOctreeEntry::setGroup(LLviewerOctreeGroup* group) +void LLViewerOctreeEntry::setGroup(LLViewerOctreeGroup* group) { if(mGroup == group) { @@ -294,7 +295,7 @@ void LLViewerOctreeEntry::setGroup(LLviewerOctreeGroup* group) if(mGroup) { - LLviewerOctreeGroup* group = mGroup; + LLViewerOctreeGroup* group = mGroup; mGroup = NULL; group->removeFromGroup(this); @@ -363,7 +364,7 @@ const LLVector4a* LLViewerOctreeEntryData::getSpatialExtents() const } //virtual -void LLViewerOctreeEntryData::setGroup(LLviewerOctreeGroup* group) +void LLViewerOctreeEntryData::setGroup(LLViewerOctreeGroup* group) { mEntry->setGroup(group); } @@ -375,7 +376,7 @@ void LLViewerOctreeEntryData::shift(const LLVector4a &shift_vector) mEntry->mPositionGroup.add(shift_vector); } -LLviewerOctreeGroup* LLViewerOctreeEntryData::getGroup()const +LLViewerOctreeGroup* LLViewerOctreeEntryData::getGroup()const { return mEntry.notNull() ? mEntry->mGroup : NULL; } @@ -425,15 +426,16 @@ void LLViewerOctreeEntryData::setVisible() const } //----------------------------------------------------------------------------------- -//class LLviewerOctreeGroup definitions +//class LLViewerOctreeGroup definitions //----------------------------------------------------------------------------------- -LLviewerOctreeGroup::~LLviewerOctreeGroup() +LLViewerOctreeGroup::~LLViewerOctreeGroup() { //empty here } -LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : +LLViewerOctreeGroup::LLViewerOctreeGroup(OctreeNode* node) +: LLTrace::MemTrackable("LLViewerOctreeGroup"), mOctreeNode(node), mState(CLEAN) { @@ -448,7 +450,7 @@ LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : mOctreeNode->addListener(this); } -bool LLviewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) +bool LLViewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) { if(!data->getEntry()) { @@ -457,12 +459,12 @@ bool LLviewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) return std::find(getDataBegin(), getDataEnd(), data->getEntry()) != getDataEnd(); } -bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data) +bool LLViewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data) { return removeFromGroup(data->getEntry()); } -bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) +bool LLViewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) { llassert(entry != NULL); llassert(!entry->getGroup()); @@ -483,7 +485,7 @@ bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) } //virtual -void LLviewerOctreeGroup::unbound() +void LLViewerOctreeGroup::unbound() { if (isDirty()) { @@ -498,7 +500,7 @@ void LLviewerOctreeGroup::unbound() OctreeNode* parent = (OctreeNode*) mOctreeNode->getParent(); while (parent != NULL) { - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) parent->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) parent->getListener(0); if (!group || group->isDirty()) { return; @@ -511,7 +513,7 @@ void LLviewerOctreeGroup::unbound() } //virtual -void LLviewerOctreeGroup::rebound() +void LLViewerOctreeGroup::rebound() { if (!isDirty()) { @@ -520,7 +522,7 @@ void LLviewerOctreeGroup::rebound() if (mOctreeNode->getChildCount() == 1 && mOctreeNode->getElementCount() == 0) { - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); group->rebound(); //copy single child's bounding box @@ -541,7 +543,7 @@ void LLviewerOctreeGroup::rebound() { LLVector4a& newMin = mExtents[0]; LLVector4a& newMax = mExtents[1]; - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); group->clearState(SKIP_FRUSTUM_CHECK); group->rebound(); //initialize to first child @@ -551,7 +553,7 @@ void LLviewerOctreeGroup::rebound() //first, rebound children for (U32 i = 1; i < mOctreeNode->getChildCount(); i++) { - group = (LLviewerOctreeGroup*) mOctreeNode->getChild(i)->getListener(0); + group = (LLViewerOctreeGroup*) mOctreeNode->getChild(i)->getListener(0); group->clearState(SKIP_FRUSTUM_CHECK); group->rebound(); const LLVector4a& max = group->mExtents[1]; @@ -575,7 +577,7 @@ void LLviewerOctreeGroup::rebound() } //virtual -void LLviewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj) +void LLViewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj) { obj->setGroup(this); unbound(); @@ -583,7 +585,7 @@ void LLviewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEn } //virtual -void LLviewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj) +void LLViewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj) { unbound(); setState(OBJECT_DIRTY); @@ -592,7 +594,7 @@ void LLviewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntr } //virtual -void LLviewerOctreeGroup::handleDestruction(const TreeNode* node) +void LLViewerOctreeGroup::handleDestruction(const TreeNode* node) { for (OctreeNode::element_iter i = mOctreeNode->getDataBegin(); i != mOctreeNode->getDataEnd(); ++i) { @@ -607,7 +609,7 @@ void LLviewerOctreeGroup::handleDestruction(const TreeNode* node) } //virtual -void LLviewerOctreeGroup::handleStateChange(const TreeNode* node) +void LLViewerOctreeGroup::handleStateChange(const TreeNode* node) { //drop bounding box upon state change if (mOctreeNode != node) @@ -618,29 +620,29 @@ void LLviewerOctreeGroup::handleStateChange(const TreeNode* node) } //virtual -void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) +void LLViewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) { if (child->getListenerCount() == 0) { - new LLviewerOctreeGroup(child); + new LLViewerOctreeGroup(child); } else { - OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << LL_ENDL; + OCT_ERRS << "LLViewerOctreeGroup redundancy detected." << LL_ENDL; } unbound(); - ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); + ((LLViewerOctreeGroup*)child->getListener(0))->unbound(); } //virtual -void LLviewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNode* child) +void LLViewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNode* child) { unbound(); } -LLviewerOctreeGroup* LLviewerOctreeGroup::getParent() +LLViewerOctreeGroup* LLViewerOctreeGroup::getParent() { if (isDead()) { @@ -656,14 +658,14 @@ LLviewerOctreeGroup* LLviewerOctreeGroup::getParent() if (parent) { - return (LLviewerOctreeGroup*) parent->getListener(0); + return (LLViewerOctreeGroup*) parent->getListener(0); } return NULL; } //virtual -bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut) +bool LLViewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut) { const OctreeNode* node = mOctreeNode; @@ -721,23 +723,23 @@ bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4 } //virtual -BOOL LLviewerOctreeGroup::isVisible() const +BOOL LLViewerOctreeGroup::isVisible() const { return mVisible[LLViewerCamera::sCurCameraID] >= LLViewerOctreeEntryData::getCurrentFrame() ? TRUE : FALSE; } //virtual -BOOL LLviewerOctreeGroup::isRecentlyVisible() const +BOOL LLViewerOctreeGroup::isRecentlyVisible() const { return FALSE; } -void LLviewerOctreeGroup::setVisible() +void LLViewerOctreeGroup::setVisible() { mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); } -void LLviewerOctreeGroup::checkStates() +void LLViewerOctreeGroup::checkStates() { #if LL_OCTREE_PARANOIA_CHECK //LLOctreeStateCheck checker; @@ -837,7 +839,7 @@ public: LLOcclusionCullingGroup::LLOcclusionCullingGroup(OctreeNode* node, LLViewerOctreePartition* part) : - LLviewerOctreeGroup(node), + LLViewerOctreeGroup(node), mSpatialPartition(part) { part->mLODSeed = (part->mLODSeed+1)%part->mLODPeriod; @@ -885,7 +887,7 @@ void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, Octr unbound(); - ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); + ((LLViewerOctreeGroup*)child->getListener(0))->unbound(); } void LLOcclusionCullingGroup::releaseOcclusionQueryObjectNames() @@ -1316,7 +1318,7 @@ BOOL LLViewerOctreePartition::isOcclusionEnabled() //----------------------------------------------------------------------------------- //virtual -bool LLViewerOctreeCull::earlyFail(LLviewerOctreeGroup* group) +bool LLViewerOctreeCull::earlyFail(LLViewerOctreeGroup* group) { return false; } @@ -1324,7 +1326,7 @@ bool LLViewerOctreeCull::earlyFail(LLviewerOctreeGroup* group) //virtual void LLViewerOctreeCull::traverse(const OctreeNode* n) { - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) n->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) n->getListener(0); if (earlyFail(group)) { @@ -1332,7 +1334,7 @@ void LLViewerOctreeCull::traverse(const OctreeNode* n) } if (mRes == 2 || - (mRes && group->hasState(LLviewerOctreeGroup::SKIP_FRUSTUM_CHECK))) + (mRes && group->hasState(LLViewerOctreeGroup::SKIP_FRUSTUM_CHECK))) { //fully in, just add everything OctreeTraveler::traverse(n); } @@ -1351,17 +1353,17 @@ void LLViewerOctreeCull::traverse(const OctreeNode* n) //------------------------------------------ //agent space group culling -S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); } -S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLViewerOctreeGroup* group) { return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); } -S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]); } @@ -1369,17 +1371,17 @@ S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* grou //------------------------------------------ //agent space object set culling -S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); } -S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLViewerOctreeGroup* group) { return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); } -S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); } @@ -1387,17 +1389,17 @@ S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* gro //------------------------------------------ //local regional space group culling -S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipGroupBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInRegionFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); } -S32 LLViewerOctreeCull::AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInRegionFrustumGroupBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInRegionFrustum(group->mBounds[0], group->mBounds[1]); } -S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift) +S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLViewerOctreeGroup* group, const LLVector3& shift) { return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); } @@ -1405,24 +1407,24 @@ S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLviewerOctr //------------------------------------------ //local regional space object culling -S32 LLViewerOctreeCull::AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInRegionFrustumObjectBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInRegionFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); } -S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipObjectBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInRegionFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); } -S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLviewerOctreeGroup* group, const LLVector3& shift) +S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLViewerOctreeGroup* group, const LLVector3& shift) { return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); } //------------------------------------------ //virtual -bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOctreeGroup* group) +bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLViewerOctreeGroup* group) { if (branch->getElementCount() == 0) //no elements { @@ -1441,19 +1443,19 @@ bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOc } //virtual -void LLViewerOctreeCull::preprocess(LLviewerOctreeGroup* group) +void LLViewerOctreeCull::preprocess(LLViewerOctreeGroup* group) { } //virtual -void LLViewerOctreeCull::processGroup(LLviewerOctreeGroup* group) +void LLViewerOctreeCull::processGroup(LLViewerOctreeGroup* group) { } //virtual void LLViewerOctreeCull::visit(const OctreeNode* branch) { - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) branch->getListener(0); preprocess(group); @@ -1475,12 +1477,12 @@ void LLViewerOctreeDebug::visit(const OctreeNode* branch) LL_INFOS() << "Child " << i << " : " << (U32)branch->getChild(i) << LL_ENDL; } #endif - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) branch->getListener(0); processGroup(group); } //virtual -void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group) +void LLViewerOctreeDebug::processGroup(LLViewerOctreeGroup* group) { #if 0 const LLVector4a* vec4 = group->getBounds(); -- cgit v1.2.3 From 697d2e720ba75e142a4d56ae8794bab8d7698dad Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 15 Oct 2013 20:24:42 -0700 Subject: renamed TimeBlock to BlockTimerStatHandle --- indra/newview/llvieweroctree.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index ce8eef7d86..e390249504 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1020,8 +1020,8 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode) } } -static LLTrace::TimeBlock FTM_OCCLUSION_READBACK("Readback Occlusion"); -static LLTrace::TimeBlock FTM_OCCLUSION_WAIT("Occlusion Wait"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_READBACK("Readback Occlusion"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_WAIT("Occlusion Wait"); BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* bounds) { @@ -1158,16 +1158,16 @@ void LLOcclusionCullingGroup::checkOcclusion() } } -static LLTrace::TimeBlock FTM_PUSH_OCCLUSION_VERTS("Push Occlusion"); -static LLTrace::TimeBlock FTM_SET_OCCLUSION_STATE("Occlusion State"); -static LLTrace::TimeBlock FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail"); -static LLTrace::TimeBlock FTM_OCCLUSION_ALLOCATE("Allocate"); -static LLTrace::TimeBlock FTM_OCCLUSION_BUILD("Build"); -static LLTrace::TimeBlock FTM_OCCLUSION_BEGIN_QUERY("Begin Query"); -static LLTrace::TimeBlock FTM_OCCLUSION_END_QUERY("End Query"); -static LLTrace::TimeBlock FTM_OCCLUSION_SET_BUFFER("Set Buffer"); -static LLTrace::TimeBlock FTM_OCCLUSION_DRAW_WATER("Draw Water"); -static LLTrace::TimeBlock FTM_OCCLUSION_DRAW("Draw"); +static LLTrace::BlockTimerStatHandle FTM_PUSH_OCCLUSION_VERTS("Push Occlusion"); +static LLTrace::BlockTimerStatHandle FTM_SET_OCCLUSION_STATE("Occlusion State"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_ALLOCATE("Allocate"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_BUILD("Build"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_BEGIN_QUERY("Begin Query"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_END_QUERY("End Query"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_SET_BUFFER("Set Buffer"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_DRAW_WATER("Draw Water"); +static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_DRAW("Draw"); void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* shift) { -- 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/llvieweroctree.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index e390249504..425e7fbd1f 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1430,6 +1430,25 @@ S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLViewerOct return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); } //------------------------------------------ +//check if the objects projection large enough +bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 projection_cutoff) +{ + LLVector3 local_orig = mCamera->getOrigin() - shift; + LLVector4a origin; + origin.load3(local_orig.mV); + + LLVector4a lookAt; + lookAt.setSub(center, origin); + F32 squared_dist = lookAt.dot3(lookAt).getF32(); + F32 squared_rad = size.dot3(size).getF32(); + + if(squared_dist > 0.f) + { + return squared_rad / squared_dist > projection_cutoff; + } + + return true; +} //virtual bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLViewerOctreeGroup* group) -- cgit v1.2.3 From e46c4fd1c6f8d99e87fd53e71d97fb8ce925a576 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 22 Oct 2013 15:47:50 -0600 Subject: trivial: convert to unix endings. --- indra/newview/llvieweroctree.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index af6f8bdede..993967ee94 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -761,22 +761,22 @@ public: } protected: - - virtual GLuint allocateName() - { - GLuint ret = 0; - - glGenQueriesARB(1, &ret); - - return ret; - } - - virtual void releaseName(GLuint name) - { -#if LL_TRACK_PENDING_OCCLUSION_QUERIES - LLOcclusionCullingGroup::sPendingQueries.erase(name); -#endif - glDeleteQueriesARB(1, &name); + + virtual GLuint allocateName() + { + GLuint ret = 0; + + glGenQueriesARB(1, &ret); + + return ret; + } + + virtual void releaseName(GLuint name) + { +#if LL_TRACK_PENDING_OCCLUSION_QUERIES + LLOcclusionCullingGroup::sPendingQueries.erase(name); +#endif + glDeleteQueriesARB(1, &name); } }; -- 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/llvieweroctree.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 993967ee94..ef802f2651 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -425,6 +425,13 @@ void LLViewerOctreeEntryData::setVisible() const } } +void LLViewerOctreeEntryData::resetVisible() const +{ + if(mEntry) + { + mEntry->mVisible = 0; + } +} //----------------------------------------------------------------------------------- //class LLViewerOctreeGroup definitions //----------------------------------------------------------------------------------- -- cgit v1.2.3 From d98b6a932deb3125422c5b544aced9d05ff8f89f Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 24 Oct 2013 19:46:09 -0600 Subject: fix a flaw LLViewerOctreeEntry::mVisible not initialized. --- indra/newview/llvieweroctree.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index ef802f2651..3646133e91 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -36,7 +36,7 @@ //----------------------------------------------------------------------------------- //static variables definitions //----------------------------------------------------------------------------------- -U32 LLViewerOctreeEntryData::sCurVisible = 0; +U32 LLViewerOctreeEntryData::sCurVisible = 10; //reserve the low numbers for special use. BOOL LLViewerOctreeDebug::sInDebug = FALSE; static LLTrace::CountStatHandle sOcclusionQueries("occlusion_queries", "Number of occlusion queries executed"), @@ -234,7 +234,8 @@ LLViewerOctreeEntry::LLViewerOctreeEntry() : LLTrace::MemTrackable("LLViewerOctreeEntry"), mGroup(NULL), mBinRadius(0.f), - mBinIndex(-1) + mBinIndex(-1), + mVisible(0) { mPositionGroup.clear(); mExtents[0].clear(); -- cgit v1.2.3 From 8582cd06ba4ec417efe9dc24971fe7011309a51c Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 29 Oct 2013 22:46:07 -0600 Subject: fix to decrease number of triangles rendered per frame --- indra/newview/llvieweroctree.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 3646133e91..1b3d7da90d 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -746,7 +746,11 @@ BOOL LLViewerOctreeGroup::isRecentlyVisible() const void LLViewerOctreeGroup::setVisible() { mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); - mAnyVisible = LLViewerOctreeEntryData::getCurrentFrame(); + + if(LLViewerCamera::sCurCameraID < LLViewerCamera::CAMERA_WATER0) + { + mAnyVisible = LLViewerOctreeEntryData::getCurrentFrame(); + } } void LLViewerOctreeGroup::checkStates() -- 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/llvieweroctree.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 1b3d7da90d..06ff68c6c3 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1429,7 +1429,7 @@ S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLViewerOct } //------------------------------------------ //check if the objects projection large enough -bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 projection_cutoff) +bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 pixel_threshold, F32 near_squared_radius) { LLVector3 local_orig = mCamera->getOrigin() - shift; LLVector4a origin; @@ -1438,14 +1438,13 @@ bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLV LLVector4a lookAt; lookAt.setSub(center, origin); F32 squared_dist = lookAt.dot3(lookAt).getF32(); - F32 squared_rad = size.dot3(size).getF32(); - - if(squared_dist > 0.f) + if(squared_dist < near_squared_radius) { - return squared_rad / squared_dist > projection_cutoff; + return true; //always load closeby objects } - return true; + F32 squared_rad = size.dot3(size).getF32(); + return squared_rad / squared_dist > pixel_threshold; } //virtual -- cgit v1.2.3 From b6688529877e9f3a46d251c64c002fbe8fd8cbb6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 11 Nov 2013 19:20:46 -0800 Subject: merge fix --- indra/newview/llvieweroctree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 06ff68c6c3..62d34d12b5 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1087,7 +1087,7 @@ void LLOcclusionCullingGroup::checkOcclusion() { glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available); - static LLCachedControl wait_for_query(gSavedSettings, "RenderSynchronousOcclusion"); + static LLCachedControl wait_for_query(gSavedSettings, "RenderSynchronousOcclusion", true); if (wait_for_query && mOcclusionIssued[LLViewerCamera::sCurCameraID] < gFrameCount) { //query was issued last frame, wait until it's available -- cgit v1.2.3 From c14ecc817895d06b04a803a88d00d4ae1c80060a Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 21 Nov 2013 11:20:45 -0700 Subject: fix for SH-4629: Interesting: crash at LLViewerRegion::killObject --- indra/newview/llvieweroctree.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 62d34d12b5..201677b3de 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -268,6 +268,10 @@ void LLViewerOctreeEntry::removeData(LLViewerOctreeEntryData* data) { return; } + if(mData[data->getDataType()] != data) + { + return; + } mData[data->getDataType()] = NULL; -- cgit v1.2.3 From d8e92867162f8c4ff9489d8eefde53546e907dff Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 26 Nov 2013 17:44:54 -0700 Subject: fix for SH-4637: Viewer-Interesting crashes if you teleport after crossing a region border. --- indra/newview/llvieweroctree.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 201677b3de..ff8f4d2434 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -481,6 +481,12 @@ bool LLViewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) { llassert(entry != NULL); llassert(!entry->getGroup()); + + if(isDead()) //group is about to be destroyed, not need to double delete the entry. + { + entry->setBinIndex(-1); + return true; + } unbound(); setState(OBJECT_DIRTY); -- 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/llvieweroctree.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index ff8f4d2434..aef632e913 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1439,22 +1439,30 @@ S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLViewerOct } //------------------------------------------ //check if the objects projection large enough -bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 pixel_threshold, F32 near_squared_radius) + +static LLTrace::BlockTimerStatHandle sProjectedAreaCheckTimeStat("Object projected area check", "Culling objects based on projected area"); + +bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 pixel_threshold, F32 near_radius) { + LL_RECORD_BLOCK_TIME(sProjectedAreaCheckTimeStat); LLVector3 local_orig = mCamera->getOrigin() - shift; LLVector4a origin; origin.load3(local_orig.mV); LLVector4a lookAt; lookAt.setSub(center, origin); - F32 squared_dist = lookAt.dot3(lookAt).getF32(); - if(squared_dist < near_squared_radius) + F32 distance = lookAt.getLength3().getF32(); + if(distance <= near_radius) { - return true; //always load closeby objects + return true; //always load close-by objects } + // treat object as if it were near_radius meters closer than it actually was. + // this allows us to get some temporal coherence on visibility...objects that can be reached quickly will tend to be visible + distance -= near_radius; + F32 squared_rad = size.dot3(size).getF32(); - return squared_rad / squared_dist > pixel_threshold; + return squared_rad / (distance * distance) > pixel_threshold; } //virtual -- 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/llvieweroctree.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index aef632e913..88f3c7d6f9 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1440,11 +1440,8 @@ S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLViewerOct //------------------------------------------ //check if the objects projection large enough -static LLTrace::BlockTimerStatHandle sProjectedAreaCheckTimeStat("Object projected area check", "Culling objects based on projected area"); - bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 pixel_threshold, F32 near_radius) { - LL_RECORD_BLOCK_TIME(sProjectedAreaCheckTimeStat); LLVector3 local_orig = mCamera->getOrigin() - shift; LLVector4a origin; origin.load3(local_orig.mV); @@ -1462,7 +1459,7 @@ bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLV distance -= near_radius; F32 squared_rad = size.dot3(size).getF32(); - return squared_rad / (distance * distance) > pixel_threshold; + return squared_rad / distance > pixel_threshold; } //virtual -- 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/llvieweroctree.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 88f3c7d6f9..12a1e98075 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -330,6 +330,8 @@ LLViewerOctreeEntryData::LLViewerOctreeEntryData(LLViewerOctreeEntry::eEntryData //virtual void LLViewerOctreeEntryData::setOctreeEntry(LLViewerOctreeEntry* entry) { + llassert_always(mEntry.isNull()); + if(mEntry.notNull()) { return; @@ -346,6 +348,15 @@ void LLViewerOctreeEntryData::setOctreeEntry(LLViewerOctreeEntry* entry) mEntry->addData(this); } +void LLViewerOctreeEntryData::removeOctreeEntry() +{ + if(mEntry) + { + mEntry->removeData(this); + mEntry = NULL; + } +} + void LLViewerOctreeEntryData::setSpatialExtents(const LLVector3& min, const LLVector3& max) { mEntry->mExtents[0].load3(min.mV); -- cgit v1.2.3 From 3040b429a3b136b87ddb0ae88ccfa3a7aa71e232 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 6 Feb 2014 11:27:16 -0800 Subject: added LL_TRACE_ENABLED to allow disabling of lltrace --- indra/newview/llvieweroctree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvieweroctree.cpp') diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 12a1e98075..03c3f0fc08 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -300,9 +300,9 @@ void LLViewerOctreeEntry::setGroup(LLViewerOctreeGroup* group) if(mGroup) { - LLViewerOctreeGroup* group = mGroup; + LLViewerOctreeGroup* old_group = mGroup; mGroup = NULL; - group->removeFromGroup(this); + old_group->removeFromGroup(this); llassert(mBinIndex == -1); } -- cgit v1.2.3