From 8d20480c5f77fe1fab8149d3cda79bdd61e77656 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 28 Oct 2021 18:06:21 +0000 Subject: SL-16148 SL-16244 SL-16270 SL-16253 Remove most BlockTimers, remove LLMemTracked, introduce alignas, hook most/all reamining allocs, disable synchronous occlusion, and convert frequently accessed LLSingletons to LLSimpleton --- indra/llmath/lloctree.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'indra/llmath/lloctree.h') diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 0e2f62f9db..8c4a1304b4 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -74,8 +74,9 @@ public: }; template -class LLOctreeNode : public LLTreeNode +class alignas(16) LLOctreeNode : public LLTreeNode { + LL_ALIGN_NEW public: typedef LLOctreeTraveler oct_traveler; @@ -91,16 +92,6 @@ public: typedef LLOctreeNode oct_node; typedef LLOctreeListener oct_listener; - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } - LLOctreeNode( const LLVector4a& center, const LLVector4a& size, BaseType* parent, -- cgit v1.2.3 From 1566c01ad16a973f22990653b3dab8e5bd476db8 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 13 Jan 2022 21:09:52 -0800 Subject: SL-16607: Cleanup magic number for no child nodes --- indra/llmath/lloctree.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'indra/llmath/lloctree.h') diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 8c4a1304b4..80eca781a9 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -92,10 +92,15 @@ public: typedef LLOctreeNode oct_node; typedef LLOctreeListener oct_listener; + enum + { + NO_CHILD_NODES = 255 // Note: This is an U8 to match the max value in mChildMap[] + }; + LLOctreeNode( const LLVector4a& center, const LLVector4a& size, BaseType* parent, - U8 octant = 255) + U8 octant = NO_CHILD_NODES) : mParent((oct_node*)parent), mOctant(octant) { @@ -108,7 +113,7 @@ public: mSize = size; updateMinMax(); - if ((mOctant == 255) && mParent) + if ((mOctant == NO_CHILD_NODES) && mParent) { mOctant = ((oct_node*) mParent)->getOctant(mCenter); } @@ -253,7 +258,7 @@ public: for (U32 i = 0; i < 8; i++) { U8 idx = mChildMap[i]; - if (idx != 255) + if (idx != NO_CHILD_NODES) { LLOctreeNode* child = mChild[idx]; @@ -286,7 +291,7 @@ public: // the data U8 next_node = node->mChildMap[octant]; - while (next_node != 255 && node->getSize()[0] >= rad) + while (next_node != NO_CHILD_NODES && node->getSize()[0] >= rad) { node = node->getChild(next_node); octant = node->getOctant(pos); @@ -514,9 +519,7 @@ public: void clearChildren() { mChildCount = 0; - - U32* foo = (U32*) mChildMap; - foo[0] = foo[1] = 0xFFFFFFFF; + memset(mChildMap, NO_CHILD_NODES, sizeof(mChildMap)); } void validate() @@ -607,11 +610,9 @@ public: --mChildCount; mChild[index] = mChild[mChildCount]; - //rebuild child map - U32* foo = (U32*) mChildMap; - foo[0] = foo[1] = 0xFFFFFFFF; + memset(mChildMap, NO_CHILD_NODES, sizeof(mChildMap)); for (U32 i = 0; i < mChildCount; ++i) { -- cgit v1.2.3 From 9b5f6c636b16e033059bb47d63a7919aeebb69ac Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 13 Jan 2022 21:10:53 -0800 Subject: SL-16607: Add Tracy capture colors for insert, remove, and balance --- indra/llmath/lloctree.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/llmath/lloctree.h') diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 80eca781a9..7032c9651b 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -34,6 +34,9 @@ #define OCT_ERRS LL_WARNS("OctreeErrors") +#define OCTREE_DEBUG_COLOR_REMOVE 0x0000FF // r +#define OCTREE_DEBUG_COLOR_INSERT 0x00FF00 // g +#define OCTREE_DEBUG_COLOR_BALANCE 0xFF0000 // b extern U32 gOctreeMaxCapacity; extern float gOctreeMinSize; @@ -308,6 +311,8 @@ public: virtual bool insert(T* data) { + //LL_PROFILE_ZONE_NAMED_COLOR("Octree::insert()",OCTREE_DEBUG_COLOR_INSERT); + if (data == NULL || data->getBinIndex() != -1) { OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << LL_ENDL; @@ -454,6 +459,8 @@ public: bool remove(T* data) { + //LL_PROFILE_ZONE_NAMED_COLOR("Octree::remove()", OCTREE_DEBUG_COLOR_REMOVE); + S32 i = data->getBinIndex(); if (i >= 0 && i < mElementCount) @@ -692,6 +699,8 @@ public: bool balance() { + //LL_PROFILE_ZONE_NAMED_COLOR("Octree::balance()",OCTREE_DEBUG_COLOR_BALANCE); + if (this->getChildCount() == 1 && !(this->mChild[0]->isLeaf()) && this->mChild[0]->getElementCount() == 0) -- cgit v1.2.3 From 1dde66ca7924358ef6c19c7d9eb8883c434882bf Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 13 Jan 2022 21:11:24 -0800 Subject: SL-16607: Cleanup whitespace --- indra/llmath/lloctree.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'indra/llmath/lloctree.h') diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 7032c9651b..2283df1e1a 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -126,9 +126,9 @@ public: clearChildren(); } - virtual ~LLOctreeNode() + virtual ~LLOctreeNode() { - BaseType::destroyListeners(); + BaseType::destroyListeners(); for (U32 i = 0; i < mElementCount; ++i) { @@ -167,7 +167,7 @@ public: return rad <= mSize[0]*2.f && isInside(pos); } - inline bool isInside(T* data) const + inline bool isInside(T* data) const { return isInside(data->getPositionGroup(), data->getBinRadius()); } @@ -284,7 +284,7 @@ public: LLOctreeNode* node = this; if (node->isInside(pos, rad)) - { + { //do a quick search by octant U8 octant = node->getOctant(pos); @@ -655,7 +655,7 @@ public: OCT_ERRS << "Octree failed to delete requested child." << LL_ENDL; } -protected: +protected: typedef enum { CENTER = 0, @@ -679,7 +679,6 @@ protected: element_list mData; element_iter mDataEnd; U32 mElementCount; - }; //just like a regular node, except it might expand on insert and compress on balance @@ -688,7 +687,7 @@ class LLOctreeRoot : public LLOctreeNode { public: typedef LLOctreeNode BaseType; - typedef LLOctreeNode oct_node; + typedef LLOctreeNode oct_node; LLOctreeRoot(const LLVector4a& center, const LLVector4a& size, @@ -703,7 +702,7 @@ public: if (this->getChildCount() == 1 && !(this->mChild[0]->isLeaf()) && - this->mChild[0]->getElementCount() == 0) + this->mChild[0]->getElementCount() == 0) { //if we have only one child and that child is an empty branch, make that child the root oct_node* child = this->mChild[0]; -- cgit v1.2.3 From 43517c5adc69ecb1d8a5e031a9e2840b005eecf9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 5 May 2022 19:41:56 +0300 Subject: SL-17244 Fix 'empty leaf' crashes --- indra/llmath/lloctree.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'indra/llmath/lloctree.h') diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 2283df1e1a..a9a54a8113 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -73,7 +73,7 @@ template class LLOctreeTravelerDepthFirst : public LLOctreeTraveler { public: - virtual void traverse(const LLOctreeNode* node); + virtual void traverse(const LLOctreeNode* node) override; }; template @@ -696,7 +696,7 @@ public: { } - bool balance() + bool balance() override { //LL_PROFILE_ZONE_NAMED_COLOR("Octree::balance()",OCTREE_DEBUG_COLOR_BALANCE); @@ -732,7 +732,7 @@ public: } // LLOctreeRoot::insert - bool insert(T* data) + bool insert(T* data) override { if (data == NULL) { @@ -835,6 +835,12 @@ public: return false; } + + bool isLeaf() const override + { + // root can't be a leaf + return false; + } }; //======================== -- cgit v1.2.3